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

Commitceab824

Browse files
committed
Add skipping when can't use VideoCapture(GSTREAMER);
Add better handling of GStreamer backend unavailable;Changed video to avoid terminations
1 parent0308bb4 commitceab824

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

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

Lines changed: 31 additions & 10 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,24 @@ 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("Backend GSTREAMER can't open the video; "+
402+
"cause: "+str(e))
403+
ifnotcap.isOpened():
404+
raiseunittest.SkipTest("Backend GSTREAMER can't open the video")
405+
returncap
406+
394407
deftest_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+
ifnotcv.videoio_registry.hasBackend(cv.CAP_GSTREAMER):
409+
raiseunittest.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
400417
g_in=cv.GMat()
@@ -409,8 +426,7 @@ def test_gst_source_accuracy(self):
409426
ccomp.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
416432
max_num_frames=10
@@ -439,6 +455,9 @@ def get_gst_pipeline(self, gstpipeline):
439455
raiseunittest.SkipTest(str(e)+", casued by "+str(e.__cause__))
440456

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

471490
deftest_gst_multisource_accuracy(self):
472-
path=self.find_file('cv/video/768x576.avi', [os.environ['OPENCV_TEST_DATA_PATH']])
491+
ifnotcv.videoio_registry.hasBackend(cv.CAP_GSTREAMER):
492+
raiseunittest.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']])
473496
gstpipeline1="""filesrc location="""+path+""" ! decodebin ! videoconvert !
474497
videoscale ! video/x-raw,format=NV12 ! appsink"""
475498
gstpipeline2="""filesrc location="""+path+""" ! decodebin !
@@ -495,10 +518,8 @@ def test_gst_multisource_accuracy(self):
495518
ccomp.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
504525
max_num_frames=10

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp