Hello,

The UVC app produces a green/broken webcam image with the OAK-D W OV9782. I've tried updating the resolution to THE_720/800_P, can some please advise on how to correct the image corruption?

Thank you,

Sean

Hi @seandevlin

Please attach a minimal code so I can try to reproduce the issue locally.

Thanks,
Jaka

Here is the UVC app modified only at line 30.

`
#!/usr/bin/env python3
import platform
import depthai as dai
import time
import sys
import signal
import threading
from depthai_sdk.managers import arg_manager

args = arg_manager.parseArgs()

if platform.machine() == 'aarch64':
print("This app is temporarily disabled on AARCH64 systems due to an issue with stream preview. We are working on resolving this issue", file=sys.stderr)
raise SystemExit(1)

enable_4k = False # Will downscale 4K -> 1080p

Start defining a pipeline

pipeline = dai.Pipeline()

Define a source - color camera

cam_rgb = pipeline.createColorCamera()
cam_rgb.setBoardSocket(dai.CameraBoardSocket.RGB)
cam_rgb.setInterleaved(True)

if enable_4k:
cam_rgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_4_K)
cam_rgb.setIspScale(1, 2)
else:
cam_rgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_720_P)

Create an UVC (USB Video Class) output node. It needs 1920x1080, NV12 input

uvc = pipeline.createUVC()
cam_rgb.video.link(uvc.input)

Terminate app handler

quitEvent = threading.Event()
signal.signal(signal.SIGTERM, lambda *_args: quitEvent.set())

Pipeline defined, now the device is connected to

with dai.Device(pipeline, usb2Mode=False) as device:
if device.getDeviceInfo().protocol == dai.XLinkProtocol.X_LINK_USB_VSC and device.getUsbSpeed() not in (dai.UsbSpeed.SUPER, dai.UsbSpeed.SUPER_PLUS):
print("This app is temporarily disabled with USB2 connection speed due to known issue. We're working on resolving it. In the meantime, please try again with a USB3 cable/port for the device connection", file=sys.stderr)
raise SystemExit(1)
print("\nDevice started, please keep this process running")
print("and open an UVC viewer. Example on Linux:")
print(" guvcview -d /dev/video0")
print("\nTo close: Ctrl+C")

# Doing nothing here, just keeping the host feeding the watchdog
while not quitEvent.is_set():
    try:
        time.sleep(0.1)
    except KeyboardInterrupt:
        break

`

    seandevlin

    #!/usr/bin/env python3
    
    import time
    import argparse
    
    parser = argparse.ArgumentParser()
    parser.add_argument('-fb', '--flash-bootloader', default=False, action="store_true")
    parser.add_argument('-f',  '--flash-app',        default=False, action="store_true")
    parser.add_argument('-l',  '--load-and-exit',    default=False, action="store_true")
    args = parser.parse_args()
    
    if args.load_and_exit:
        import os
        # Disabling device watchdog, so it doesn't need the host to ping periodically.
        # Note: this is done before importing `depthai`
        os.environ["DEPTHAI_WATCHDOG"] = "0"
    
    import depthai as dai
    
    def getPipeline():
        enable_4k = False  # Will downscale 4K -> 1080p
    
        pipeline = dai.Pipeline()
    
        # Define a source - color camera
        cam_rgb = pipeline.createColorCamera()
        cam_rgb.setBoardSocket(dai.CameraBoardSocket.CAM_A)
        cam_rgb.setInterleaved(False)
        #cam_rgb.initialControl.setManualFocus(130)
    
        if enable_4k:
            cam_rgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_4_K)
            cam_rgb.setIspScale(1, 2)
        else:
            cam_rgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
    
        # Create an UVC (USB Video Class) output node
        uvc = pipeline.createUVC()
        cam_rgb.video.link(uvc.input)
    
        # Note: if the pipeline is sent later to device (using startPipeline()),
        # it is important to pass the device config separately when creating the device
        config = dai.Device.Config()
        # config.board.uvc = dai.BoardConfig.UVC()  # enable default 1920x1080 NV12
        config.board.uvc = dai.BoardConfig.UVC(1280, 800)
        config.board.uvc.frameType = dai.ImgFrame.Type.NV12
        # config.board.uvc.cameraName = "My Custom Cam"
        pipeline.setBoardConfig(config.board)
    
        return pipeline
    
    # Will flash the bootloader if no pipeline is provided as argument
    def flash(pipeline=None):
        (f, bl) = dai.DeviceBootloader.getFirstAvailableDevice()
        bootloader = dai.DeviceBootloader(bl, True)
    
        # Create a progress callback lambda
        progress = lambda p : print(f'Flashing progress: {p*100:.1f}%')
    
        startTime = time.monotonic()
        if pipeline is None:
            print("Flashing bootloader...")
            bootloader.flashBootloader(progress)
        else:
            print("Flashing application pipeline...")
            bootloader.flash(progress, pipeline)
    
        elapsedTime = round(time.monotonic() - startTime, 2)
        print("Done in", elapsedTime, "seconds")
    
    if args.flash_bootloader or args.flash_app:
        if args.flash_bootloader: flash()
        if args.flash_app: flash(getPipeline())
        print("Flashing successful. Please power-cycle the device")
        quit()
    
    if args.load_and_exit:
        device = dai.Device(getPipeline())
        print("\nDevice started. Attempting to force-terminate this process...")
        print("Open an UVC viewer to check the camera stream.")
        print("To reconnect with depthai, a device power-cycle may be required in some cases")
        # We do not want the device to be closed, so terminate the process uncleanly.
        # (TODO add depthai API to be able to cleanly exit without closing device)
        import signal
        os.kill(os.getpid(), signal.SIGTERM)
    
    # Standard UVC load with depthai
    with dai.Device(getPipeline()) as device:
        print("\nDevice started, please keep this process running")
        print("and open an UVC viewer to check the camera stream.")
        print("\nTo close: Ctrl+C")
    
        # Doing nothing here, just keeping the host feeding the watchdog
        while True:
            try:
                time.sleep(0.1)
            except KeyboardInterrupt:
                break

    Thanks,
    Jaka

      jakaskerl

      ➜  depthai git:(develop) ✗ python3 ./apps/uvc/main3.py -fb 
      Flashing bootloader...
      Flashing progress: 0.0%
      Flashing progress: 6.2%
      Flashing progress: 12.5%
      Flashing progress: 18.8%
      Flashing progress: 25.0%
      Traceback (most recent call last):
        File "/Users/sean.devlin/Luxonis/depthai/./apps/uvc/main3.py", line 72, in <module>
          if args.flash_bootloader: flash()
        File "/Users/sean.devlin/Luxonis/depthai/./apps/uvc/main3.py", line 63, in flash
          bootloader.flashBootloader(progress)
      depthai.XLinkReadError: Couldn't read data from stream: '__bootloader' (X_LINK_ERROR)
      ➜  depthai git:(develop) ✗ python3 ./apps/uvc/main3.py -f 
      Traceback (most recent call last):
        File "/Users/sean.devlin/Luxonis/depthai/./apps/uvc/main3.py", line 73, in <module>
          if args.flash_app: flash(getPipeline())
        File "/Users/sean.devlin/Luxonis/depthai/./apps/uvc/main3.py", line 38, in getPipeline
          uvc = pipeline.createUVC()
      AttributeError: 'depthai.Pipeline' object has no attribute 'createUVC'
      ➜  depthai git:(develop) ✗ python3 ./apps/uvc/main3.py -l
      Traceback (most recent call last):
        File "/Users/sean.devlin/Luxonis/depthai/./apps/uvc/main3.py", line 78, in <module>
          device = dai.Device(getPipeline())
        File "/Users/sean.devlin/Luxonis/depthai/./apps/uvc/main3.py", line 38, in getPipeline
          uvc = pipeline.createUVC()
      AttributeError: 'depthai.Pipeline' object has no attribute 'createUVC'

        Hi seandevlin
        createUVC should work on 2.23 and 2.22. And also, why are you flashing the app to a USB device? The standalone mode should be used on POE devices only.

        Thanks,
        Jaka

        Reflashed device back to original state, still can't get create UVC on this OV9782 camera though.


        depthai-python git:(v2.23.0.0) ✗ python3 ./examples/ColorCamera/rgb_uvc.py Traceback (most recent call last): File "/Users/sean.devlin/play/depthai-python/./examples/ColorCamera/rgb_uvc.py", line 88, in <module> with dai.Device(getPipeline()) as device: File "/Users/sean.devlin/play/depthai-python/./examples/ColorCamera/rgb_uvc.py", line 38, in getPipeline uvc = pipeline.createUVC() AttributeError: 'depthai.Pipeline' object has no attribute 'createUVC' ➜ depthai-python git:(v2.23.0.0) ✗

          Hi seandevlin
          There must be a problem with python version then. Perhaps a different environment is used? I can confirm the createUVC was added in 2.22.0.0.

          Thanks,
          Jaka

          Hi seandevlin
          I mean the problem is likely that some other environment is used that doesn't have the correct depthai version installed.
          I usually use 3.11.6

          Thanks,
          Jaka