Taking Your First Picture with CSI or USB Camera
Introduction
This guide will show you how to quickly get up and running with CSI and USB cameras. By following this guide, you’ll be able to:
- Start capture and preview display on the screen
- Take a picture and save to disk
- Capture a video and save to disk
-
How to use a camera with a container
Supported Cameras
Jetson developer kits have multiple interfaces for connecting a camera, including USB, Ethernet, and MIPI CSI-2. Popular cameras are supported out of the box, and Jetson ecosystem partners support a broad portfolio of additional cameras .
Popular cameras supported out of the box include IMX219 camera modules such as Raspberry Pi Camera Module V2, the Intel Realsense and StereoLabs Zed 3D cameras, and standard USB webcams.
nvgstcapture
The examples below use nvgstcapture gstreamer application to access the camera features via the NVIDIA API. More info and commands of nvgstcapture can be found in the L4T Guide under the Multimedia section .
Start Capture and Preview display on the screen
CSI camera
For information about how to connect the ribbon cable for MIPI CSI-2 cameras, see Jetson Nano 2GB Developer Kit User Guide .
In order to check that the CSI camera is working, you can run the following command, which will start capture and preview display it on the screen.
nvgstcapture-1.0
This example command will rotate the image 180 degrees (vertical flip)
nvgstcapture-1.0 --orientation 2
USB Camera
You’ll need to tell nvgstcapture where to find your USB camera device (in place of the default CSI camera).
# V4L2 USB camera (where <N> is the /dev/videoN node) nvgstcapture-1.0 --camsrc=0 --cap-dev-node=<N>
Take a picture and save to disk
CSI camera
Runtime command line option
-
nvgstcapture-1.0
- Press 'j' to Capture one image.
- Press 'q' to exit
Automated command line option
nvgstcapture-1.0 --automate --capture-auto
NOTE: Use “nvgstcapture-1.0 --help” to refer supported command line options
USB Camera
Runtime command line option
-
nvgstcapture-1.0 --camsrc=0 --cap-dev-node=<N> (where N is the /dev/videoN Node)
- Press 'j' to Capture one image.
- Press 'q' to exit
Automated command line option
nvgstcapture-1.0 --camsrc=0 --cap-dev-node=<N> --automate --capture-auto (where N is the /dev/videoN Node
NOTE: Use “nvgstcapture-1.0 --help” to refer supported command line options
Capture a video and save to disk
CSI camera
Runtime command line option
-
nvgstcapture-1.0
- Press '1' to Start recording video
- Press '0' to Stop recording video
-
Press 'q' to exit
Automated command line option
nvgstcapture-1.0 --mode=2 --automate --capture-aut
NOTE: Use “nvgstcapture-1.0 --help” to refer supported command line options
USB Camera
Runtime command line option
-
nvgstcapture-1.0 --mode=2 --camsrc=0 --cap-dev-node=<N> (where N is the /dev/videoN Node)
- Press '1' to Start recording video
- Press '0' to Stop recording video
-
Press 'q' to exit
Automated command line option
nvgstcapture-1.0 --mode=2 --camsrc=0 --cap-dev-node=<N> --automate --capture-auto (where N is the /dev/videoN Nod
NOTE: Use “nvgstcapture-1.0 --help” to refer supported command line options
Use the camera within a container
CSI camera
The commands are the same, just add this option to the command line when you launch the container with "docker run"
--volume /tmp/argus_socket:/tmp/argus_socket
USB Camera
When you launch your container with "docker run ", mount the corresponding /dev/video* device by adding the following option to the command line:
--device /dev/video0
the above assumes your V4L2 USB camera is /dev/video0
Useful resources
-
The jetson-inference project on GitHub includes camera APIs for Python and C++ that can stream CSI and USB cameras, RTP/RTSP, and video files. For more info, see Camera Streaming and Multimedia .
- See the Jetson Partner Supported Cameras page for a directory of cameras that are compatible with Jetson.