Skip to content

Commit a1321cf

Browse files
committed
fix video get/set
1 parent 75783d2 commit a1321cf

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/pcv/vidIO.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,18 +323,18 @@ def get(self, property):
323323
try:
324324
return super().get(self.properties.get(property, property))
325325
except TypeError: # property must be an unknown string
326-
return super().get(eval('cv2.CAP_PROP_'+property.upper()))
326+
return super().get(getattr(cv2, 'CAP_PROP' + property.upper()))
327327

328328
def set(self, property, value):
329329
try:
330330
return super().set(self.properties.get(property, property), value)
331331
except TypeError: # 'property' must be an unknown string
332-
return super().set(eval('cv2.CAP_PROP_'+property.upper))
332+
return super().set(getattr(cv2, 'CAP_PROP_' + property.upper()), value)
333333

334334

335335
class ContextualVideoCapture(VideoSource):
336336
''' A video-capturing class with a context manager for releasing. '''
337-
337+
338338
def __init__(self, id, *args, display='frame', delay=None, quit=ord('q'),
339339
play_pause=ord(' '), pause_effects={}, play_commands={},
340340
destroy=-1, source=OpenCVSource, **kwargs):
@@ -839,6 +839,12 @@ def get(this, *args, **kwargs):
839839

840840
self._get_latest_image() # re-initialise as ready
841841

842+
def get(self, property):
843+
return super().get(self.properties.get(property, property))
844+
845+
def set(self, property, value):
846+
return super().set(self.properties.get(property, property), value)
847+
842848
def _set_start(self, start):
843849
''' Set the start of the video to user specification, if possible. '''
844850
self._frame = 0

0 commit comments

Comments
 (0)