The operation of usb camera under linux is inseparable from the v4l2 framework.
V4L2 is the abbreviation of Video for linux2, which is the kernel driver of video equipment in linux. In Linux, the video device is a device file, which can be read and written like a normal file. The camera is under /dev/video0.
- Check the linux camera device, if there is a valid camera device, you can check it in the dev directory
eric@eric-PC:/$ ls dev/video* -l
crw-rw----+ 1 root video 81, 0 11月 8 13:37 dev/video0
crw-rw----+ 1 root video 81, 1 11月 8 13:37 dev/video1
- You can also check the startup information, whether there is a valid usb camera device
eric@eric-PC:/$ dmesg | grep video
[ 1849.908486] videodev: Linux video capture interface: v2.00
[ 1850.022954] uvcvideo: Found UVC 1.00 device hm1091_techfront (0408:1020)
[ 1850.061899] uvcvideo 1-1:1.0: Entity type for entity Extension 4 was not initialized!
[ 1850.061903] uvcvideo 1-1:1.0: Entity type for entity Extension 3 was not initialized!
[ 1850.061905] uvcvideo 1-1:1.0: Entity type for entity Processing 2 was not initialized!
[ 1850.061907] uvcvideo 1-1:1.0: Entity type for entity Camera 1 was not initialized!
[ 1850.062579] usbcore: registered new interface driver uvcvideo
The v4l2-ctl command to view the video device parameter information, if the v4l2-ctl command is not found as prompted, you need to install v4l-utils
eric@eric-PC:/dev$ v4l2-ctl -d /dev/video0 --all
bash: v4l2-ctl:未找到命令
eric@eric-PC:/dev$ sudo apt-get install v4l-utils
eric@eric-PC:/$ v4l2-ctl -d /dev/video0 --all
Driver Info:
Driver name : uvcvideo
Card type : hm1091_techfront: hm1091_techfr
Bus info : usb-0000:02:04.0-1
Driver version : 5.4.50
Capabilities : 0x84a00001
Video Capture
Metadata Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
Width/Height : 1280/720
Pixel Format : 'MJPG' (Motion-JPEG)
Field : None
Bytes per Line : 0
Size Image : 1843200
Colorspace : sRGB
Transfer Function : Default (maps to sRGB)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization : Default (maps to Full Range)
Flags :
Crop Capability Video Capture:
Bounds : Left 0, Top 0, Width 1280, Height 720
Default : Left 0, Top 0, Width 1280, Height 720
Pixel Aspect: 1/1
Selection: crop_default, Left 0, Top 0, Width 1280, Height 720, Flags:
Selection: crop_bounds, Left 0, Top 0, Width 1280, Height 720, Flags:
Streaming Parameters Video Capture:
Capabilities : timeperframe
Frames per second: 30.000 (30/1)
Read buffers : 0
brightness 0x00980900 (int) : min=-64 max=64 step=1 default=0 value=0
contrast 0x00980901 (int) : min=0 max=95 step=1 default=0 value=0
saturation 0x00980902 (int) : min=0 max=100 step=1 default=64 value=64
hue 0x00980903 (int) : min=-2000 max=2000 step=1 default=0 value=0
white_balance_temperature_auto 0x0098090c (bool) : default=1 value=1
gamma 0x00980910 (int) : min=100 max=300 step=1 default=100 value=100
power_line_frequency 0x00980918 (menu) : min=0 max=2 default=1 value=1
white_balance_temperature 0x0098091a (int) : min=2800 max=6500 step=1 default=4600 value=4600 flags=inactive
sharpness 0x0098091b (int) : min=0 max=7 step=1 default=2 value=2
backlight_compensation 0x0098091c (int) : min=0 max=1 step=1 default=1 value=1
exposure_auto 0x009a0901 (menu) : min=0 max=3 default=3 value=3
exposure_absolute 0x009a0902 (int) : min=10 max=2047 step=1 default=384 value=384 flags=inactive
exposure_auto_priority 0x009a0903 (bool) : default=0 value=1
With the above information, it can be seen that the device supports a resolution of 1280×720 and supports the MJPEG format.