Skip to content

Commit 2bedf5b

Browse files
author
Andrey Kamaev
committed
Refactored build conditionals in highgui tests
1 parent b14df1c commit 2bedf5b

File tree

9 files changed

+190
-114
lines changed

9 files changed

+190
-114
lines changed

modules/highgui/src/cap.cpp

Lines changed: 97 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,27 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
121121
#ifdef HAVE_VIDEOINPUT
122122
CV_CAP_DSHOW,
123123
#endif
124+
#if 1
124125
CV_CAP_IEEE1394, // identical to CV_CAP_DC1394
126+
#endif
127+
#ifdef HAVE_TYZX
125128
CV_CAP_STEREO,
129+
#endif
130+
#ifdef HAVE_PVAPI
126131
CV_CAP_PVAPI,
132+
#endif
133+
#if 1
127134
CV_CAP_VFW, // identical to CV_CAP_V4L
135+
#endif
136+
#ifdef HAVE_MIL
128137
CV_CAP_MIL,
138+
#endif
139+
#ifdef HAVE_QUICKTIME
129140
CV_CAP_QT,
141+
#endif
142+
#ifdef HAVE_UNICAP
130143
CV_CAP_UNICAP,
144+
#endif
131145
#ifdef HAVE_OPENNI
132146
CV_CAP_OPENNI,
133147
#endif
@@ -137,7 +151,9 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
137151
#ifdef HAVE_XIMEA
138152
CV_CAP_XIAPI,
139153
#endif
140-
CV_CAP_AVFOUNDATION
154+
#ifdef HAVE_AVFOUNDATION
155+
CV_CAP_AVFOUNDATION,
156+
#endif
141157
-1
142158
};
143159

@@ -153,142 +169,159 @@ CV_IMPL CvCapture * cvCreateCameraCapture (int index)
153169
// try every possibly installed camera API
154170
for (int i = 0; domains[i] >= 0; i++)
155171
{
156-
#if defined(HAVE_VIDEOINPUT) || defined(HAVE_TYZX) || defined(HAVE_VFW) || \
157-
defined(HAVE_CAMV4L) || defined (HAVE_CAMV4L2) || defined(HAVE_GSTREAMER) || \
158-
defined(HAVE_DC1394_2) || defined(HAVE_DC1394) || defined(HAVE_CMU1394) || \
159-
defined(HAVE_GSTREAMER) || defined(HAVE_MIL) || defined(HAVE_QUICKTIME) || \
160-
defined(HAVE_UNICAP) || defined(HAVE_PVAPI) || defined(HAVE_OPENNI) || defined(HAVE_ANDROID_NATIVE_CAMERA) || \
161-
defined(HAVE_AVFOUNDATION)
172+
#if defined(HAVE_VIDEOINPUT) || \
173+
defined(HAVE_TYZX) || \
174+
defined(HAVE_VFW) || \
175+
defined(HAVE_LIBV4L) || \
176+
(defined(HAVE_CAMV4L) && defined(HAVE_CAMV4L2)) || \
177+
defined(HAVE_GSTREAMER) || \
178+
defined(HAVE_DC1394_2) || \
179+
defined(HAVE_DC1394) || \
180+
defined(HAVE_CMU1394) || \
181+
defined(HAVE_MIL) || \
182+
defined(HAVE_QUICKTIME) || \
183+
defined(HAVE_UNICAP) || \
184+
defined(HAVE_PVAPI) || \
185+
defined(HAVE_OPENNI) || \
186+
defined(HAVE_XIMEA) || \
187+
defined(HAVE_AVFOUNDATION) || \
188+
defined(HAVE_ANDROID_NATIVE_CAMERA) || \
189+
(0)
162190
// local variable to memorize the captured device
163191
CvCapture *capture;
164-
#endif
192+
#endif
165193

166194
switch (domains[i])
167195
{
168-
#ifdef HAVE_VIDEOINPUT
196+
#ifdef HAVE_VIDEOINPUT
169197
case CV_CAP_DSHOW:
170198
capture = cvCreateCameraCapture_DShow (index);
171199
if (capture)
172200
return capture;
173201
break;
174-
#endif
202+
#endif
175203

176-
#ifdef HAVE_TYZX
204+
#ifdef HAVE_TYZX
177205
case CV_CAP_STEREO:
178206
capture = cvCreateCameraCapture_TYZX (index);
179207
if (capture)
180208
return capture;
181209
break;
182-
#endif
210+
#endif
183211

184212
case CV_CAP_VFW:
185-
#ifdef HAVE_VFW
213+
#ifdef HAVE_VFW
186214
capture = cvCreateCameraCapture_VFW (index);
187215
if (capture)
188216
return capture;
189-
#endif
190-
#if defined HAVE_LIBV4L || (defined (HAVE_CAMV4L) && defined (HAVE_CAMV4L2))
217+
#endif
218+
219+
#if defined HAVE_LIBV4L || (defined (HAVE_CAMV4L) && defined (HAVE_CAMV4L2))
191220
capture = cvCreateCameraCapture_V4L (index);
192221
if (capture)
193222
return capture;
194-
#endif
195-
#ifdef HAVE_GSTREAMER
223+
#endif
224+
225+
#ifdef HAVE_GSTREAMER
196226
capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L2, 0);
197227
if (capture)
198228
return capture;
199229
capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L, 0);
200230
if (capture)
201231
return capture;
202-
#endif
203-
break;
232+
#endif
233+
break; //CV_CAP_VFW
204234

205235
case CV_CAP_FIREWIRE:
206-
#ifdef HAVE_DC1394_2
236+
#ifdef HAVE_DC1394_2
207237
capture = cvCreateCameraCapture_DC1394_2 (index);
208238
if (capture)
209239
return capture;
210-
#endif
211-
#ifdef HAVE_DC1394
240+
#endif
241+
242+
#ifdef HAVE_DC1394
212243
capture = cvCreateCameraCapture_DC1394 (index);
213244
if (capture)
214245
return capture;
215-
#endif
216-
#ifdef HAVE_CMU1394
246+
#endif
247+
248+
#ifdef HAVE_CMU1394
217249
capture = cvCreateCameraCapture_CMU (index);
218250
if (capture)
219251
return capture;
220-
#endif
221-
/* Re-enable again when gstreamer 1394 support will land in the backend code
222-
#ifdef HAVE_GSTREAMER
252+
#endif
253+
254+
#ifdef HAVE_GSTREAMER && 0
255+
//Re-enable again when gstreamer 1394 support will land in the backend code
223256
capture = cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_1394, 0);
224257
if (capture)
225258
return capture;
226-
#endif
227-
*/
228-
break;
229-
#ifdef HAVE_MIL
259+
#endif
260+
break; //CV_CAP_FIREWIRE
261+
262+
#ifdef HAVE_MIL
230263
case CV_CAP_MIL:
231264
capture = cvCreateCameraCapture_MIL (index);
232265
if (capture)
233266
return capture;
234267
break;
235-
#endif
268+
#endif
236269

237-
#ifdef HAVE_QUICKTIME
270+
#ifdef HAVE_QUICKTIME
238271
case CV_CAP_QT:
239272
capture = cvCreateCameraCapture_QT (index);
240273
if (capture)
241274
return capture;
242275
break;
243-
#endif
276+
#endif
244277

245-
#ifdef HAVE_UNICAP
278+
#ifdef HAVE_UNICAP
246279
case CV_CAP_UNICAP:
247280
capture = cvCreateCameraCapture_Unicap (index);
248281
if (capture)
249282
return capture;
250283
break;
251-
#endif
284+
#endif
252285

253-
#ifdef HAVE_PVAPI
286+
#ifdef HAVE_PVAPI
254287
case CV_CAP_PVAPI:
255288
capture = cvCreateCameraCapture_PvAPI (index);
256289
if (capture)
257290
return capture;
258291
break;
259-
#endif
292+
#endif
260293

261-
#ifdef HAVE_OPENNI
294+
#ifdef HAVE_OPENNI
262295
case CV_CAP_OPENNI:
263296
capture = cvCreateCameraCapture_OpenNI (index);
264297
if (capture)
265298
return capture;
266299
break;
267-
#endif
300+
#endif
268301

269-
#ifdef HAVE_ANDROID_NATIVE_CAMERA
302+
#ifdef HAVE_ANDROID_NATIVE_CAMERA
270303
case CV_CAP_ANDROID:
271304
capture = cvCreateCameraCapture_Android (index);
272305
if (capture)
273306
return capture;
274307
break;
275-
#endif
308+
#endif
276309

277-
#ifdef HAVE_XIMEA
310+
#ifdef HAVE_XIMEA
278311
case CV_CAP_XIAPI:
279312
capture = cvCreateCameraCapture_XIMEA (index);
280313
if (capture)
281314
return capture;
282315
break;
283-
#endif
316+
#endif
284317

285-
#ifdef HAVE_AVFOUNDATION
318+
#ifdef HAVE_AVFOUNDATION
286319
case CV_CAP_AVFOUNDATION:
287320
capture = cvCreateCameraCapture_AVFoundation (index);
288321
if (capture)
289322
return capture;
290323
break;
291-
#endif
324+
#endif
292325
}
293326
}
294327

@@ -307,30 +340,30 @@ CV_IMPL CvCapture * cvCreateFileCapture (const char * filename)
307340
if (! result)
308341
result = cvCreateFileCapture_FFMPEG_proxy (filename);
309342

310-
#ifdef HAVE_XINE
343+
#ifdef HAVE_XINE
311344
if (! result)
312345
result = cvCreateFileCapture_XINE (filename);
313-
#endif
346+
#endif
314347

315-
#ifdef HAVE_GSTREAMER
348+
#ifdef HAVE_GSTREAMER
316349
if (! result)
317350
result = cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename);
318-
#endif
351+
#endif
319352

320-
#ifdef HAVE_QUICKTIME
353+
#ifdef HAVE_QUICKTIME
321354
if (! result)
322355
result = cvCreateFileCapture_QT (filename);
323-
#endif
356+
#endif
324357

325-
#ifdef HAVE_AVFOUNDATION
358+
#ifdef HAVE_AVFOUNDATION
326359
if (! result)
327360
result = cvCreateFileCapture_AVFoundation (filename);
328-
#endif
361+
#endif
329362

330-
#ifdef HAVE_OPENNI
363+
#ifdef HAVE_OPENNI
331364
if (! result)
332365
result = cvCreateFileCapture_OpenNI (filename);
333-
#endif
366+
#endif
334367

335368
if (! result)
336369
result = cvCreateFileCapture_Images (filename);
@@ -360,19 +393,21 @@ CV_IMPL CvVideoWriter* cvCreateVideoWriter( const char* filename, int fourcc,
360393
result = cvCreateVideoWriter_XINE(filename, fourcc, fps, frameSize, is_color);
361394
#endif
362395
*/
363-
#ifdef HAVE_AVFOUNDATION
396+
#ifdef HAVE_AVFOUNDATION
364397
if (! result)
365398
result = cvCreateVideoWriter_AVFoundation(filename, fourcc, fps, frameSize, is_color);
366-
#endif
399+
#endif
367400

368-
#ifdef HAVE_QUICKTIME
401+
#ifdef HAVE_QUICKTIME
369402
if(!result)
370403
result = cvCreateVideoWriter_QT(filename, fourcc, fps, frameSize, is_color);
371-
#endif
372-
#ifdef HAVE_GSTREAMER
404+
#endif
405+
406+
#ifdef HAVE_GSTREAMER
373407
if (! result)
374408
result = cvCreateVideoWriter_GStreamer(filename, fourcc, fps, frameSize, is_color);
375-
#endif
409+
#endif
410+
376411
if(!result)
377412
result = cvCreateVideoWriter_Images(filename);
378413

modules/highgui/test/test_drawing.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,10 @@ int CV_DrawingTest_C::checkLineIterator( Mat& _img )
406406
return 0;
407407
}
408408

409+
#ifdef HAVE_JPEG
409410
TEST(Highgui_Drawing_CPP, regression) { CV_DrawingTest_CPP test; test.safe_run(); }
410411
TEST(Highgui_Drawing_C, regression) { CV_DrawingTest_C test; test.safe_run(); }
412+
#endif
411413

412414
class CV_FillConvexPolyTest : public cvtest::BaseTest
413415
{

modules/highgui/test/test_framecount.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,6 @@ class CV_FramecountTest: public cvtest::BaseTest
5555

5656
void CV_FramecountTest::run(int)
5757
{
58-
#if defined WIN32 || (defined __linux__ && !defined ANDROID) || (defined __APPLE__ && defined HAVE_FFMPEG)
59-
#if !defined HAVE_GSTREAMER || defined HAVE_GSTREAMER_APP
60-
6158
const int time_sec = 5, fps = 25;
6259

6360
const string ext[] = {"avi", "mov", "mp4", "mpg", "wmv"};
@@ -126,9 +123,7 @@ void CV_FramecountTest::run(int)
126123

127124
ts->printf(cvtest::TS::LOG, "\nSuccessfull experiments: %d (%d%%)\n", n-failed, (n - failed)*100/n);
128125
ts->printf(cvtest::TS::LOG, "Failed experiments: %d (%d%%)\n", failed, failed*100/n);
129-
130-
#endif
131-
#endif
132126
}
133-
127+
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
134128
TEST(HighguiFramecount, regression) {CV_FramecountTest test; test.safe_run();}
129+
#endif

modules/highgui/test/test_grfmt.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,13 @@ class CV_GrfmtReadBMPRLE8Test : public cvtest::BaseTest
201201
}
202202
};
203203

204+
#ifdef HAVE_PNG
204205
TEST(Highgui_Grfmt_WriteBigImage, regression) { CV_GrfmtWriteBigImageTest test; test.safe_run(); }
206+
#endif
207+
208+
#if defined(HAVE_PNG) && defined(HAVE_TIFF) && defined(HAVE_JPEG)
205209
TEST(Highgui_Grfmt_WriteSequenceImage, regression) { CV_GrfmtWriteSequenceImageTest test; test.safe_run(); }
210+
#endif
211+
206212
TEST(GrfmtReadBMPRLE8, regression) { CV_GrfmtReadBMPRLE8Test test; test.safe_run(); }
207213

modules/highgui/test/test_positioning.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -209,25 +209,15 @@ void CV_VideoPositioningTest::run_test(int method)
209209

210210
void CV_VideoProgressivePositioningTest::run(int)
211211
{
212-
#if defined WIN32 || (defined __linux__ && !defined ANDROID) || (defined __APPLE__ && defined HAVE_FFMPEG)
213-
#if !defined HAVE_GSTREAMER || defined HAVE_GSTREAMER_APP
214-
215212
run_test(PROGRESSIVE);
216-
217-
#endif
218-
#endif
219213
}
220214

221215
void CV_VideoRandomPositioningTest::run(int)
222216
{
223-
#if defined WIN32 || (defined __linux__ && !defined ANDROID) || (defined __APPLE__ && defined HAVE_FFMPEG)
224-
#if !defined HAVE_GSTREAMER || defined HAVE_GSTREAMER_APP
225-
226217
run_test(RANDOM);
227-
228-
#endif
229-
#endif
230218
}
231219

220+
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
232221
TEST (HighguiPositioning, progressive) { CV_VideoProgressivePositioningTest test; test.safe_run(); }
233222
TEST (HighguiPositioning, random) { CV_VideoRandomPositioningTest test; test.safe_run(); }
223+
#endif

0 commit comments

Comments
 (0)