Skip to content

Commit

Permalink
Fix bug #47, validate source and sink resolution
Browse files Browse the repository at this point in the history
When using opencv as video source, validate that video source and video
sink resolutions match. Otherwise throw a runtime error.
  • Loading branch information
Mario Ruiz committed Nov 19, 2021
1 parent 0c07839 commit e85b057
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pynq_composable/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,14 @@ def _configure(self):
cv2.VideoWriter_fourcc('M', 'J', 'P', 'G'))
self._videoIn.set(cv2.CAP_PROP_FPS, self.mode.fps)

f_reso = (int(self._videoIn.get(cv2.CAP_PROP_FRAME_WIDTH)),
int(self._videoIn.get(cv2.CAP_PROP_FRAME_HEIGHT)))
v_reso = (self.mode.width, self.mode.height)

if f_reso != v_reso:
raise RuntimeError("Source {} and sink {} resolution do not match"
.format(f_reso, v_reso))

def start(self):
"""Start video stream by configuring it"""
if not self._started:
Expand Down

0 comments on commit e85b057

Please sign in to comment.