Open imkow opened 6 years ago
Please report output of lsusb
and lsmod
after booting with camera connected.
this is from downgraded 4.14.31 kernel:
pi@raspberrypi:~ $ lsusb
Bus 001 Device 004: ID 045e:0811 Microsoft Corp.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pi@raspberrypi:~ $ lsmod
Module Size Used by
fuse 106496 3
rfcomm 49152 6
bnep 20480 2
hci_uart 24576 1
evdev 24576 0
bluetooth 368640 28 hci_uart,bnep,rfcomm
ecdh_generic 28672 1 bluetooth
binfmt_misc 20480 1
snd_soc_wm8804_i2c 16384 0
arizona_spi 16384 0
snd_soc_wm8804 16384 1 snd_soc_wm8804_i2c
arizona_ldo1 16384 0
uvcvideo 90112 0
videobuf2_vmalloc 16384 1 uvcvideo
videobuf2_memops 16384 1 videobuf2_vmalloc
videobuf2_v4l2 24576 1 uvcvideo
videobuf2_core 45056 2 uvcvideo,videobuf2_v4l2
videodev 184320 3 uvcvideo,videobuf2_core,videobuf2_v4l2
snd_usb_audio 172032 0
media 32768 2 uvcvideo,videodev
snd_hwdep 16384 1 snd_usb_audio
snd_usbmidi_lib 32768 1 snd_usb_audio
snd_rawmidi 32768 1 snd_usbmidi_lib
snd_seq_device 16384 1 snd_rawmidi
brcmfmac 307200 0
brcmutil 16384 1 brcmfmac
cfg80211 573440 1 brcmfmac
rfkill 28672 6 bluetooth,cfg80211
snd_soc_rpi_cirrus 24576 0
snd_soc_bcm2835_i2s 16384 0
snd_bcm2835 32768 1
snd_soc_core 188416 3 snd_soc_wm8804,snd_soc_rpi_cirrus,snd_soc_bcm2835_i2s
snd_compress 20480 1 snd_soc_core
snd_pcm_dmaengine 16384 1 snd_soc_core
snd_pcm 98304 7 snd_soc_wm8804,snd_soc_rpi_cirrus,snd_usb_audio,snd_pcm_dmaengine,snd_soc_bcm2835_i2s,snd_bcm2835,snd_soc_core
snd_timer 32768 1 snd_pcm
snd 69632 13 snd_compress,snd_hwdep,snd_soc_rpi_cirrus,snd_usb_audio,snd_timer,snd_rawmidi,snd_usbmidi_lib,snd_seq_device,snd_bcm2835,snd_soc_core,snd_pcm
i2c_bcm2835 16384 0
spi_bcm2835 16384 0
uio_pdrv_genirq 16384 0
uio 20480 1 uio_pdrv_genirq
fixed 16384 0
i2c_dev 16384 0
ip_tables 24576 0
x_tables 28672 1 ip_tables
ipv6 434176 26
@imkow Is this still an issue with later kernels? (We are currently on 4.14.39 if you use rpi-update)
I am getting the same error with last kernel version 4.14.41-v7+.
select timeout
select timeout
OpenCV(3.4.1) Error: Assertion failed (total() == 0 || data != __null) in Mat, file /home/pi/opencv-3.4.1/modules/core/include/opencv2/core/mat.inl.hpp, line 500
Further debug required to have any hope of tracking this down.
sudo apt install v4l-utils
v4l2-ctl -D
v4l2-ctl --list-formats-ext
v4l2-ctl -V
v4l2-ctl -stream-mmap=3 --stream-count=1000 --stream-to=/dev/null
That last one should stream 1000 frames from the webcam (ditching the resulting data). If that works then it implies OpenCV is doing something wrong.
There's no obvious changes in the history for USB or V4L2 between 4.14.31 and 4.14.32, other than https://github.com/raspberrypi/linux/commit/8960ba68b681a62a523cc593773d5d03a413a075, but that should only be fixing an initialisation error.
In my case, this did the trick:
sudo rmmod uvcvideo
sudo modprobe uvcvideo nodrop=1 timeout=5000
@6by9 Do we need to increase a default timeout somewhere, as per the previous comment?
timeout
defaults to 5000 anyway.
https://elixir.bootlin.com/linux/v4.14.52/source/drivers/media/usb/uvc/uvcvideo.h#L171
https://elixir.bootlin.com/linux/v4.14.52/source/drivers/media/usb/uvc/uvc_driver.c#L39
nodrop
has the description of "Don't drop incomplete frames".
If nodrop!=0, then the uvc queue gets a UVC_QUEUE_DROP_CORRUPTED
flag applied, and if we get errors reported then the buffer is reused rather than returned.
Getting errors would imply the USB camera is misbehaving at some level, so it should NOT be on by default.
Looking back at the original report, there's the outside chance of a USB regression within the 4.14.31 to 4.14.32 window, but unlikely.
If @imkow reports back with the actual model information of his webcam, and whether nodrop=1
works for him, then it gives something that can be investigated.
@imkow Can you provide some more information on the HW being used and try the nodrop=1 option outlined above? We won't be able to make any progress unless we get this information.
I'm facing the same problem. Did you fix this problem?
Which kernel are you running? Can you provide the information and follow the suggestion that James mentions above? (@imkow seems to have lost interest)
I am using 4.14.71-v7+. I already did the suggestion from @jruizaranguren but the error still there. Opencv version : 3.4.1
Which hardware are you using?
Have you tried the steps using v4l2-ctl in https://github.com/raspberrypi/linux/issues/2490#issuecomment-390604528 ? Has this device every worked on any Linux platform?
I am using Raspberry Pi 3 B+. I already uninstall OpenCv 3.4.1 and install 3.3.0 instead. It seems working normally now. Thanks guys
@nguyen13 Please will you post the output of the requested commands. Downgrading may sort you out for now, but problems ought to be reported back to the OpenCV folk so that they can investigate and fix it. (AFAICT this isn't a Pi issue, but can't say that for certain based on the information given).
after updating to this commit: https://github.com/Hexxeh/rpi-firmware/commit/0382fa9aae15a1641e4c52ba2ffdaf2cfbe0c4f8
4.14.31 is OK.
detailed info:
select timeout select timeout OpenCV Error: Assertion failed (total() == 0 || data != null) in Mat, file /home/pi/projects/opencv-3.4.0/modules/core/include/opencv2/core/mat.inl.hpp, line 500 terminate called after throwing an instance of 'cv::Exception' what(): /home/pi/projects/opencv-3.4.0/modules/core/include/opencv2/core/mat.inl.hpp:500: error: (-215) total() == 0 || data != null in function Mat