Hi,
I’m building my own RC car with Jetson Nano and the Raspberry Pi cam. I’m doing some experiments with the Jetbot examples to understand what I’ve to do (many thanks for the examples :-)).
But I’ve the problem, that I’ve to install the Raspberry Pi camera in “the wrong direction” because of the flat cable that I can’t fold, so that the videos and pictures are upside down.
I’m using the code snippet below to display the camera output in the Jupyter Notebook:
import traitlets
import ipywidgets.widgets as widgets
from IPython.display import display
from jetbot import Camera, bgr8_to_jpeg
camera = Camera.instance(width=224, height=224)
image = widgets.Image(format='jpeg', width=224, height=224) # this width and height doesn't necessarily have to match the camera
camera_link = traitlets.dlink((camera, 'value'), (image, 'value'), transform=bgr8_to_jpeg)
display(image)
I searched online and in this community, but I can’t find the solution to flip the camera output for that Python code.
I would be very pleased, if someone could help me.
Thanks,
Lars
Hi Orandus, what you can do is modify the camera code in JetBot to supply a flip-method parameter to the nvvidconv gstreamer element that it uses here:
https://github.com/NVIDIA-AI-IOT/jetbot/blob/dfba440bd939070d57a6c7ed7bfb5346857b7101/jetbot/camera.py#L50
What you want to do is change nvvidconv to nvvidconv flip-method=2
where flip-method=2 can be changed to different values depending on the transformation you desire. These are the values to flip-method parameter that you can try setting:
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
2 Likes
Hi dusty,
thanks for your help again!
I changed it in the sources, made a
sudo python3 setup.py install
restarted the Jupyter kernel and the video output was flipped.
Thanks,
Lars
Hi both,
I would also like to do this but have a silly question.how do I actually open camera.py to modify Camera? I looked in the Jupyter notebook and plugged it back into a monitor but can’t find it anywhere.
1 Like
Hi All,
I know it’s an old post, but as I can’t find a way to found how to execute what I modified, I ask :-):
I have the same issue that descript in the post : " image is flipped "
I found the source and modified it with the flip-method
and then can find a way to " sudo python3 setup.py install".
Thanks for you help
Olivier