You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/05/24 08:16:17 UTC

[GitHub] lebeg commented on a change in pull request #11033: Add frame-resize option to ssd demo to scale camera input

lebeg commented on a change in pull request #11033: Add frame-resize option to ssd demo to scale camera input
URL: https://github.com/apache/incubator-mxnet/pull/11033#discussion_r190499813
 
 

 ##########
 File path: example/ssd/dataset/cv2Iterator.py
 ##########
 @@ -26,10 +26,18 @@ class CameraIterator():
     """
     def __init__(self, capture=cv2.VideoCapture(0), frame_resize=None):
         self._capture = capture
-        self._frame_resize = frame_resize
         if frame_resize:
-            assert isinstance(frame_resize, tuple) and (len(tuple) == 2), "frame_resize should be a tuple of (x,y)"
-            self._frame_shape = (1, 3, frame_resize[0], frame_resize[1])
+            if isinstance(frame_resize, (tuple, list)) and (len(frame_resize) == 2):
+                self._frame_resize = tuple(map(int, frame_resize))
+                self._frame_shape = (1, 3, self._frame_resize[0], self._frame_resize[1])
+            elif isinstance(frame_resize, float):
+                width = int(self._capture.get(cv2.CAP_PROP_FRAME_WIDTH)*frame_resize)
+                height = int(self._capture.get(cv2.CAP_PROP_FRAME_HEIGHT)*frame_resize)
+                self._frame_shape = (1, 3, width, height)
+                self._frame_resize = (width, height)
+            else:
+                assert False, "frame_resize should be a tuple of (x,y) pixels "
+                "or an float setting the scaling factor"
 
 Review comment:
   a float, not an float

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services