Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video flip #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions jetcam/csi_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand Down