fixed bugs for windows. added 2 tests for ffmpeg
authorAndrey Morozov <no@email>
Wed, 1 Jun 2011 16:14:17 +0000 (16:14 +0000)
committerAndrey Morozov <no@email>
Wed, 1 Jun 2011 16:14:17 +0000 (16:14 +0000)
modules/highgui/CMakeLists.txt
modules/highgui/test/test_ffmpeg.cpp [new file with mode: 0644]

index 95cc3e6..c79f211 100644 (file)
@@ -360,7 +360,7 @@ install(FILES ${highgui_ext_hdrs}
 include_directories("${CMAKE_CURRENT_SOURCE_DIR}/test"
                     "${CMAKE_CURRENT_BINARY_DIR}")
 
-set(test_deps opencv_ts opencv_highgui)
+set(test_deps opencv_ts opencv_highgui opencv_imgproc)
 
 foreach(d ${test_deps})
     if(${d} MATCHES "opencv_")
diff --git a/modules/highgui/test/test_ffmpeg.cpp b/modules/highgui/test/test_ffmpeg.cpp
new file mode 100644 (file)
index 0000000..7b00170
--- /dev/null
@@ -0,0 +1,101 @@
+/*M///////////////////////////////////////////////////////////////////////////////////////\r
+//\r
+//  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.\r
+//\r
+//  By downloading, copying, installing or using the software you agree to this license.\r
+//  If you do not agree to this license, do not download, install,\r
+//  copy or use the software.\r
+//\r
+//\r
+//                           License Agreement\r
+//                For Open Source Computer Vision Library\r
+//\r
+// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.\r
+// Copyright (C) 2009, Willow Garage Inc., all rights reserved.\r
+// Third party copyrights are property of their respective owners.\r
+//\r
+// Redistribution and use in source and binary forms, with or without modification,\r
+// are permitted provided that the following conditions are met:\r
+//\r
+//   * Redistribution's of source code must retain the above copyright notice,\r
+//     this list of conditions and the following disclaimer.\r
+//\r
+//   * Redistribution's in binary form must reproduce the above copyright notice,\r
+//     this list of conditions and the following disclaimer in the documentation\r
+//     and/or other materials provided with the distribution.\r
+//\r
+//   * The name of the copyright holders may not be used to endorse or promote products\r
+//     derived from this software without specific prior written permission.\r
+//\r
+// This software is provided by the copyright holders and contributors "as is" and\r
+// any express or implied warranties, including, but not limited to, the implied\r
+// warranties of merchantability and fitness for a particular purpose are disclaimed.\r
+// In no event shall the Intel Corporation or contributors be liable for any direct,\r
+// indirect, incidental, special, exemplary, or consequential damages\r
+// (including, but not limited to, procurement of substitute goods or services;\r
+// loss of use, data, or profits; or business interruption) however caused\r
+// and on any theory of liability, whether in contract, strict liability,\r
+// or tort (including negligence or otherwise) arising in any way out of\r
+// the use of this software, even if advised of the possibility of such damage.\r
+//\r
+//M*/\r
+\r
+#include "test_precomp.hpp"\r
+#include "opencv2/highgui/highgui.hpp"\r
+\r
+using namespace cv;\r
+using namespace std;\r
+\r
+class CV_FFmpegWriteBigImagesTest : public cvtest::BaseTest\r
+{\r
+       public:\r
+               void run(int)\r
+               {\r
+                       try\r
+                       {\r
+                               Mat img = imread(string(ts->get_data_path()) + "readwrite/read.png", 0);\r
+                               if (img.empty()) ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_TEST_DATA);\r
+                               imwrite(string(ts->get_data_path()) + "readwrite/write.png", img);\r
+                       }\r
+                       catch(...)\r
+                       {\r
+                               ts->set_failed_test_info(cvtest::TS::FAIL_EXCEPTION);\r
+                       }\r
+                       ts->set_failed_test_info(cvtest::TS::OK);\r
+               }\r
+};\r
+\r
+class CV_FFmpegWriteBigVideoTest : public cvtest::BaseTest\r
+{\r
+       public:\r
+               void run(int)\r
+               {\r
+                       const int img_r = 4096;\r
+                       const int img_c = 4096;\r
+                       Size frame_s = Size(img_c, img_r);\r
+                       const double fps = 30;\r
+                       const double time_sec = 1;\r
+\r
+                       Mat img(img_r, img_c, CV_8UC3, Scalar::all(0));\r
+                       try\r
+                       {\r
+                               VideoWriter writer(string(ts->get_data_path()) + "video/output.avi",\r
+                                       CV_FOURCC('X', 'V', 'I', 'D'), fps, frame_s);\r
+\r
+                               for (int i = 0 ; i < static_cast<int>(fps * time_sec); i++ )\r
+                               {\r
+                                       circle(img, Point2i(img_c / 2, img_r / 2), cv::min(img_r, img_c) / 2 * (i + 1), Scalar::all(255));\r
+                                       writer << img;\r
+                               }\r
+                       }\r
+                       catch(...)\r
+                       {\r
+                               ts->set_failed_test_info(cvtest::TS::FAIL_EXCEPTION);\r
+                       }\r
+                       ts->set_failed_test_info(cvtest::TS::OK);\r
+               }\r
+};\r
+\r
+\r
+TEST(Highgui_FFmpeg_WriteBigImage, regression) { CV_FFmpegWriteBigImagesTest test; test.safe_run(); }\r
+TEST(Highgui_FFmpeg_WriteBigVideo, regression) { CV_FFmpegWriteBigVideoTest  test; test.safe_run(); }\r