• DepthAI-v2
  • Different PreviewSize links for RGB camera needed

I need different preview feeds from the createColorCamera() module. I have parallel stages of simple preprocessing to do with the video feed, like cropping to a different size. So a 300x300 preview, a 512x512 preview,..... But I am unable to create multiple CamRgb(s) (from createColorCamera()). I need to send the processed images/video stream to other parts of the code later on.

Should I just use Manipulate?
Is this a supported action?
Is there a syntax/example I can use?

Or should I simply pass them out to an XLinkOut() and use it from them (using getFrame())?

  • erik replied to this.

    Hello tarocal, I would use multiple image manip nodes (it is supported, yes).

    Here is a simple example:

    #!/usr/bin/env python3
    
    import cv2
    import depthai as dai
    
    # Start defining a pipeline
    pipeline = dai.Pipeline()
    
    # Define a source - color camera
    cam = pipeline.createColorCamera()
    cam.setPreviewSize(640, 480)
    cam.setInterleaved(False)
    camOut = pipeline.createXLinkOut()
    camOut.setStreamName("rgb")
    
    manip1 = pipeline.createImageManip()
    manip1.initialConfig.setResize(300, 300)
    manipOut1 = pipeline.createXLinkOut()
    manipOut1.setStreamName("manip1")
    manip1.out.link(manipOut1.input)
    
    manip2 = pipeline.createImageManip()
    manip2.initialConfig.setResize(150, 150)
    manipOut2 = pipeline.createXLinkOut()
    manipOut2.setStreamName("manip2")
    manip2.out.link(manipOut2.input)
    
    cam.preview.link(camOut.input)
    cam.preview.link(manip1.inputImage)
    cam.preview.link(manip2.inputImage)
    
    
    # Pipeline defined, now the device is connected to
    with dai.Device(pipeline) as device:
        # Start pipeline
        device.startPipeline()
    
        qRgb = device.getOutputQueue(name="rgb", maxSize=4)
        qManip1 = device.getOutputQueue(name="manip1", maxSize=4)
        qManip2 = device.getOutputQueue(name="manip2", maxSize=4)
    
        while True:
            inRgb = qRgb.tryGet()
            inManip1 = qManip1.tryGet()
            inManip2 = qManip2.tryGet()
    
            if inRgb is not None:
                cv2.imshow("rgb", inRgb.getCvFrame())
            if inManip1 is not None:
                cv2.imshow("manip1", inManip1.getCvFrame())
            if inManip2 is not None:
                cv2.imshow("manip2", inManip2.getCvFrame())
    
            if cv2.waitKey(1) == ord('q'):
                break