diff --git a/README.md b/README.md index 8905686..52cb2bf 100644 --- a/README.md +++ b/README.md @@ -27,12 +27,24 @@ Below we show some usage examples. You can find more in the [notebooks](noteboo ### Create CSI camera -Call ``CSICamera`` to use a compatible CSI camera. ``capture_width``, ``capture_height``, and ``capture_fps`` will control the capture shape and rate that images are aquired. ``width`` and ``height`` control the final output shape of the image as returned by the ``read`` function. +Call ``CSICamera`` to use a compatible CSI camera. ``capture_width``, ``capture_height``, and ``capture_fps`` will control the capture shape and rate that images are aquired. ``width`` and ``height`` control the final output shape of the image as returned by the ``read`` function. +``capture_flip`` allows the image to be flipped or rotated using the following codes. + +| Type | Specific | Code | +|:-------|:-----:|:---:| +| Identity | no rotation (default)| 0| +| Rotate | Counterclockwise 90 degrees| 1| +|Rotate | 180 degrees| 2| +|Rotate| Clockwise 90 degrees| 3| +|Flip| Horizontal flip| 4| +|Flip| Upper right diagonal flip| 5| +|Flip|Vertical flip| 6| +|Flip|Upper-left diagonal| 7| ```python from jetcam.csi_camera import CSICamera -camera = CSICamera(width=224, height=224, capture_width=1080, capture_height=720, capture_fps=30) +camera = CSICamera(width=224, height=224, capture_width=1080, capture_height=720, capture_fps=30, capture_flip=6) ``` ### Create USB camera diff --git a/jetcam/csi_camera.py b/jetcam/csi_camera.py index 6496c69..5049d99 100644 --- a/jetcam/csi_camera.py +++ b/jetcam/csi_camera.py @@ -12,6 +12,8 @@ class CSICamera(Camera): capture_fps = traitlets.Integer(default_value=30) capture_width = traitlets.Integer(default_value=640) capture_height = traitlets.Integer(default_value=480) + capture_flip = traitlets.Integer(default_value=0) + def __init__(self, *args, **kwargs): super(CSICamera, self).__init__(*args, **kwargs) @@ -29,8 +31,8 @@ def __init__(self, *args, **kwargs): atexit.register(self.cap.release) def _gst_str(self): - return 'nvarguscamerasrc sensor-id=%d ! video/x-raw(memory:NVMM), width=%d, height=%d, format=(string)NV12, framerate=(fraction)%d/1 ! nvvidconv ! video/x-raw, width=(int)%d, height=(int)%d, format=(string)BGRx ! videoconvert ! appsink' % ( - self.capture_device, self.capture_width, self.capture_height, self.capture_fps, self.width, self.height) + return 'nvarguscamerasrc sensor-id=%d ! video/x-raw(memory:NVMM), width=%d, height=%d, format=(string)NV12, framerate=(fraction)%d/1 ! nvvidconv flip-method=%d ! video/x-raw, width=(int)%d, height=(int)%d, format=(string)BGRx ! videoconvert ! appsink' % ( + self.capture_device, self.capture_width, self.capture_height, self.capture_fps, self.capture_flip, self.width, self.height) def _read(self): re, image = self.cap.read() diff --git a/setup.py b/setup.py index ece3e5a..3879b46 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='jetcam', - version='0.0.0', + version='0.0.1', description='An easy to use camera interface for NVIDIA Jetson', packages=find_packages(), install_requires=[