Hi erik ,
Please try following code with OAK-D Pro PoE and please compare printed out results by running with the code uncommented line 41 and 46. And I attached a pipeline graph, please tell me if I'm wrong. In this graph, I still not sure why adding XLinkOut effects frame drop in script node. It is nice to help me to understand what's going on. How can I get color image stream(frame droppable) and snapshot image(without frame drop) at an event on script node? Any advice would be helpful. Thank you!
import depthai as dai
fps = 30
pipeline = dai.Pipeline()
# Color camera
colorCam = pipeline.createColorCamera()
colorCam.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
colorCam.setFps(fps)
colorCam.setBoardSocket(dai.CameraBoardSocket.RGB)
colorCam.setInterleaved(False)
# Script node
io_node = pipeline.create(dai.node.Script)
script = """
import time
preSeqNum = 0
while True:
cf = node.io['c'].get()
seqNum = cf.getSequenceNum()
if seqNum - preSeqNum > 1:
node.warn(f"Drop {seqNum - preSeqNum} frames at {seqNum}")
if seqNum % 10 == 0:
node.io['color'].send(cf)
preSeqNum = seqNum
"""
io_node.setScript(script)
io_node.inputs['c'].setQueueSize(10)
io_node.inputs['c'].setBlocking(True)
# Linking
xout_color = pipeline.createXLinkOut()
xout_color.setStreamName("color")
xout_color_stream = pipeline.createXLinkOut()
xout_color_stream.setStreamName("color_stream")
xout_color_stream.input.setBlocking(False)
xout_color_stream.input.setQueueSize(10)
colorCam.isp.link(io_node.inputs['c'])
# colorCam.isp.link(xout_color_stream.input)
io_node.outputs["color"].link(xout_color.input)
with dai.Device(pipeline) as device:
q_color = device.getOutputQueue("color")
# q_color_stream = device.getOutputQueue("color_stream", maxSize=30, blocking=False)
print("Started")
while True:
color_frame = q_color.get()
print(f"Received sequence number: {color_frame.getSequenceNum()}")
This is output in my environment.
(Original)
Started
[-] [-] [5.556] [Script(1)] [warning] Drop 3 frames at 7
Received sequence number: 0
Received sequence number: 10
Received sequence number: 20
Received sequence number: 30
Received sequence number: 40
Received sequence number: 50
...
(With uncomment)
Started
Received sequence number: 0
[-] [-] [5.614] [Script(1)] [warning] Drop 3 frames at 7
[-] [-] [5.616] [Script(1)] [warning] Drop 2 frames at 9
Received sequence number: 10
Received sequence number: 20
[-] [-] [6.162] [Script(1)] [warning] Drop 2 frames at 24
Received sequence number: 30
[-] [-] [6.501] [Script(1)] [warning] Drop 2 frames at 34
...
Received sequence number: 150
[-] [-] [10.502] [Script(1)] [warning] Drop 2 frames at 154
Received sequence number: 160
[-] [-] [10.766] [Script(1)] [warning] Drop 2 frames at 162
[-] [-] [11.011] [Script(1)] [warning] Drop 2 frames at 170
Received sequence number: 170
[-] [-] [11.279] [Script(1)] [warning] Drop 2 frames at 178
...