概述
我已经看过了之前的关于VIM3 MIPI摄像头的帖子,但依旧没有找到解决方案。
一开始我用的是,VIM3_Ubuntu-server-focal_Linux-4.9_arm64_EMMC_V1.0.9-211217.img.xz 固件,通过pip安装的opencv
pip install opencv-python
但跑python代码会报错
import cv2
cap = cv2.VideoCapture(0)
[ WARN:0] VIDEOIO(V4L2:/dev/video0): can’t open camera by index
通过v4l2测试可以看到摄像头画面
v4l2_test -c 1 -p 0 -F 0 -f 0 -D 0 -R 1 -r 2 -d 2 -N 1000 -n 800 -w 0 -e 1 -I 0 -b /dev/fb0 -v /dev/video0
软件版本
- 固件版本 VIM3_Ubuntu-server-focal_Linux-4.9_arm64_EMMC_V1.0.9-211217.img.xz
- opencv版本 通过pip安装,看到版本是4.2.0
SD桌面版
我猜测是OpenCV库的问题,看了之前的帖子我以为桌面版的自带了OpenCV库
所以我又试了SD桌面版固件VIM3_Ubuntu-gnome-focal_Linux-5.16-rc2_arm64_SD-USB_V1.0.9-211217.img.xz。但python import发现并没有OpenCV库。同时,发现GuvcView无法打开摄像头
此时v4l2测试也遇到报错,(报错信息中出现了Permission denied信息,但我是用root运行v4l2_test的)
sh: 1: cannot create /sys/class/display/mode: Directory nonexistent
ioctl FBIOPUT_VSCREENINFO: Invalid argument
sh: 1: cannot create /sys/class/graphics/fb0/freescale_mode: Permission denied
sh: 1: cannot create /sys/class/graphics/fb0/window_axis: Permission denied
sh: 1: cannot create /sys/class/graphics/fb0/free_scale_axis: Permission denied
sh: 1: cannot create /sys/class/graphics/fb0/free_scale: Permission denied
ds1_out_fmt = 0, ds2_out_fmt = 0, ds1_res = 2, ds2_res = 2
The /dev/fb0 device was opened successfully.
1920x1080, 32bpp
Error reading variable information
The framebuffer device was mapped to memory successfully.
fr_num = 1000, ds_num = 800
pixel fmt 0x33424752, width 1920, height 1080, wdr_mode 0, exposure 1pixel fmt 0x33424752, width 1280, height 720, wdr_mode 0, exposure 1pixel fmt 0x33424752, width 1280, height 720, wdr_mode 0, exposure 1Setting 0 sensor preset
Do sensor preset failedThread 0 created successfully
[T#0] The /dev/video0 device was opened successfully.
[T#0] VIDIOC_QUERYCAP: capabilities=0x84204000, device_caps:0x4204000
FR wdr_mode = 0, exp = 1
Do sensor wdr mode failed
Do sensor exposure failed
do_sensor_ir_cut failed
[T#0] VIDIO_S_FMT: type=9, w=1920, h=1080, fmt=0x33424752, field=0
[T#0] VIDIO_G_FMT: type=9, w=1920, h=1080, fmt=0x32314d4e, field=1
[T#0] multiplanar support planes=2
Error get crop cap
set_manual_exposure failed
set_manual_sensor_integration_time failed
set_manual_sensor_analog_gain failed
set_manual_sensor_digital_gain failed
set_manual_isp_digital_gain failed
set_stop_sensor_update failed
[T#0] plane:0 multiplanar length: 2097152 offset: 1073741824, dma_fd:5
[T#0] Buffer[0] mapped at address 0xffffa1bf9000 total_mapped_mem:1.
[T#0] plane:1 multiplanar length: 1048576 offset: 1075838976, dma_fd:6
[T#0] Buffer[1] mapped at address 0xffffa1af9000 total_mapped_mem:2.
[T#0] plane:0 multiplanar length: 2097152 offset: 1076887552, dma_fd:7
[T#0] Buffer[2] mapped at address 0xffffa18f9000 total_mapped_mem:3.
[T#0] plane:1 multiplanar length: 1048576 offset: 1078984704, dma_fd:8
[T#0] Buffer[3] mapped at address 0xffffa17f9000 total_mapped_mem:4.
[T#0] plane:0 multiplanar length: 2097152 offset: 1080033280, dma_fd:9
[T#0] Buffer[4] mapped at address 0xffffa15f9000 total_mapped_mem:5.
[T#0] plane:1 multiplanar length: 1048576 offset: 1082130432, dma_fd:10
[T#0] Buffer[5] mapped at address 0xffffa14f9000 total_mapped_mem:6.
[T#0] plane:0 multiplanar length: 2097152 offset: 1083179008, dma_fd:11
[T#0] Buffer[6] mapped at address 0xffffa12f9000 total_mapped_mem:7.
[T#0] plane:1 multiplanar length: 1048576 offset: 1085276160, dma_fd:12
[T#0] Buffer[7] mapped at address 0xffffa11f9000 total_mapped_mem:8.
[T#0] plane:0 multiplanar length: 2097152 offset: 1086324736, dma_fd:13
[T#0] Buffer[8] mapped at address 0xffffa0ff9000 total_mapped_mem:9.
[T#0] plane:1 multiplanar length: 1048576 offset: 1088421888, dma_fd:14
[T#0] Buffer[9] mapped at address 0xffffa0ef9000 total_mapped_mem:10.
[T#0] plane:0 multiplanar length: 2097152 offset: 1089470464, dma_fd:15
[T#0] Buffer[10] mapped at address 0xffffa0cf9000 total_mapped_mem:11.
[T#0] plane:1 multiplanar length: 1048576 offset: 1091567616, dma_fd:16
[T#0] Buffer[11] mapped at address 0xffffa0bf9000 total_mapped_mem:12.
[T#0] Queue buf done.
[T#0] Video stream is on.
terminating all threads ...
[T#0] 2000 ms poll timeout.
do_sensor_ir_cut failed
thread 0 terminated ...
terminating v4l2 test app, thank you ...
我想确认这是否是OpenCV库造成的问题,如果是,我应该装哪个版本的库,如何安装?