Hi all,
We are currently developing with the OAK4S. We are running into problems with the image buffers.
I have a custom threadedhostnode which contains the main logic (Communication outside, statemachines,etc). I have left most of it out because the problem lies with the receiving of the "last image" in the input queue. I expect to see the latest frame in the visualizer every 5 seconds. However this does not happen. The visualizer shows old messages (images).
class Master(dai.node.ThreadedHostNode):
def __init__(self, name: str) -> None:
# Handle luxonis threaded node
super().__init__()
self.name: str = name
self.input_image = self.createInput()
self.output = self.createOutput()
self.input_image.setPossibleDatatypes(
[
(dai.DatatypeEnum.ImgFrame, True),
]
)
self.output.setPossibleDatatypes([(dai.DatatypeEnum.ImgFrame, True)])
self.input_image.setMaxSize(1)
def run(self):
while self.isRunning():
time.sleep(5) # pretend this is waiting for outside communication trigger
# Empty the buffer:
self.input_image.getAll()
print(f"cleaned Buffer: {self.input_image.getSize()}/{self.input_image.getMaxSize()}")
# Get the latest img
msg: ADatatype | None = self.input_image.get()
self.output.send(msg)
Now the Master threaded node is implemented with this pipeline:
def main():
# Create a remote visualizer connection
visualizer = dai.RemoteConnection(httpPort=8082)
# Create device and pipeline
device = dai.Device()
with dai.Pipeline(device) as pipeline:
engima_master: Master = Master("Master")
# Create and configure the camera node
camera = pipeline.create(dai.node.Camera).build(sensorFps=5)
camera.setOutputsMaxSizePool(1)
camera.setNumFramesPools(1, 1, 1)
model_input = camera.requestOutput(size=(800, 800), enableUndistortion=True)
camera.initialControl.setManualExposure(exposureTimeUs=40000, sensitivityIso=800)
model_input.link(master.input_image)
visualizer.addTopic(topicName="output", output=engima_master.output)
pipeline.start()
visualizer.registerPipeline(pipeline)
# Run loop until 'q' is pressed
while pipeline.isRunning():
pipeline.processTasks()
if __name__ == "__main__":
main()
I find it strange because I have set the pool size (output buffer) to 1 and the input buffer to 1.
Did I miss something
Thanks in advance
Ryan