@@ -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,23 @@ 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 ("SKIP test: backend GSTREAMER can't open the video; " +
402+ "cause: " + str (e ))
403+ if not cap .isOpened ():
404+ raise unittest .SkipTest ("SKIP test: backend GSTREAMER can't open the video" )
405+ return cap
406+
394407def test_gst_source_accuracy (self ):
408+ if not cv .videoio_registry .hasBackend (cv .CAP_GSTREAMER ):
409+ raise unittest .SkipTest ("Backend is not available/disabled: GSTREAMER" )
410+
395411path = 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"""
412+ gstpipeline = """filesrc location=""" + path + """ ! decodebin ! videoconvert !
413+ videoscale ! video/x-raw,format=NV12 ! appsink"""
398414
399415# G-API pipeline
400416g_in = cv .GMat ()
@@ -409,8 +425,7 @@ def test_gst_source_accuracy(self):
409425ccomp .start ()
410426
411427# OpenCV Gst-source
412- cap = cv .VideoCapture (gstpipeline ,cv .CAP_GSTREAMER )
413- self .assertTrue (cap .isOpened ())
428+ cap = self .open_VideoCapture_gstreamer (gstpipeline )
414429
415430# Assert
416431max_num_frames = 10
@@ -439,6 +454,9 @@ def get_gst_pipeline(self, gstpipeline):
439454raise unittest .SkipTest (str (e )+ ", casued by " + str (e .__cause__ ))
440455
441456def test_gst_multiple_sources (self ):
457+ if not cv .videoio_registry .hasBackend (cv .CAP_GSTREAMER ):
458+ raise unittest .SkipTest ("Backend is not available/disabled: GSTREAMER" )
459+
442460gstpipeline = """videotestsrc is-live=true pattern=colors num-buffers=10 !
443461 videorate ! videoscale !
444462 video/x-raw,width=1920,height=1080,framerate=30/1 !
@@ -469,6 +487,9 @@ def test_gst_multiple_sources(self):
469487
470488
471489def test_gst_multisource_accuracy (self ):
490+ if not cv .videoio_registry .hasBackend (cv .CAP_GSTREAMER ):
491+ raise unittest .SkipTest ("Backend is not available/disabled: GSTREAMER" )
492+
472493path = self .find_file ('cv/video/768x576.avi' , [os .environ ['OPENCV_TEST_DATA_PATH' ]])
473494gstpipeline1 = """filesrc location=""" + path + """ ! decodebin ! videoconvert !
474495 videoscale ! video/x-raw,format=NV12 ! appsink"""
@@ -495,10 +516,8 @@ def test_gst_multisource_accuracy(self):
495516ccomp .start ()
496517
497518# 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 ())
519+ cap1 = self .open_VideoCapture_gstreamer (gstpipeline1 )
520+ cap2 = self .open_VideoCapture_gstreamer (gstpipeline2 )
502521
503522# Assert
504523max_num_frames = 10