Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7af4fe1

Browse files
committed
Add skipping when can't use VideoCapture(GSTREAMER); add better handling of GStreamer backend unavailable
1 parent0308bb4 commit7af4fe1

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

‎modules/gapi/misc/python/test/test_gapi_streaming.py‎

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,9 @@ def get_gst_source(self, gstpipeline):
370370
raiseunittest.SkipTest(str(e))
371371

372372
deftest_gst_source(self):
373+
ifnotcv.videoio_registry.hasBackend(cv.CAP_GSTREAMER):
374+
raiseunittest.SkipTest("Backend is not available/disabled: GSTREAMER")
375+
373376
gstpipeline="""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):
391394
has_frame,output=ccomp.pull()
392395

393396

397+
defopen_VideoCapture_gstreamer(self,gstpipeline):
398+
try:
399+
cap=cv.VideoCapture(gstpipeline,cv.CAP_GSTREAMER)
400+
exceptExceptionase:
401+
raiseunittest.SkipTest("SKIP test: backend GSTREAMER can't open the video; "+
402+
"cause: "+str(e))
403+
ifnotcap.isOpened():
404+
raiseunittest.SkipTest("SKIP test: backend GSTREAMER can't open the video")
405+
returncap
406+
394407
deftest_gst_source_accuracy(self):
408+
ifnotcv.videoio_registry.hasBackend(cv.CAP_GSTREAMER):
409+
raiseunittest.SkipTest("Backend is not available/disabled: GSTREAMER")
410+
395411
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"""
412+
gstpipeline="""filesrc location="""+path+""" ! decodebin ! videoconvert !
413+
videoscale !video/x-raw,format=NV12 ! appsink"""
398414

399415
# G-API pipeline
400416
g_in=cv.GMat()
@@ -409,8 +425,7 @@ def test_gst_source_accuracy(self):
409425
ccomp.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
416431
max_num_frames=10
@@ -439,6 +454,9 @@ def get_gst_pipeline(self, gstpipeline):
439454
raiseunittest.SkipTest(str(e)+", casued by "+str(e.__cause__))
440455

441456
deftest_gst_multiple_sources(self):
457+
ifnotcv.videoio_registry.hasBackend(cv.CAP_GSTREAMER):
458+
raiseunittest.SkipTest("Backend is not available/disabled: GSTREAMER")
459+
442460
gstpipeline="""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

471489
deftest_gst_multisource_accuracy(self):
490+
ifnotcv.videoio_registry.hasBackend(cv.CAP_GSTREAMER):
491+
raiseunittest.SkipTest("Backend is not available/disabled: GSTREAMER")
492+
472493
path=self.find_file('cv/video/768x576.avi', [os.environ['OPENCV_TEST_DATA_PATH']])
473494
gstpipeline1="""filesrc location="""+path+""" ! decodebin ! videoconvert !
474495
videoscale ! video/x-raw,format=NV12 ! appsink"""
@@ -495,10 +516,8 @@ def test_gst_multisource_accuracy(self):
495516
ccomp.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
504523
max_num_frames=10

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp