@@ -370,6 +370,9 @@ def get_gst_source(self, gstpipeline):
370370raise unittest .SkipTest (str (e ))
371371
372372def test_gst_source (self ):
373+ if not cv .videoio_registry .hasBackend (cv .CAP_GSTREAMER ):
374+ raise unittest .SkipTest ("Backend is not available/disabled: GSTREAMER" )
375+
373376gstpipeline = """videotestsrc is-live=true pattern=colors num-buffers=10 !
374377 videorate ! videoscale ! video/x-raw,width=1920,height=1080,
375378 framerate=30/1 ! appsink"""
@@ -391,10 +394,24 @@ def test_gst_source(self):
391394has_frame ,output = ccomp .pull ()
392395
393396
397+ def open_VideoCapture_gstreamer (self ,gstpipeline ):
398+ try :
399+ cap = cv .VideoCapture (gstpipeline ,cv .CAP_GSTREAMER )
400+ except Exception as e :
401+ raise unittest .SkipTest ("Backend GSTREAMER can't open the video; " +
402+ "cause: " + str (e ))
403+ if not cap .isOpened ():
404+ raise unittest .SkipTest ("Backend GSTREAMER can't open the video" )
405+ return cap
406+
394407def test_gst_source_accuracy (self ):
395- path = self .find_file ('cv/video/768x576.avi' , [os .environ ['OPENCV_TEST_DATA_PATH' ]])
396- gstpipeline = """filesrc location=""" + path + """ ! decodebin ! videoconvert ! videoscale !
397- video/x-raw,format=NV12 ! appsink"""
408+ if not cv .videoio_registry .hasBackend (cv .CAP_GSTREAMER ):
409+ raise unittest .SkipTest ("Backend is not available/disabled: GSTREAMER" )
410+
411+ path = self .find_file ('highgui/video/big_buck_bunny.avi' ,
412+ [os .environ ['OPENCV_TEST_DATA_PATH' ]])
413+ gstpipeline = """filesrc location=""" + path + """ ! decodebin ! videoconvert !
414+ videoscale ! video/x-raw,format=NV12 ! appsink"""
398415
399416# G-API pipeline
400417g_in = cv .GMat ()
@@ -409,8 +426,7 @@ def test_gst_source_accuracy(self):
409426ccomp .start ()
410427
411428# OpenCV Gst-source
412- cap = cv .VideoCapture (gstpipeline ,cv .CAP_GSTREAMER )
413- self .assertTrue (cap .isOpened ())
429+ cap = self .open_VideoCapture_gstreamer (gstpipeline )
414430
415431# Assert
416432max_num_frames = 10
@@ -439,6 +455,9 @@ def get_gst_pipeline(self, gstpipeline):
439455raise unittest .SkipTest (str (e )+ ", casued by " + str (e .__cause__ ))
440456
441457def test_gst_multiple_sources (self ):
458+ if not cv .videoio_registry .hasBackend (cv .CAP_GSTREAMER ):
459+ raise unittest .SkipTest ("Backend is not available/disabled: GSTREAMER" )
460+
442461gstpipeline = """videotestsrc is-live=true pattern=colors num-buffers=10 !
443462 videorate ! videoscale !
444463 video/x-raw,width=1920,height=1080,framerate=30/1 !
@@ -469,7 +488,11 @@ def test_gst_multiple_sources(self):
469488
470489
471490def test_gst_multisource_accuracy (self ):
472- path = self .find_file ('cv/video/768x576.avi' , [os .environ ['OPENCV_TEST_DATA_PATH' ]])
491+ if not cv .videoio_registry .hasBackend (cv .CAP_GSTREAMER ):
492+ raise unittest .SkipTest ("Backend is not available/disabled: GSTREAMER" )
493+
494+ path = self .find_file ('highgui/video/big_buck_bunny.avi' ,
495+ [os .environ ['OPENCV_TEST_DATA_PATH' ]])
473496gstpipeline1 = """filesrc location=""" + path + """ ! decodebin ! videoconvert !
474497 videoscale ! video/x-raw,format=NV12 ! appsink"""
475498gstpipeline2 = """filesrc location=""" + path + """ ! decodebin !
@@ -495,10 +518,8 @@ def test_gst_multisource_accuracy(self):
495518ccomp .start ()
496519
497520# OpenCV Gst-source
498- cap1 = cv .VideoCapture (gstpipeline1 ,cv .CAP_GSTREAMER )
499- self .assertTrue (cap1 .isOpened ())
500- cap2 = cv .VideoCapture (gstpipeline2 ,cv .CAP_GSTREAMER )
501- self .assertTrue (cap2 .isOpened ())
521+ cap1 = self .open_VideoCapture_gstreamer (gstpipeline1 )
522+ cap2 = self .open_VideoCapture_gstreamer (gstpipeline2 )
502523
503524# Assert
504525max_num_frames = 10