Monday, August 09, 2021

OpenCV on 6.9 can't open camera

Hi,

I'm porting a python3 program I wrote for capturing jpegs from a USB
based webcam, using OpenCV for capture and post-processing.  I was
running this on a RaspberryPi 3B+ under linux but I'm sick of battling
crappy hardware and linux so I bought a Mini PC stick and installed
6.9.  (dmesg follows)

OpenCV (installed from the package) doesn't seem to be able to open the
camera. The camera (in this case for testing a Logitech C910) can be
accessed no problem with ffplay, fswebcam and video(1).  I also opened
the kern sysctls for both audio and video and chowned /dev/video to my user.

jross@aurora-cam:/home/jross $ fswebcam  -d v4l2:/dev/video0 -F3 --save
test2.jpg
--- Opening v4l2:/dev/video0...
/dev/video0 opened.
No input was specified, using the first.
Adjusting resolution from 384x288 to 432x240.
--- Capturing 3 frames...
Captured 3 frames in 0.06 seconds. (46 fps)
--- Processing captured image...
Writing JPEG image to 'test2.jpg'.

OpenCV not so much though:

jross@aurora-cam:/home/jross $ cat open_test.py
import cv2 as cv
import subprocess

cap = cv.VideoCapture(0, cv.CAP_V4L2)
print(cap)
if not cap.isOpened():
    print("Open Failed!")
elif cap.isOpened():
    print("Open Succeeded!")

height = cap.get(cv.CAP_PROP_FRAME_HEIGHT)
width = cap.get(cv.CAP_PROP_FRAME_WIDTH)
exposure = cap.get(cv.CAP_PROP_AUTO_EXPOSURE)

print(height,width,exposure)
frame = []
try:
    ret, temp_frame = cap.read()
    print(ret)
except Exception as e:
    print(e)
    #kill anything else using the camera
    pid = subprocess.check_output("fuser -k
/dev/video0",stderr=subprocess.STDOUT, shell=True)[:-1].decode('utf-8')
    print("Exception caught! %s" % (e))
frame.append(temp_frame)
print(frame)

jross@aurora-cam:/home/jross $ python3 open_test.py
<VideoCapture 0x6ead5ca5570>
Open Failed!
0.0 0.0 0.0
False
[None]

I'd appreciate anyone's thoughts on fixing this!

Jeff Ross

dmesg:

OpenBSD 6.9 (GENERIC.MP) #473: Mon Apr 19 10:40:28 MDT 2021
deraadt@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
real mem = 4099731456 (3909MB)
avail mem = 3960090624 (3776MB)
random: good seed from bootblocks
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 3.0 @ 0xe9c60 (84 entries)
bios0: vendor American Megatrends Inc. version "2.0" date 09/18/2020
bios0: AXON Mini PC Stick
acpi0 at bios0: ACPI 6.0
acpi0: sleep states S0 S3 S4 S5
acpi0: tables DSDT FACP FPDT FIDT MCFG DBG2 DBGP LPIT APIC NPKT PRAM
WSMT SSDT SSDT SSDT SSDT SSDT SSDT SSDT SSDT UEFI BGRT WDAT NHLT
acpi0: wakeup devices HDAS(S3) PRT0(S4) PRT1(S4) XHC_(S4) XDCI(S4)
BRCM(S0) RP01(S4) PXSX(S4) RP02(S4) PXSX(S4) RP03(S4) PXSX(S4) RP04(S4)
PXSX(S4) RP05(S4) PXSX(S4) [...]
acpitimer0 at acpi0: 3579545 Hz, 32 bits
acpimcfg0 at acpi0
acpimcfg0: addr 0xe0000000, bus 0-255
acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
cpu0 at mainbus0: apid 0 (boot processor)
cpu0: Intel(R) Celeron(R) CPU J3355 @ 2.00GHz, 1996.01 MHz, 06-5c-09
cpu0:
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,CX16,xTPR,PDCM,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,3DNOWP,PERF,ITSC,FSGSBASE,TSC_ADJUST,SMEP,ERMS,MPX,RDSEED,SMAP,CLFLUSHOPT,PT,SHA,MD_CLEAR,IBRS,IBPB,STIBP,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES
cpu0: 1MB 64b/line 16-way L2 cache
cpu0: smt 0, core 0, package 0
mtrr: Pentium Pro MTRR support, 10 var ranges, 88 fixed ranges
cpu0: apic clock running at 19MHz
cpu1 at mainbus0: apid 4 (application processor)
cpu1: Intel(R) Celeron(R) CPU J3355 @ 2.00GHz, 1995.43 MHz, 06-5c-09
cpu1:
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,DS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE,SSE3,PCLMUL,DTES64,DS-CPL,VMX,EST,TM2,SSSE3,SDBG,CX16,xTPR,PDCM,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,DEADLINE,AES,XSAVE,RDRAND,NXE,PAGE1GB,RDTSCP,LONG,LAHF,3DNOWP,PERF,ITSC,FSGSBASE,TSC_ADJUST,SMEP,ERMS,MPX,RDSEED,SMAP,CLFLUSHOPT,PT,SHA,MD_CLEAR,IBRS,IBPB,STIBP,SENSOR,ARAT,XSAVEOPT,XSAVEC,XGETBV1,XSAVES
cpu1: 1MB 64b/line 16-way L2 cache
cpu1: smt 0, core 2, package 0
ioapic0 at mainbus0: apid 1 pa 0xfec00000, version 20, 120 pins
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 1 (RP01)
acpiprt2 at acpi0: bus 2 (RP02)
acpiprt3 at acpi0: bus -1 (RP03)
acpiprt4 at acpi0: bus -1 (RP04)
acpiprt5 at acpi0: bus -1 (RP05)
acpiprt6 at acpi0: bus -1 (RP06)
aplgpio0 at acpi0 GPO0 uid 1 addr 0xd0c50000/0x76c irq 14, 78 pins
acpipci0 at acpi0 PCI0: 0x00000000 0x00000011 0x00000001
acpicmos0 at acpi0
acpibtn0 at acpi0: PWRB
aplgpio1 at acpi0 GPO1 uid 2 addr 0xd0c40000/0x764 irq 14, 77 pins
aplgpio2 at acpi0 GPO2 uid 3 addr 0xd0c70000/0x674 irq 14, 47 pins
aplgpio3 at acpi0 GPO3 uid 4 addr 0xd0c00000/0x654 irq 14, 43 pins
"ACPI0011" at acpi0 not configured
"INT33A1" at acpi0 not configured
"INT3400" at acpi0 not configured
"PNP0C0B" at acpi0 not configured
acpicpu0 at acpi0: C3(10@150 io@0x419), C2(10@50 io@0x415), C1(1000@1
halt), PSS
acpicpu1 at acpi0: C3(10@150 io@0x419), C2(10@50 io@0x415), C1(1000@1
halt), PSS
acpipwrres0 at acpi0: SPPR
acpipwrres1 at acpi0: SPPR
acpipwrres2 at acpi0: UPPR
acpipwrres3 at acpi0: PX03, resource for HS03, MODM
acpipwrres4 at acpi0: UPPR
acpipwrres5 at acpi0: UPPR
acpipwrres6 at acpi0: UPPR
acpipwrres7 at acpi0: UPPR
acpipwrres8 at acpi0: UPPR
acpipwrres9 at acpi0: PXP_, resource for RP01
acpipwrres10 at acpi0: PXP_, resource for RP03
acpipwrres11 at acpi0: PXP_, resource for RP04
acpipwrres12 at acpi0: PXP_, resource for RP06
acpipwrres13 at acpi0: PAUD
acpipwrres14 at acpi0: LSPR, resource for I2C0, I2C1, I2C2, I2C3, I2C4,
I2C5, I2C6, I2C7, URT1, URT2, URT3, URT4, SPI1, SPI2, SPI3, PWM_
acpipwrres15 at acpi0: SDPR, resource for SDHA, SDIO
acpipwrres16 at acpi0: USBC, resource for XDCI
acpipwrres17 at acpi0: FN00, resource for FAN0
acpitz0 at acpi0: critical temperature is 100 degC
acpivideo0 at acpi0: GFX0
acpivout0 at acpivideo0: DD1F
cpu0: Enhanced SpeedStep 1996 MHz: speeds: 2001, 2000, 1900, 1800, 1700,
1600, 1500, 1400, 1300, 1200, 1100, 1000, 900, 800 MHz
pci0 at mainbus0 bus 0
0:24:2: mem address conflict 0xfea10000/0x1000
pchb0 at pci0 dev 0 function 0 "Intel Apollo Lake Host" rev 0x0b
vendor "Intel", unknown product 0x5a8c (class DASP subclass
miscellaneous, rev 0x0b) at pci0 dev 0 function 1 not configured
inteldrm0 at pci0 dev 2 function 0 "Intel HD Graphics 500" rev 0x0b
drm0 at inteldrm0
inteldrm0: msi, BROXTON, gen 9
azalia0 at pci0 dev 14 function 0 "Intel Apollo Lake HD Audio" rev 0x0b: msi
azalia0: no supported codecs
"Intel Apollo Lake TXE" rev 0x0b at pci0 dev 15 function 0 not configured
ppb0 at pci0 dev 20 function 0 "Intel Apollo Lake PCIE" rev 0xfb
pci1 at ppb0 bus 1
ppb1 at pci0 dev 20 function 1 "Intel Apollo Lake PCIE" rev 0xfb: msi
pci2 at ppb1 bus 2
iwm0 at pci2 dev 0 function 0 "Intel AC 7265" rev 0x59, msi
xhci0 at pci0 dev 21 function 0 "Intel Apollo Lake xHCI" rev 0x0b: msi,
xHCI 1.0
usb0 at xhci0: USB revision 3.0
uhub0 at usb0 configuration 1 interface 0 "Intel xHCI root hub" rev
3.00/1.00 addr 1
dwiic0 at pci0 dev 22 function 0 "Intel Apollo Lake I2C" rev 0x0b: apic
1 int 27
iic0 at dwiic0
dwiic1 at pci0 dev 22 function 1 "Intel Apollo Lake I2C" rev 0x0b: apic
1 int 28
iic1 at dwiic1
dwiic2 at pci0 dev 22 function 2 "Intel Apollo Lake I2C" rev 0x0b: apic
1 int 29
iic2 at dwiic2
dwiic3 at pci0 dev 22 function 3 "Intel Apollo Lake I2C" rev 0x0b: apic
1 int 30
iic3 at dwiic3
dwiic4 at pci0 dev 23 function 0 "Intel Apollo Lake I2C" rev 0x0b: apic
1 int 31
iic4 at dwiic4
dwiic5 at pci0 dev 23 function 1 "Intel Apollo Lake I2C" rev 0x0b: apic
1 int 32
iic5 at dwiic5
dwiic6 at pci0 dev 23 function 2 "Intel Apollo Lake I2C" rev 0x0b: apic
1 int 33
iic6 at dwiic6
dwiic7 at pci0 dev 23 function 3 "Intel Apollo Lake I2C" rev 0x0b: apic
1 int 34
iic7 at dwiic7
com4 at pci0 dev 24 function 0 "Intel Apollo Lake HSUART" rev 0x0b:
ns16550, no working fifo
com5 at pci0 dev 24 function 1 "Intel Apollo Lake HSUART" rev 0x0b:
ns16550, no working fifo
com6 at pci0 dev 24 function 2 "Intel Apollo Lake HSUART" rev 0x0b: not
a UART
com7 at pci0 dev 24 function 3 "Intel Apollo Lake HSUART" rev 0x0b:
ns16550, no working fifo
"Intel Apollo Lake SPI" rev 0x0b at pci0 dev 25 function 0 not configured
"Intel Apollo Lake SPI" rev 0x0b at pci0 dev 25 function 1 not configured
"Intel Apollo Lake SPI" rev 0x0b at pci0 dev 25 function 2 not configured
"Intel Apollo Lake PWM" rev 0x0b at pci0 dev 26 function 0 not configured
sdhc0 at pci0 dev 27 function 0 "Intel Apollo Lake SD/MMC" rev 0x0b:
apic 1 int 3
sdhc0: SDHC 3.0, 200 MHz base clock
sdmmc0 at sdhc0: 4-bit, sd high-speed, mmc high-speed, ddr52, dma
sdhc1 at pci0 dev 28 function 0 "Intel Apollo Lake eMMC" rev 0x0b: apic
1 int 39
sdhc1: SDHC 3.0, 200 MHz base clock
sdmmc1 at sdhc1: 8-bit, sd high-speed, mmc high-speed, ddr52, dma
pcib0 at pci0 dev 31 function 0 "Intel Apollo Lake LPC" rev 0x0b
ichiic0 at pci0 dev 31 function 1 "Intel Apollo Lake SMBus" rev 0x0b:
polling
iic8 at ichiic0
isa0 at pcib0
isadma0 at isa0
pcppi0 at isa0 port 0x61
spkr0 at pcppi0
vmm0 at mainbus0: VMX/EPT
efifb at mainbus0 not configured
scsibus1 at sdmmc1: 2 targets, initiator 0
sd0 at scsibus1 targ 1 lun 0: <SD/MMC, SLD64G, 0000> removable
sd0: 59000MB, 512 bytes/sector, 120832000 sectors
uhub1 at uhub0 port 2 configuration 1 interface 0 "VIA Labs, Inc. USB2.0
Hub" rev 2.10/90.11 addr 2
uhidev0 at uhub1 port 2 configuration 1 interface 0 " USB Keyboard" rev
1.10/2.40 addr 3
uhidev0: iclass 3/1
ukbd0 at uhidev0: 8 variable keys, 6 key codes
wskbd0 at ukbd0: console keyboard
uhidev1 at uhub1 port 2 configuration 1 interface 1 " USB Keyboard" rev
1.10/2.40 addr 3
uhidev1: iclass 3/0, 2 report ids
uhid0 at uhidev1 reportid 1: input=1, output=0, feature=0
uhid1 at uhidev1 reportid 2: input=3, output=0, feature=0
uaudio0 at uhub1 port 4 configuration 1 interface 1 "Logitech HD Pro
Webcam C910" rev 2.00/0.10 addr 4
uaudio0: class v1, high-speed, sync, channels: 0 play, 2 rec, 2 ctls
audio0 at uaudio0
uvideo0 at uhub1 port 4 configuration 1 interface 2 "Logitech HD Pro
Webcam C910" rev 2.00/0.10 addr 4
video0 at uvideo0
uhidev2 at uhub0 port 4 configuration 1 interface 0 "Microsoft Basic
Optical Mouse" rev 1.10/0.00 addr 5
uhidev2: iclass 3/1
ums0 at uhidev2: 3 buttons, Z dir
wsmouse0 at ums0 mux 0
ugen0 at uhub0 port 7 "Intel Bluetooth" rev 2.00/0.03 addr 6
uhub2 at uhub0 port 10 configuration 1 interface 0 "VIA Labs, Inc.
USB3.0 Hub" rev 3.00/90.11 addr 7
vscsi0 at root
scsibus2 at vscsi0: 256 targets
softraid0 at root
scsibus3 at softraid0: 256 targets
root on sd0a (e0ba285b066ac610.a) swap on sd0b dump on sd0b
WARNING: / was not properly unmounted
drm:pid0:rc6_supported *NOTICE* RC6 and powersaving disabled by BIOS
inteldrm0: 1920x1080, 32bpp
wsdisplay0 at inteldrm0 mux 1: console (std, vt100 emulation), using wskbd0
wsdisplay0: screen 1-5 added (std, vt100 emulation)
iwm0: hw rev 0x210, fw ver 17.3216344376.0, address b8:9a:2a:88:b8:af

No comments:

Post a Comment