@erik I have purchased OAK D lite and OAK D and I have cloned the repository, ran a demo script which worked perfectly for me.

Now, I'm trying to connect to the device via the below script. But I'm getting an error message.

Basically, I'm trying to connect to the device and capture data for training and also I need to control the frames like rather than capturing all the I want to capture every 5th frame.

I have also noticed the following link https://docs.luxonis.com/projects/api/en/v2.3.0.0/samples/06_rgb_full_resolution_saver/
I tested it, it helps me to capture the frame.

But is it possible to connect via opencv python module?

  • erik replied to this.

    erik thanks for your reply. I'm trying to save the frames as video, when I inspected the frame it's in 1D array and the shape keep changing. Could you please help me here?

    
    import time
    from pathlib import Path
    
    import cv2
    import depthai as dai
    # Start defining a pipeline
    pipeline = dai.Pipeline()
    
    # Define a source - color camera
    camRgb = pipeline.createColorCamera()
    camRgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
    
    # Create RGB output
    xoutRgb = pipeline.createXLinkOut()
    xoutRgb.setStreamName("rgb")
    camRgb.video.link(xoutRgb.input)
    
    # Create encoder to produce JPEG images
    videoEnc = pipeline.createVideoEncoder()
    videoEnc.setDefaultProfilePreset(camRgb.getVideoSize(), camRgb.getFps(), dai.VideoEncoderProperties.Profile.MJPEG)
    camRgb.video.link(videoEnc.input)
    
    # Create JPEG output
    xoutJpeg = pipeline.createXLinkOut()
    xoutJpeg.setStreamName("jpeg")
    videoEnc.bitstream.link(xoutJpeg.input)
    
    
    # Connect and start the pipeline
    with dai.Device(pipeline) as device:
    
        # Output queue will be used to get the rgb frames from the output defined above
        qRgb = device.getOutputQueue(name="rgb", maxSize=30, blocking=False)
        qJpeg = device.getOutputQueue(name="jpeg", maxSize=30, blocking=True)
    
        # Make sure the destination path is present before starting to store the examples
        Path('06_data').mkdir(parents=True, exist_ok=True)
        fourcc = cv2.VideoWriter_fourcc('X','V','I','D')
        videoWriter = cv2.VideoWriter('test_video.avi', fourcc, 30.0, (640,480))
        while True:
            inRgb = qRgb.tryGet()  # Non-blocking call, will return a new data that has arrived or None otherwise
            if inRgb is not None:
                cv2.imshow("rgb", inRgb.getCvFrame())
    
            for encFrame in qJpeg.tryGetAll():
                with open(f"06_data/{int(time.time() * 10000)}.jpeg", "wb") as f:
                    f.write(bytearray(encFrame.getData()))
                    print('type ;',type(encFrame.getData()))
                    print('shape ;',encFrame.getData().shape)
                    array = encFrame.getData()
                    #arr_3d = array.reshape((640,480,3))
                    #print('shape ;',arr_3d.shape)
                    #videoWriter.write(arr_3d)
    
            if cv2.waitKey(1) == ord('q'):
                break
    
    OUTPUT:
    Output exceeds the size limit. Open the full output data in a text editor
    [2022-11-20 20:20:43.170] [warning] VideoEncoder setDefaultProfilePreset: passing 'width'/ 'height' is deprecated. The size is auto-determined from first frame
    type ; <class 'numpy.ndarray'>
    shape ; (257099,)
    type ; <class 'numpy.ndarray'>
    shape ; (525753,)
    type ; <class 'numpy.ndarray'>
    shape ; (275844,)
    type ; <class 'numpy.ndarray'>
    shape ; (275553,)
    type ; <class 'numpy.ndarray'>
    shape ; (275863,)
    type ; <class 'numpy.ndarray'>
    shape ; (275888,)
    type ; <class 'numpy.ndarray'>
    shape ; (275610,)
    type ; <class 'numpy.ndarray'>
    shape ; (275931,)
    type ; <class 'numpy.ndarray'>
    shape ; (344873,)
    type ; <class 'numpy.ndarray'>
    shape ; (305604,)
    • erik replied to this.
      9 days later

      erik Hi Erik, I'm planning to use OAD K with NVIDIA Jetson Nano device. I have got few questions

      1. Could you please tell whether OAD D is compatible with NVIDIA Jetson Nano device?
      2. Is it possible to turn on the video using opencv-python library rather than depthAI? if yes, could you please tell me how to connect via opencv-python because I tried it didn't work.
      • erik replied to this.