-
Notifications
You must be signed in to change notification settings - Fork 9
CSI camera
Tested with RasPi Cam V2 which connects to the MIPI CSI-2 interface on connector J3.
Power off and connect camera module connect to CSI connector.
When (re-)booting, config.txt must contain a line
start_x=1
otherwise, the camera cannot be used and you get a ENOMEM error.
These tools are RasPi specific and closer to the hardware. See source code: https://github.com/raspberrypi/userland/tree/master/host_applications/linux/apps/raspicam
raspistill -o raspistill.jpg
file raspistill.jpg
raspivid -o raspivid.h264
file raspivid.h264
Many options are possible, like sending the stream to stdout and pipe it to gstreamer or nc
("netcat") for streaming.
First, the v4l2 device driver must be loaded:
modprobe bcm2835-v4l2
Now, the device /dev/video0
can be used.
(v4l2-ctl
is build with recipe v4l-utils)
v4l2-ctl --device=0 --all
v4l2-ctl --list-formats-ext
v4l2-ctl --overlay=1
v4l2-ctl --overlay=0
v4l2-ctl --set-fmt-video=width=2592,height=1944,pixelformat=MJPEG
v4l2-ctl --stream-mmap=3 --stream-count=1 --stream-to=testfile.jpg
H.264 640x480 @ 90 fps, see https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=142536
v4l2-ctl -p 90
v4l2-ctl --set-ctrl video_bitrate=10000000
v4l2-ctl --set-fmt-video=width=640,height=480,pixelformat=H264
v4l2-ctl --stream-mmap=3 --stream-count=1000 --stream-to=/dev/null
Check driver info:
modinfo bcm2835_v4l2
Finally, the driver could also be removed:
modprobe -r bcm2835-v4l2
gstreamer can use /dev/video0
, the above driver shall be loaded.
this is a command line version of VideoLAN vlc video player, the swiss army knive among video players. Can also be used for RTSP streaming. cvlc is a command line tool, but it comes together with vlc which requires a lot of graphics stuff. (There maybe a "no X" version vlc-nox, but no bitbake recipe.)
see https://www.uco.es/investiga/grupos/ava/node/40 (not tested)
Closed source - neither recommended, nor tested. Claims to support WebRTC https://www.linux-projects.org/uv4l/
USB has a device class for webcams: UVC UVC support is included in the RasPi image and works plug-and-play.
Tested with Microsoft LifeCam Studio webcam, when V4L2 driver for CSI camera was also loaded
Connect webcam to USB, check kernel log:
root@raspberrypi3:~# dmesg | tail [ 4016.669518] usb 1-1.4: New USB device found, idVendor=045e, idProduct=0772 [ 4016.673681] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 4016.677794] usb 1-1.4: Product: Microsoft\xffffffc2\xffffffae LifeCam Studio(TM) [ 4016.681753] usb 1-1.4: Manufacturer: Microsoft [ 4016.694515] hid-generic 0003:045E:0772.0001: hiddev0,hidraw0: USB HID v1.01 Device [Microsoft Microsoft\xffffffc2\xffffffae LifeCam Studio(TM)] on usb-3f980000.usb-1.4/input4 [ 4016.724801] uvcvideo: Found UVC 1.00 device Microsoft\xffffffc2\xffffffae LifeCam Studio(TM) (045e:0772) [ 4016.788227] input: Microsoft\xffffffc2\xffffffae LifeCam Studio(TM) as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/input/input0 [ 4016.796404] usbcore: registered new interface driver uvcvideo [ 4016.800554] USB Video Class driver (1.1.1) [ 4017.154916] usbcore: registered new interface driver snd-usb-audio
A new video device was created: /dev/video1
. This video device works similar to the CSI cam /dev/video0
,
but there will be differences because different cameras might handle different image sizes, pixel formats, etc..
There may even be differences between different UVC cams, good luck!