Refactored build conditionals in highgui tests
authorAndrey Kamaev <no@email>
Wed, 18 Apr 2012 21:32:56 +0000 (21:32 +0000)
committerAndrey Kamaev <no@email>
Wed, 18 Apr 2012 21:32:56 +0000 (21:32 +0000)
modules/highgui/src/cap.cpp
modules/highgui/test/test_drawing.cpp
modules/highgui/test/test_framecount.cpp
modules/highgui/test/test_grfmt.cpp
modules/highgui/test/test_positioning.cpp
modules/highgui/test/test_precomp.hpp
modules/highgui/test/test_video_io.cpp
modules/highgui/test/test_video_pos.cpp
modules/python/test/goodfeatures.py

index 96767d9..edfea55 100644 (file)
@@ -121,13 +121,27 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
 #ifdef HAVE_VIDEOINPUT
         CV_CAP_DSHOW,
 #endif
+#if 1
         CV_CAP_IEEE1394,   // identical to CV_CAP_DC1394
+#endif
+#ifdef HAVE_TYZX
         CV_CAP_STEREO,
+#endif
+#ifdef HAVE_PVAPI
         CV_CAP_PVAPI,
+#endif
+#if 1
         CV_CAP_VFW,        // identical to CV_CAP_V4L
+#endif
+#ifdef HAVE_MIL
         CV_CAP_MIL,
+#endif
+#ifdef HAVE_QUICKTIME
         CV_CAP_QT,
+#endif
+#ifdef HAVE_UNICAP
         CV_CAP_UNICAP,
+#endif
 #ifdef HAVE_OPENNI
         CV_CAP_OPENNI,
 #endif
@@ -137,7 +151,9 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
 #ifdef HAVE_XIMEA
         CV_CAP_XIAPI,
 #endif
-        CV_CAP_AVFOUNDATION
+#ifdef HAVE_AVFOUNDATION
+        CV_CAP_AVFOUNDATION,
+#endif
         -1
     };
 
@@ -153,142 +169,159 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
     // try every possibly installed camera API
     for (int i = 0; domains[i] >= 0; i++)
     {
-        #if defined(HAVE_VIDEOINPUT) || defined(HAVE_TYZX) || defined(HAVE_VFW) || \
-        defined(HAVE_CAMV4L) || defined (HAVE_CAMV4L2) || defined(HAVE_GSTREAMER) || \
-        defined(HAVE_DC1394_2) || defined(HAVE_DC1394) || defined(HAVE_CMU1394) || \
-        defined(HAVE_GSTREAMER) || defined(HAVE_MIL) || defined(HAVE_QUICKTIME) || \
-        defined(HAVE_UNICAP) || defined(HAVE_PVAPI) || defined(HAVE_OPENNI) || defined(HAVE_ANDROID_NATIVE_CAMERA) || \
-        defined(HAVE_AVFOUNDATION)
+#if defined(HAVE_VIDEOINPUT)   || \
+    defined(HAVE_TYZX)         || \
+    defined(HAVE_VFW)          || \
+    defined(HAVE_LIBV4L)       || \
+    (defined(HAVE_CAMV4L) && defined(HAVE_CAMV4L2)) || \
+    defined(HAVE_GSTREAMER)    || \
+    defined(HAVE_DC1394_2)     || \
+    defined(HAVE_DC1394)       || \
+    defined(HAVE_CMU1394)      || \
+    defined(HAVE_MIL)          || \
+    defined(HAVE_QUICKTIME)    || \
+    defined(HAVE_UNICAP)       || \
+    defined(HAVE_PVAPI)        || \
+    defined(HAVE_OPENNI)       || \
+    defined(HAVE_XIMEA)        || \
+    defined(HAVE_AVFOUNDATION) || \
+    defined(HAVE_ANDROID_NATIVE_CAMERA) || \
+    (0)
         // local variable to memorize the captured device
         CvCapture *capture;
-        #endif
+#endif
 
         switch (domains[i])
         {
-        #ifdef HAVE_VIDEOINPUT
+#ifdef HAVE_VIDEOINPUT
         case CV_CAP_DSHOW:
             capture = cvCreateCameraCapture_DShow (index);
             if (capture)
                 return capture;
             break;
-        #endif
+#endif
 
-        #ifdef HAVE_TYZX
+#ifdef HAVE_TYZX
         case CV_CAP_STEREO:
             capture = cvCreateCameraCapture_TYZX (index);
             if (capture)
                 return capture;
             break;
-        #endif
+#endif
 
         case CV_CAP_VFW:
-        #ifdef HAVE_VFW
+#ifdef HAVE_VFW
             capture = cvCreateCameraCapture_VFW (index);
             if (capture)
                 return capture;
-        #endif
-        #if defined HAVE_LIBV4L || (defined (HAVE_CAMV4L) && defined (HAVE_CAMV4L2))
+#endif
+
+#if defined HAVE_LIBV4L || (defined (HAVE_CAMV4L) && defined (HAVE_CAMV4L2))
             capture = cvCreateCameraCapture_V4L (index);
             if (capture)
                 return capture;
-        #endif
-        #ifdef HAVE_GSTREAMER
+#endif
+
+#ifdef HAVE_GSTREAMER
             capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L2, 0);
             if (capture)
                 return capture;
             capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L, 0);
             if (capture)
                 return capture;
-        #endif
-            break;
+#endif
+            break; //CV_CAP_VFW
 
         case CV_CAP_FIREWIRE:
-        #ifdef HAVE_DC1394_2
+#ifdef HAVE_DC1394_2
             capture = cvCreateCameraCapture_DC1394_2 (index);
             if (capture)
                 return capture;
-        #endif
-        #ifdef HAVE_DC1394
+#endif
+
+#ifdef HAVE_DC1394
             capture = cvCreateCameraCapture_DC1394 (index);
             if (capture)
                 return capture;
-        #endif
-        #ifdef HAVE_CMU1394
+#endif
+
+#ifdef HAVE_CMU1394
             capture = cvCreateCameraCapture_CMU (index);
             if (capture)
                 return capture;
-        #endif
-    /* Re-enable again when gstreamer 1394 support will land in the backend code       
-        #ifdef HAVE_GSTREAMER
+#endif
+
+#ifdef HAVE_GSTREAMER && 0
+            //Re-enable again when gstreamer 1394 support will land in the backend code
             capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_1394, 0);
             if (capture)
                 return capture;
-        #endif
-    */ 
-            break;
-        #ifdef HAVE_MIL
+#endif
+            break; //CV_CAP_FIREWIRE
+
+#ifdef HAVE_MIL
         case CV_CAP_MIL:
             capture = cvCreateCameraCapture_MIL (index);
             if (capture)
                 return capture;
             break;
-        #endif
+#endif
 
-        #ifdef HAVE_QUICKTIME
+#ifdef HAVE_QUICKTIME
         case CV_CAP_QT:
             capture = cvCreateCameraCapture_QT (index);
             if (capture)
                 return capture;
             break;
-        #endif
+#endif
 
-        #ifdef HAVE_UNICAP
+#ifdef HAVE_UNICAP
         case CV_CAP_UNICAP:
             capture = cvCreateCameraCapture_Unicap (index);
             if (capture)
                 return capture;
         break;
-        #endif
+#endif
         
-        #ifdef HAVE_PVAPI
+#ifdef HAVE_PVAPI
         case CV_CAP_PVAPI:
             capture = cvCreateCameraCapture_PvAPI (index);
             if (capture)
                 return capture;
         break;
-        #endif
+#endif
 
-        #ifdef HAVE_OPENNI
+#ifdef HAVE_OPENNI
         case CV_CAP_OPENNI:
             capture = cvCreateCameraCapture_OpenNI (index);
             if (capture)
                 return capture;
         break;
-        #endif
+#endif
 
-        #ifdef HAVE_ANDROID_NATIVE_CAMERA
+#ifdef HAVE_ANDROID_NATIVE_CAMERA
         case CV_CAP_ANDROID:
             capture = cvCreateCameraCapture_Android (index);
             if (capture)
                 return capture;
         break;
-        #endif
+#endif
         
-        #ifdef HAVE_XIMEA
+#ifdef HAVE_XIMEA
         case CV_CAP_XIAPI:
             capture = cvCreateCameraCapture_XIMEA (index);
             if (capture)
                 return capture;
         break;
-        #endif
+#endif
 
-        #ifdef HAVE_AVFOUNDATION
+#ifdef HAVE_AVFOUNDATION
         case CV_CAP_AVFOUNDATION:
             capture = cvCreateCameraCapture_AVFoundation (index);
             if (capture)
                 return capture;
         break;
-        #endif
+#endif
         }
     }
 
@@ -307,30 +340,30 @@ CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
     if (! result)
         result = cvCreateFileCapture_FFMPEG_proxy (filename);
 
-    #ifdef HAVE_XINE
+#ifdef HAVE_XINE
     if (! result)
         result = cvCreateFileCapture_XINE (filename);
-    #endif
+#endif
 
-    #ifdef HAVE_GSTREAMER
+#ifdef HAVE_GSTREAMER
     if (! result)
         result = cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename);
-    #endif
+#endif
 
-    #ifdef HAVE_QUICKTIME
+#ifdef HAVE_QUICKTIME
     if (! result)
         result = cvCreateFileCapture_QT (filename);
-    #endif
+#endif
     
-    #ifdef HAVE_AVFOUNDATION
+#ifdef HAVE_AVFOUNDATION
     if (! result)
         result = cvCreateFileCapture_AVFoundation (filename);
-    #endif
+#endif
 
-    #ifdef HAVE_OPENNI
+#ifdef HAVE_OPENNI
     if (! result)
         result = cvCreateFileCapture_OpenNI (filename);
-    #endif
+#endif
     
     if (! result)
         result = cvCreateFileCapture_Images (filename);
@@ -360,19 +393,21 @@ CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
                result = cvCreateVideoWriter_XINE(filename, fourcc, fps, frameSize, is_color);
        #endif
 */
-    #ifdef HAVE_AVFOUNDATION 
+#ifdef HAVE_AVFOUNDATION 
     if (! result)
         result = cvCreateVideoWriter_AVFoundation(filename, fourcc, fps, frameSize, is_color);
-    #endif
+#endif
 
-       #ifdef HAVE_QUICKTIME
+#ifdef HAVE_QUICKTIME
        if(!result)
                result = cvCreateVideoWriter_QT(filename, fourcc, fps, frameSize, is_color);
-       #endif
-    #ifdef HAVE_GSTREAMER
+#endif
+
+#ifdef HAVE_GSTREAMER
     if (! result)
         result = cvCreateVideoWriter_GStreamer(filename, fourcc, fps, frameSize, is_color);
-    #endif
+#endif
+
        if(!result)
                result = cvCreateVideoWriter_Images(filename);
 
index a887c0f..a4a7269 100644 (file)
@@ -406,8 +406,10 @@ int CV_DrawingTest_C::checkLineIterator( Mat& _img )
     return 0;
 }
 
+#ifdef HAVE_JPEG
 TEST(Highgui_Drawing_CPP,    regression) { CV_DrawingTest_CPP test; test.safe_run(); }
 TEST(Highgui_Drawing_C,      regression) { CV_DrawingTest_C   test; test.safe_run(); }
+#endif
 
 class CV_FillConvexPolyTest : public cvtest::BaseTest
 {
index 1764c27..4c19687 100644 (file)
@@ -55,9 +55,6 @@ public:
 
 void CV_FramecountTest::run(int)
 {
-#if defined WIN32 || (defined __linux__ && !defined ANDROID) || (defined __APPLE__ && defined HAVE_FFMPEG)
-#if !defined HAVE_GSTREAMER || defined HAVE_GSTREAMER_APP
-
     const int time_sec = 5, fps = 25;
 
     const string ext[] = {"avi", "mov", "mp4", "mpg", "wmv"};
@@ -126,9 +123,7 @@ void CV_FramecountTest::run(int)
 
     ts->printf(cvtest::TS::LOG, "\nSuccessfull experiments: %d (%d%%)\n", n-failed, (n - failed)*100/n);
     ts->printf(cvtest::TS::LOG, "Failed experiments: %d (%d%%)\n", failed, failed*100/n);
-
-#endif
-#endif
 }
-
+#if BUILD_WITH_VIDEO_INPUT_SUPPORT
 TEST(HighguiFramecount, regression) {CV_FramecountTest test; test.safe_run();}
+#endif
index 377d8b2..c9cc5a6 100644 (file)
@@ -201,7 +201,13 @@ public:
     }
 };
 
+#ifdef HAVE_PNG
 TEST(Highgui_Grfmt_WriteBigImage,         regression) { CV_GrfmtWriteBigImageTest      test; test.safe_run(); }
+#endif
+
+#if defined(HAVE_PNG) && defined(HAVE_TIFF) && defined(HAVE_JPEG)
 TEST(Highgui_Grfmt_WriteSequenceImage,    regression) { CV_GrfmtWriteSequenceImageTest test; test.safe_run(); }
+#endif
+
 TEST(GrfmtReadBMPRLE8,    regression) { CV_GrfmtReadBMPRLE8Test test; test.safe_run(); }
 
index 87e42c9..c77ee4f 100644 (file)
@@ -209,25 +209,15 @@ void CV_VideoPositioningTest::run_test(int method)
 
 void CV_VideoProgressivePositioningTest::run(int) 
 {
-#if defined WIN32 || (defined __linux__ && !defined ANDROID) || (defined __APPLE__ && defined HAVE_FFMPEG)
-#if !defined HAVE_GSTREAMER || defined HAVE_GSTREAMER_APP
-
        run_test(PROGRESSIVE);
-
-#endif
-#endif
 }
 
 void CV_VideoRandomPositioningTest::run(int)
 {
-#if defined WIN32 || (defined __linux__ && !defined ANDROID) || (defined __APPLE__ && defined HAVE_FFMPEG)
-#if !defined HAVE_GSTREAMER || defined HAVE_GSTREAMER_APP
-
        run_test(RANDOM);
-
-#endif
-#endif
 }
 
+#if BUILD_WITH_VIDEO_INPUT_SUPPORT
 TEST (HighguiPositioning, progressive) { CV_VideoProgressivePositioningTest test; test.safe_run(); }
 TEST (HighguiPositioning, random) { CV_VideoRandomPositioningTest test; test.safe_run(); }
+#endif
\ No newline at end of file
index a2804a2..786ef38 100644 (file)
 #include "opencv2/imgproc/imgproc_c.h"
 #include <iostream>
 
+#if defined(HAVE_VIDEOINPUT)   || \
+    defined(HAVE_TYZX)         || \
+    defined(HAVE_VFW)          || \
+    defined(HAVE_LIBV4L)       || \
+    (defined(HAVE_CAMV4L) && defined(HAVE_CAMV4L2)) || \
+    defined(HAVE_GSTREAMER)    || \
+    defined(HAVE_DC1394_2)     || \
+    defined(HAVE_DC1394)       || \
+    defined(HAVE_CMU1394)      || \
+    defined(HAVE_MIL)          || \
+    defined(HAVE_QUICKTIME)    || \
+    defined(HAVE_UNICAP)       || \
+    defined(HAVE_PVAPI)        || \
+    defined(HAVE_OPENNI)       || \
+    defined(HAVE_XIMEA)        || \
+    defined(HAVE_AVFOUNDATION) || \
+    (0)
+    //defined(HAVE_ANDROID_NATIVE_CAMERA) ||   - enable after #1193
+#  define BUILD_WITH_CAMERA_SUPPORT 1
+#else
+#  define BUILD_WITH_CAMERA_SUPPORT 0
+#endif
+
+#if defined(HAVE_XINE)         || \
+    defined(HAVE_GSTREAMER)    || \
+    defined(HAVE_QUICKTIME)    || \
+    defined(HAVE_AVFOUNDATION) || \
+    /*defined(HAVE_OPENNI)     || too specialized */ \
+    defined(HAVE_FFMPEG)       || \
+    defined(WIN32) /* assume that we have ffmpeg */
+    
+#  define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
+#else
+#  define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
+#endif
+
+#if /*defined(HAVE_XINE)       || */\
+    defined(HAVE_GSTREAMER)    || \
+    defined(HAVE_QUICKTIME)    || \
+    defined(HAVE_AVFOUNDATION) || \
+    defined(HAVE_FFMPEG)       || \
+    defined(WIN32) /* assume that we have ffmpeg */
+#  define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 1
+#else
+#  define BUILD_WITH_VIDEO_OUTPUT_SUPPORT 0
+#endif
+
+
 #endif
index 3910547..bfaf252 100644 (file)
@@ -141,7 +141,26 @@ void CV_HighGuiTest::ImageTest(const string& dir)
         return;
     }
 
-    const string exts[] = {"png", "bmp", "tiff", "jpg", "jp2", "ppm", "ras" };
+    const string exts[] = {
+#ifdef HAVE_PNG
+        "png",
+#endif
+#ifdef HAVE_TIFF
+        "tiff",
+#endif
+#ifdef HAVE_JPEG
+        "jpg",
+#endif
+#ifdef HAVE_JASPER
+        "jp2",
+#endif
+#ifdef HAVE_OPENEXR
+        "exr",
+#endif
+        "bmp",
+        "ppm",
+        "ras"
+        };
     const size_t ext_num = sizeof(exts)/sizeof(exts[0]);
 
     for(size_t i = 0; i < ext_num; ++i)
@@ -632,9 +651,6 @@ void CV_SpecificImageTest::run(int)
 
 void CV_VideoTest::run(int)
 {
-#if defined WIN32 || (defined __linux__ && !defined ANDROID) || (defined __APPLE__ && defined HAVE_FFMPEG)
-#if !defined HAVE_GSTREAMER || defined HAVE_GSTREAMER_APP
-
     const char codecs[][4] = { {'I', 'Y', 'U', 'V'},
                                {'X', 'V', 'I', 'D'},
                                {'m', 'p', 'e', 'g'},
@@ -648,16 +664,10 @@ void CV_VideoTest::run(int)
     {
         VideoTest(ts->get_data_path(), CV_FOURCC(codecs[i][0], codecs[i][1], codecs[i][2], codecs[i][3]));
     }
-
-#endif
-#endif
 }
 
 void CV_SpecificVideoFileTest::run(int)
 {
-#if defined WIN32 || (defined __linux__ && !defined ANDROID) || (defined __APPLE__ && defined HAVE_FFMPEG)
-#if !defined HAVE_GSTREAMER || defined HAVE_GSTREAMER_APP
-
     const char codecs[][4] = { {'m', 'p', 'e', 'g'},
                                {'X', 'V', 'I', 'D'},
                                {'M', 'J', 'P', 'G'},
@@ -669,16 +679,10 @@ void CV_SpecificVideoFileTest::run(int)
     {
         SpecificVideoFileTest(ts->get_data_path(), codecs[i]);
     }
-
-#endif
-#endif
 }
 
 void CV_SpecificVideoCameraTest::run(int)
 {
-#if defined WIN32 || (defined __linux__ && !defined ANDROID)
-#if !defined HAVE_GSTREAMER || defined HAVE_GSTREAMER_APP
-
     const char codecs[][4] = { {'m', 'p', 'e', 'g'},
                                {'X', 'V', 'I', 'D'},
                                {'M', 'J', 'P', 'G'},
@@ -690,13 +694,19 @@ void CV_SpecificVideoCameraTest::run(int)
     {
         SpecificVideoCameraTest(ts->get_data_path(), codecs[i]);
     }
-
-#endif
-#endif
 }
 
+#ifdef HAVE_JPEG
 TEST(Highgui_Image, regression) { CV_ImageTest test; test.safe_run(); }
+#endif
+
+#if BUILD_WITH_VIDEO_INPUT_SUPPORT && BUILD_WITH_VIDEO_OUTPUT_SUPPORT
 TEST(Highgui_Video, regression) { CV_VideoTest test; test.safe_run(); }
-TEST(Highgui_SpecificImage, regression) { CV_SpecificImageTest test; test.safe_run(); }
 TEST(Highgui_SpecificVideoFile, regression) { CV_SpecificVideoFileTest test; test.safe_run(); }
+#endif
+
+#if BUILD_WITH_VIDEO_INPUT_SUPPORT && BUILD_WITH_VIDEO_OUTPUT_SUPPORT && BUILD_WITH_CAMERA_SUPPORT
 TEST(Highgui_SpecificVideoCamera, regression) { CV_SpecificVideoCameraTest test; test.safe_run(); }
+#endif
+
+TEST(Highgui_SpecificImage, regression) { CV_SpecificImageTest test; test.safe_run(); }
index 2091f7c..b114ec5 100755 (executable)
 #include "test_precomp.hpp"\r
 #include "opencv2/highgui/highgui.hpp"\r
 \r
-#ifdef HAVE_FFMPEG\r
-\r
-#include "ffmpeg_codecs.hpp"\r
-\r
 using namespace cv;\r
 using namespace std;\r
 \r
@@ -102,9 +98,6 @@ void CV_PositioningTest::CreateTestVideo(const string& format, int codec, int fr
 \r
 void CV_PositioningTest::run(int)\r
 {\r
-#if defined WIN32 || (defined __linux__ && !defined ANDROID) || (defined __APPLE__ && defined HAVE_FFMPEG)\r
-#if !defined HAVE_GSTREAMER || defined HAVE_GSTREAMER_APP\r
-\r
     const string format[] =  {"avi", "mov", "mp4", "mpg", "wmv", "3gp"};\r
 \r
     const char codec[][4] = { {'X', 'V', 'I', 'D'},\r
@@ -219,11 +212,8 @@ void CV_PositioningTest::run(int)
       ts->printf(ts->LOG, "\nSuccessfull iterations: %d(%d%%)   Failed iterations: %d(%d%%)   %s\n", N-failed, (N-failed)*100/N, failed, failed*100/N, status.c_str());\r
       if( i < n_format-1 || j < n_codec-1 ) ts->printf(ts->LOG, "\n----------");\r
     }\r
-\r
-#endif\r
-#endif\r
 }\r
 \r
+#if BUILD_WITH_VIDEO_INPUT_SUPPORT && BUILD_WITH_VIDEO_OUTPUT_SUPPORT\r
 TEST(Highgui_Positioning, regression) { CV_PositioningTest test; test.safe_run(); }\r
-\r
 #endif\r
index 37f64ac..e4c4b0a 100644 (file)
@@ -10,14 +10,14 @@ class TestGoodFeaturesToTrack(unittest.TestCase):
         temp_image = cv.CreateImage(size, cv.IPL_DEPTH_32F, 1)
         threshes = [ x / 100. for x in range(1,10) ]
 
-        results = dict([(t, cv.GoodFeaturesToTrack(arr, eig_image, temp_image, 20000, t, 2, use_harris = 1)) for t in threshes])
+        results = dict([(t, cv.GoodFeaturesToTrack(arr, eig_image, temp_image, 20000, t, 2, useHarris = 1)) for t in threshes])
 
         # Check that GoodFeaturesToTrack has not modified input image
         self.assert_(arr.tostring() == original.tostring())
 
         # Check for repeatability
         for i in range(10):
-            results2 = dict([(t, cv.GoodFeaturesToTrack(arr, eig_image, temp_image, 20000, t, 2, use_harris = 1)) for t in threshes])
+            results2 = dict([(t, cv.GoodFeaturesToTrack(arr, eig_image, temp_image, 20000, t, 2, useHarris = 1)) for t in threshes])
             self.assert_(results == results2)
 
         for t0,t1 in zip(threshes, threshes[1:]):