-
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.
First still image test:
raspistill -o raspistill.jpg
file raspistill.jpg
But this is BCM specific, better enable V4L2 device:
modprobe bcm2835-v4l2
Now, the device /dev/video0
can be used.
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
test frame rate and video streaming (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
Finally, the driver could also be removed:
modprobe -r bcm2835-v4l2
gstreamer could be used with raspivid
as video source (cf. https://www.raspberrypi.org/forums/viewtopic.php?t=49278&p=664616), but this would be a RasPi specific solution.
So we prefer using gstreamer with a V4l2 video source.
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!