How to flip the CSI Camera image in "Getting Started with AI on Jetson Nano"DLI course

How to flip the CSI Camera image in "Getting Started with AI on Jetson Nano"DLI course?
Thanks!

For the gstreamer pipeline you can use nvvidconv.

  flip-method         : video flip methods
                        flags: readable, writable, controllable
                        Enum "GstNvVideoFlipMethod" Default: 0, "none"
                           (0): none             - Identity (no rotation)
                           (1): counterclockwise - Rotate counter-clockwise 90 degrees
                           (2): rotate-180       - Rotate 180 degrees
                           (3): clockwise        - Rotate clockwise 90 degrees
                           (4): horizontal-flip  - Flip horizontally
                           (5): upper-right-diagonal - Flip across upper right/lower left diagonal
                           (6): vertical-flip    - Flip vertically
                           (7): upper-left-diagonal - Flip across upper left/lower right diagonal

It is in container.
sudo docker run --runtime nvidia -it --rm --network host
–volume ~/nvdli-data:/nvdli-nano/data
–volume /tmp/argus_socket:/tmp/argus_socket
–device /dev/video0 \
nvcr.io/nvidia/dli/dli-nano-ai:v2.0.1-r32.4.4

If you run the argus API base APP you need to implement it by below API. Otherwise run the gst-launch pipeline command in the docker with the nvvideconv element.

The 'Getting Started with AI on Jetson Nano" DLI course uses the JetCam wrapper for CSI/V4L2 camera. You would need to modify the GStreamer pipeline it uses in csi_camera.py found here:

https://github.com/NVIDIA-AI-IOT/jetcam/blob/508ff3a402c5a0449a8d5776c05d2d17d6a87f46/jetcam/csi_camera.py#L32

Add the flip-method to the nvvidconv element in that pipeline - like this:

 return 'nvarguscamerasrc sensor-id=%d ! video/x-raw(memory:NVMM), width=%d, height=%d, format=(string)NV12, framerate=(fraction)%d/1 ! nvvidconv flip-method=2 ! 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)

The 'Getting Started with AI on Jetson Nano" DLI course is in docker img.
How to find modify the csi_camera.py ?

When you are inside the container, follow these steps:

git clone https://github.com/NVIDIA-AI-IOT/jetcam
cd jetcam
apt-get update
apt-get install nano
nano jetcam/csi_camera.py
# make your edits and save the file
python3 setup.py install

Your changes to jetcam should then take effect the next time you run the Jupyter notebook.

If desired, you can then use docker commit to save your changes to a new container tag (just remember to launch your new tag instead of the original one in the future)

1 Like

It’s working. Thank you!