El funcionamiento de la cámara USB en linux es inseparable del marco v4l2.
V4L2 es la abreviatura de Video para linux2, que es el controlador del núcleo de los equipos de video en linux. En Linux, el dispositivo de video es un archivo de dispositivo, que se puede leer y escribir como un archivo normal. La cámara se encuentra en / dev / video0.
- Verifique el dispositivo de la cámara de Linux, si hay un dispositivo de cámara válido, puede verificarlo en el directorio dev
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
- También puede verificar la información de inicio, si hay un dispositivo de cámara USB válido
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
El comando v4l2-ctl para ver la información de los parámetros del dispositivo de video, si el comando v4l2-ctl no se encuentra como se le solicita, debe instalar 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
Con la información anterior, se puede ver que el dispositivo admite una resolución de 1280 × 720 y admite el formato MJPEG.