Hello,

I was looking for assistance with modifying currently functional OAK-D-S2 code to OAK-D-PoE code. Here are the changes made so far, but are there further changes that should be made to connect all the nodes and make sure the pipeline will launch correctly? Relevant portion below:

FRAME_SIZE = (1440,1080)
FOCUS_VALUE = 175
FPS = 30

BBOX_EXPANSION_PERCENT = 200
DETECTION_THRESHOLD = 0.9

MANUAL_EXPOSURE = True
EXP_TIME = 1000 # sensor exposure time, range 1 to 33000
SENS_ISO = 1600 # sesnor sensitivity, range 100 to 1600

# Create pipeline
pipeline = dai.Pipeline()

# Create an OAK-1-PoE camera
cam = pipeline.create(dai.node.CameraBoard, dai.CameraBoard.OAK1_POE)

# Define camera node
cam = pipeline.create(dai.node.ColorCamera)
cam.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
cam.setPreviewSize(FRAME_SIZE)
cam.setInterleaved(False)
cam.initialControl.setManualFocus(FOCUS_VALUE)
cam.setFps(FPS)

# Define image preprocessor node
# --> dection model requires 384x384, grayscale input image
proc = pipeline.create(dai.node.ImageManip)
proc.initialConfig.setResize(384,384)
proc.initialConfig.setFrameType(dai.ImgFrame.Type.GRAY8)
proc.initialConfig.setKeepAspectRatio(False)

# Define QR detection model
nn = pipeline.create(dai.node.MobileNetDetectionNetwork)
nn.setConfidenceThreshold(DETECTION_THRESHOLD)
nn.setBlobPath(blobconverter.from_zoo(name="qr_code_detection_384x384", zoo_type="depthai", shaves=6))
nn.input.setQueueSize(1)
nn.input.setBlocking(False)

# Define input nodes
controlIn = pipeline.create(dai.node.XLinkIn)
controlIn.setStreamName("control")

# Define output nodes
camOut = pipeline.create(dai.node.XLinkOut)
camOut.setStreamName("camera")
nnOut = pipeline.create(dai.node.XLinkOut)
nnOut.setStreamName("nn")

# Link the nodes
cam.preview.link(proc.inputImage)
proc.out.link(nn.input)
cam.preview.link(camOut.input)
nn.out.link(nnOut.input)
controlIn.out.link(cam.inputControl)

# Connect to a device and start the pipeline
with dai.Device(pipeline) as device:  .. and business logic continues, having launched pipeline

    Hi DiproChakraborty
    Not sure what this is:
    cam = pipeline.create(dai.node.CameraBoard, dai.CameraBoard.OAK1_POE)

    You are redefining the cam variable. The rest seems fine. What exactly is the error you are getting?

    Thanks,
    Jaka

    Ah right, sorry! This was a remnant from something else. Is the code as is correct with the nodes and as expected for the PoE camera, if that line is excluded? Are there code differences to keep in mind between the PoE and OAK-D-S2 camera otherwise?

      Hi DiproChakraborty
      The device name doesn't need to be specified since it is present in the factory calibration flash. The code itself looks fine to me, is it not working?

      Thanks,
      Jaka

      Sometimes, in the logic, I also restart another connection pipeline and try to get the camera started again. Sometimes on this second try, the camera fails (it returns no devices connected) and needs another try. 2 questions here:

      1. How can I explicitly close the Luxonis pipeline for the PoE camera from an earlier process?
      2. How do I handle a "try-except" like paradigm where I can try for a connection, and if it fails, just try again?

      Usually the camera successfully connects on the second try, so I want to handle this error programmatically

        Hi DiproChakraborty
        Usually just waiting something like 10 seconds will be enough for the POE camera to bootup again. Alternatively, I believe you can change the watchdog timeout to a different value, so the device will reboot faster.

        As for the try/except;
        You should be able to boot and close the device using device.startPipeline() and device.close(). Then you can create a loop that would check the device status using device.isPipelineRunning()..

        Second option would be to use a supervisor to check the state of the app. In case the app crashes, you could employ logic to restart it.

        Thanks,
        Jaka