OAK 双目相机 --debug 硬盘空间用尽,解决方法是禁用uvcdynctrldebug

程序

debug  20220828 OAK 双目 灰度 视频流.ipynb 

import cv2
import depthai as dai

# Create pipeline
pipeline = dai.Pipeline()

# Define sources and outputs
monoLeft = pipeline.create(dai.node.MonoCamera)
monoRight = pipeline.create(dai.node.MonoCamera)
xoutLeft = pipeline.create(dai.node.XLinkOut)
xoutRight = pipeline.create(dai.node.XLinkOut)

xoutLeft.setStreamName('left')
xoutRight.setStreamName('right')

# Properties
monoLeft.setBoardSocket(dai.CameraBoardSocket.LEFT)
monoLeft.setResolution(dai.MonoCameraProperties.SensorResolution.THE_480_P)
monoRight.setBoardSocket(dai.CameraBoardSocket.RIGHT)
monoRight.setResolution(dai.MonoCameraProperties.SensorResolution.THE_480_P)

# Linking
monoRight.out.link(xoutRight.input)
monoLeft.out.link(xoutLeft.input)

# Connect to device and start pipeline
device=dai.Device(pipeline)       ## <<<<<<<<<<<<<<<<<    debug        RuntimeError: Failed to find device after booting, error message: X_LINK_DEVICE_NOT_FOUND
                                                                ## 原来的语句是 with dai.Device(pipeline) as device:
    # Output queues will be used to get the grayscale frames from the outputs defined above
qLeft   = device.getOutputQueue(name="left", maxSize=4, blocking=False)
qRight = device.getOutputQueue(name="right", maxSize=4, blocking=False)

while True:
        # Instead of get (blocking), we use tryGet (non-blocking) which will return the available data or None otherwise
        inLeft = qLeft.tryGet()
        # print(  "inLeft=",  inLeft, "\n")                                                                      #  显示 inLeft= None     或 显示   inLeft=  
        inRight = qRight.tryGet()

        if inLeft is not None:
            print(  "inLeft.getCvFrame()=",  inLeft.getCvFrame(), "\n")  
            cv2.imshow("left", inLeft.getCvFrame())

        if inRight is not None:
            cv2.imshow("right", inRight.getCvFrame())

        if cv2.waitKey(1) == ord('q'):
            break
            
#dai.DeviceBase.close (self)                                                                                 #    报错 NameError: name 'self' is not defined
#dai.DeviceBase.close (self: dai.DeviceBase)                                               #    报错SyntaxError: invalid syntax
#dai.DeviceBase.close (dai.DeviceBase)                                                        #   报错TypeError: close(): incompatible function arguments. 
                                                                                                                                         #  The following argument types are supported    1. (self: depthai.DeviceBase) -> None

    
dai.DeviceBase.close (device)                                                                              # 顺利运行没有报错,但是资源没有马上释放  27 with dai.Device(pipeline) as device:   RuntimeError: Failed to find device after booting, error message: X_LINK_DEVICE_NOT_FOUND
                                                                                                                                        #  uvcdynctrl-d/dev/video0-addctrl=03e7:f63b      也许原因在于  uvcdynctrl    疯狂debug,                     
cv2.destroyAllWindows()
## 运行上述代码后显示报错:
## ---------------------------------------------------------------------------
## RuntimeError                              Traceback (most recent call last)
##  in 
##      25 
##      26 # Connect to device and start pipeline
## ---> 27 device=dai.Device(pipeline)       
## <<<<<<<<<<<<<<<<<    debug        RuntimeError: ## Failed to find device after booting, error message: X_LINK_DEVICE_NOT_FOUND
##      28                                                                 
## 原来的语句是 with ## dai.Device(pipeline) as device:
##      29     # Output queues will be used to get the grayscale frames from the outputs defined above

## RuntimeError: Failed to connect to device, error message: X_LINK_DEVICE_ALREADY_IN_USE

程序运行环境

        ubuntu 18.04

bug

    程序退出后,cpu忙,不能马上开始新的视频流,结束黑白摄像头进程,风扇狂转,系统反应变慢, 系统盘写满

报错内容

                cmd窗口中, 写入重复内容
                [libwebcam] Warning: The driver behind device video0 has a slightly buggy implementation of the V4L2_CTRL_FLAG_NEXT_CTRL flag.
                    --It does not return the next higher control ID if a control query fails. A workaround has been enabled.

检查工具软件

        ubuntu自带的分析磁盘容量的图形工具--Disk Usage Analyzer

发现硬盘空间用尽 

                /var/log  目录下  uvcdynctrl-udev.log ,体积巨大,接近200G , 硬盘空间用尽. 写入重复内容
                

            /var/log syslog文件体积增大    写入重复内容:
                 cc-desktop kernel: [  413.411015] uvcvideo: Failed to query (GET_DEF) UVC control 9 on unit 1: -32 (exp. 2).

            /var/log kern.log文件体积增大    写入重复内容
                 cc-desktop kernel: [  125.283714] uvcvideo: Failed to query (GET_DEF) UVC control 9 on unit 1: -32 (exp. 2).

                QObject::moveToThread: Current thread (0x5595c1462c70) is not the object's thread (0x5595c2b0ee80). Cannot move to target thread (0x5595c1462c70)


追踪bug

    [libwebcam] Warning: The driver behind device video0 has a slightly buggy implementation of the V4L2_CTRL_FLAG_NEXT_CTRL flag.
    It does not return the next higher control ID if a control query fails. A workaround has been enabled.

根据这句话搜索,得到网址
 

        733094 - fills disk writing to /var/log/uvcdynctrl-udev.log - Debian Bug report logs

        关闭uvcdynctrl-udev.log_Joker_Ren的博客-CSDN博客
        文中说uvcdynctrl会输出巨量的log文件,会把硬盘占满,直到100%。 解决问题只需禁用debug 就可以了

debug
    修改uvcdynctrl,禁用debug
        进入目录/lib/udev/uvcdynctrl 中
        修改文件名uvcdynctrl 更名为uvcdynctrl.txt
        修改文件内容 将 debug 设置为 0,保存
        修改文件名uvcdynctrl.txt 更名为uvcdynctrl

    删除uvcdynctrl-udev.log
        进入command
        sudo nautilus
        删除uvcdynctrl-udev.log
        清空垃圾箱, 释放硬盘空间

###########################################################################


下面是 uvcdynctrl-udev.log  中的内容(仅记录开头)

==============================================================================
uvcdynctrl script version 0.3 running from '/lib/udev/uvcdynctrl'


DEVNAME='/dev/video1'
DEVPATH='/devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.1/video4linux/video1'
PPID='3560'
SEQNUM='4459'
USEC_INITIALIZED='1524407612'

==============================================================================
uvcdynctrl script version 0.3 running from '/lib/udev/uvcdynctrl'
Triggered at Sun Aug 28 13:06:14 CST 2022

ACTION='add'
COLORD_DEVICE='1'
COLORD_KIND='camera'
DEVLINKS='/dev/v4l/by-id/usb-Intel_Corporation_Luxonis_Device_1844301001BF101300-video-index0 /dev/v4l/by-path/pci-0000:00:14.0-usb-0:2:1.1-video-index0'
DEVNAME='/dev/video0'
DEVPATH='/devices/pci0000:00/0000:00:14.0/usb2/2-2/2-2:1.1/video4linux/video0'
ID_BUS='usb'
ID_FOR_SEAT='video4linux-pci-0000_00_14_0-usb-0_2_1_1'
ID_MODEL='Luxonis_Device'
ID_MODEL_ENC='Luxonis\x20Device'
ID_MODEL_ID='f63b'
ID_PATH='pci-0000:00:14.0-usb-0:2:1.1'
ID_PATH_TAG='pci-0000_00_14_0-usb-0_2_1_1'
ID_REVISION='0200'
ID_SERIAL='Intel_Corporation_Luxonis_Device_1844301001BF101300'
ID_SERIAL_SHORT='1844301001BF101300'
ID_TYPE='video'
ID_USB_DRIVER='uvcvideo'
ID_USB_INTERFACES=':ff0000:0e0100:0e0200:'
ID_USB_INTERFACE_NUM='01'
ID_V4L_CAPABILITIES=':capture:'
ID_V4L_PRODUCT='Luxonis Device: UVC Video Contr'
ID_V4L_VERSION='2'
ID_VENDOR='Intel_Corporation'
ID_VENDOR_ENC='Intel\x20Corporation'
ID_VENDOR_ID='03e7'
IFS='     
'
MAJOR='81'
MINOR='0'
OPTIND='1'
PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
PPID='3556'
PS1='# '
PS2='> '
PS4='+ '
PWD='/'
SEQNUM='4458'
SUBSYSTEM='video4linux'
TAGS=':uaccess:seat:'
USEC_INITIALIZED='1524405312'
debug='1'
logfile='/var/log/uvcdynctrl-udev.log'
uvcdynctrlpath='uvcdynctrl'
version='0.3'

VID of new device: '03e7'
PID of new device: 'f63b'
Executing command: 'uvcdynctrl -d /dev/video0 --addctrl=03e7:f63b'


[libwebcam] Warning: The driver behind device video0 has a slightly buggy implementation
  of the V4L2_CTRL_FLAG_NEXT_CTRL flag. It does not return the next higher
  control ID if a control query fails. A workaround has been enabled.
[libwebcam] Warning: The driver behind device video0 has a slightly buggy implementation
  of the V4L2_CTRL_FLAG_NEXT_CTRL flag. It does not return the next higher
  control ID if a control query fails. A workaround has been enabled.
[libwebcam] Warning: The driver behind device video0 has a slightly buggy implementation
  of the V4L2_CTRL_FLAG_NEXT_CTRL flag. It does not return the next higher
  control ID if a control query fails. A workaround has been enabled.
[libwebcam] Warning: The driver behind device video0 has a slightly buggy implementation
  of the V4L2_CTRL_FLAG_NEXT_CTRL flag. It does not return the next higher
  control ID if a control query fails. A workaround has been enabled.

========================================================


     尝试过的其他方法2 -1                                                                                                  
        等待2分钟,cup闲下来,再运行jupyter notebook 程序就能成功
        
     尝试过的其他方法2 -2                                                                                                  
        dai.DeviceBase.close (device)                                                                              
        # 顺利运行没有报错,但是资源没有马上释放  27 with dai.Device(pipeline) as device:   RuntimeError: Failed to find device after booting, error message: X_LINK_DEVICE_NOT_FOUND
        有时能马上开始新的视频流,但是有时需要等待2分钟,cup闲下来,再运行jupyter notebook 程序就能成功
        
        原因在于
            高cpu利用线程
                uvcdynctrl-d/dev/video0-addctrl=03e7:f63b

            导致资源不能及时释放,
                 with dai.Device(pipeline) as device:   RuntimeError: Failed to find device after booting, error message: X_LINK_DEVICE_NOT_FOUND

                这时运行释放资源 程序就能成功

   尝试过的其他方法 2-3
        pip install pyqt5 -i https://pypi.tuna.tsinghua.edu.cn/simple
        显示已经安装, Requirement already satisfied: PyQt5_sip<4.20,>=4.19.14 in ./anaconda3/lib/python3.8/site-packages (from pyqt5) (4.19.19)


QObject::moveToThread: Current thread (0x5595c1462c70) is not the object's thread (0x5595c2b0ee80).
Cannot move to target thread (0x5595c1462c70)

[I 2022-08-28 20:07:12.403 ServerApp] Saving file at /depthai-OAK/20220828 OAK 双目 灰度 视频流.ipynb
[1844301001BF101300] [1.4] [23.272] [system] [info] PRINT:LeonCss: bss_init took 40.529 ms
BootloaderConfig.options1 checksum doesn't match. Is: 0x10304418 should be: 0xF8135BD0
GPIO boot mode 0x16, interface USBD
Setting aons(0..4) back to boot from flash (offset = 0)
====ENABLE WATCHDOG====1
initial keepalive, countdown: 10
PLL0: 700000 AUX_IO0: 24000 AUX_IO1: 24000 MCFG: 24000 MECFG: 24000
Board init ret 3
eeprom configuration version: 55AA0006
Reading VERSION 6 --- ->
eeprom configuration load from user area, status: 0
--> brdInit ...
brdInitAuxDevices: Error: SC = 27: io_initialize expander_cam_gpios_1 [OK]

spi_N25Q_init: Flash JEDEC ID: ff ff ff
Invalid Flash JEDEC ID... No NOR available
Could not register the spi device
Failed to probe IR driver LM3644
Failed to probe IR driver LM3644
Failed to probe IR driver LM3644
Closing EEPROm!
MyriaX board configuration
pll0 frequency: 700000, ref0 frequency: 24000
Is booted from flash by bootloader: 0
Networking not available...
Called by: LOS, controller: LOS
Enumerating on socket: Cam_A / RGB / Center
Probe failed I2C1 0x10 reg 300a: expected 7750, read 0000
  >> Registered camera IMX214R0 (imx214) as /dev/Camera_0
Enumerating on socket: Cam_B / Left
Probe failed I2C2 0x60 reg 300a: expected 9281, read 7750
  >> Registered camera MV200 (ov7750) as /dev/Camera_1
Enumerating on socket: Cam_C / Right
Probe failed I2C2 0x62 reg 300a: expected 9281, read 7750
  >> Registered camera MV200 (ov7750) as /dev/Camera_2
Enumerating on socket: CAM_D
initial keepalive, countdown: 9
Initializing XLink...
UsbPumpVscAppI_Event: 5 VSC2_EVENT_ATTACH
UsbPumpVscAppI_Event: 4 VSC2_EVENT_RESET
initial keepalive, countdown: 8
UsbPumpVscAppI_Event: 4 VSC2_EVENT_RESET
UsbPumpVscAppI_Event: 0 VSC2_EVENT_INTERFACE_UP
UvcDevice_Start
USB 3.1 gen1 video device detected
Bulk endpoint on 2 interface
Done!
Usb connection speed: Super - USB 3.0
I: [Timesync] [   1729382] [main] startSync:116     Timesync | Callback not set
Temperature: Driver registered.
Temperature: Initialized driver.
Temperature: Sensor opened: CSS.
Temperature: Sensor opened: MSS.
Temperature: Sensor opened: UPA.
Temperature: Sensor opened: DSS.
[1844301001BF101300] [1.4] [23.272] [system] [info] PRINT:LeonMss: Called by: LRT, controller: LOS

QObject::moveToThread: Current thread (0x5595c1462c70) is not the object's thread (0x5595c2b0ee80).
Cannot move to target thread (0x5595c1462c70)

QObject::moveToThread: Current thread (0x5595c1462c70) is not the object's thread (0x5595c2b0ee80).
Cannot move to target thread (0x5595c1462c70)

[I 2022-08-28 20:13:12.466 ServerApp] Saving file at /depthai-OAK/20220828 OAK 双目 灰度 视频流.ipynb
[1844301001BF101300] [1.4] [302.004] [system] [info] PRINT:LeonCss: bss_init took 40.527 ms
BootloaderConfig.options1 checksum doesn't match. Is: 0x10304418 should be: 0xF8135BD0
GPIO boot mode 0x16, interface USBD
Setting aons(0..4) back to boot from flash (offset = 0)
====ENABLE WATCHDOG====1
initial keepalive, countdown: 10
PLL0: 700000 AUX_IO0: 24000 AUX_IO1: 24000 MCFG: 24000 MECFG: 24000
Board init ret 3
eeprom configuration version: 55AA0006
Reading VERSION 6 --- ->
eeprom configuration load from user area, status: 0
--> brdInit ...
brdInitAuxDevices: Error: SC = 27: io_initialize expander_cam_gpios_1 [OK]

spi_N25Q_init: Flash JEDEC ID: ff ff ff
Invalid Flash JEDEC ID... No NOR available
Could not register the spi device
Failed to probe IR driver LM3644
Failed to probe IR driver LM3644
Failed to probe IR driver LM3644
Closing EEPROm!
MyriaX board configuration
pll0 frequency: 700000, ref0 frequency: 24000
Is booted from flash by bootloader: 0
Networking not available...
Called by: LOS, controller: LOS
Enumerating on socket: Cam_A / RGB / Center

Probe failed I2C1 0x10 reg 300a: expected 7750, read 0000
  >> Registered camera IMX214R0 (imx214) as /dev/Camera_0
Enumerating on socket: Cam_B / Left

Probe failed I2C2 0x60 reg 300a: expected 9281, read 7750
  >> Registered camera MV200 (ov7750) as /dev/Camera_1
Enumerating on socket: Cam_C / Right

Probe failed I2C2 0x60 reg 300a: expected 9281, read 7750
  >> Registered camera MV200 (ov7750) as /dev/Camera_2
Enumerating on socket: CAM_D
initial keepalive, countdown: 9
Initializing XLink...
UsbPumpVscAppI_Event: 5 VSC2_EVENT_ATTACH
UsbPumpVscAppI_Event: 4 VSC2_EVENT_RESET
UsbPumpVscAppI_Event: 4 VSC2_EVENT_RESET
initial keepalive, countdown: 8
UsbPumpVscAppI_Event: 0 VSC2_EVENT_INTERFACE_UP
UvcDevice_Start
USB 3.1 gen1 video device detected
Bulk endpoint on 2 interface
Done!
Usb connection speed: Super - USB 3.0
I: [Timesync] [   1676326] [main] startSync:116     Timesync | Callback not set
Temperature: Driver registered.
Temperature: Initialized driver.
Temperature: Sensor opened: CSS.
Temperature: Sensor opened: MSS.
Temperature: Sensor opened: UPA.
Temperature: Sensor opened: DSS.
[1844301001BF101300] [1.4] [302.004] [system] [info] PRINT:LeonMss: Called by: LRT, controller: LOS

QObject::moveToThread: Current thread (0x5595c1462c70) is not the object's thread (0x5595c2b0ee80).
Cannot move to target thread (0x5595c1462c70)

你可能感兴趣的:(python,opencv,开发语言)