This is how I start the camera worker thread,
target_device_info = dai.DeviceInfo(self.host) # Camera's IP address
self.device = dai.Device(target_device_info)
self.pipeline = dai.Pipeline(self.device)
self.hostCamera = self.pipeline.create(dai.node.Camera).build()
self.aprilTagNode = self.pipeline.create(dai.node.AprilTag)
self.resolution = (640, 480)
self.fps = 50
self.videoOutput = self.hostCamera.requestOutput(size=self.resolution, fps=self.fps)
self.videoOutput.link(self.aprilTagNode.inputImage)
self.passthroughOutputQueue = self.aprilTagNode.passthroughInputImage.createOutputQueue(maxSize = 1)
self.AprilTagNodeOutQueue = self.aprilTagNode.out.createOutputQueue(maxSize = 1)
# Image manipulation node to convert RGB image to GRAY to feed to Script node
self.manipNode = self.pipeline.create(dai.node.ImageManip)
self.manipNode.initialConfig.setFrameType(dai.ImgFrame.Type.GRAY8)
self.videoOutput.link(self.manipNode.inputImage) #Input set to the manipNode
#Script node for Laplacian variance check
self.scriptNode = self.pipeline.create(dai.node.Script)
self.manipNode.out.link(self.scriptNode.inputs["image"]) #manipNode output is input for the Script node
self.lensCheckQueue = self.scriptNode.outputs["laplacianVar"].createOutputQueue(maxSize = 1)
self.scriptNode.setScript("""
import cv2
import struct
out = Buffer(4)
PACK = struct.Struct("f")
while True:
grayImage = node.io['image'].get().getCvFrame()
laplacianVar = cv2.Laplacian(grayImage, cv2.CV_64F).var()
out.setData(PACK.pack(laplacianVar))
node.io['laplacianVar'].send(out)
""")
self.pipeline.start()
and this is how I access data from the queues. Below runs in a loop. please ignore the indentation issue.
wallTime, aprilTagMessage = time.time() , self.AprilTagNodeOutQueue.tryGet()
if aprilTagMessage is None:
time.sleep(0.002) # tiny yield so SIGINT handler runs
continue
self.image = self.passthroughOutputQueue.tryGet()
if self.image is None:
time.sleep(0.002) # tiny yield so SIGINT handler runs
continue
imageQuality = self.lensCheckQueue.tryGet()
if imageQuality is None:
time.sleep(0.002) # tiny yield so SIGINT handler runs
continue
assert(isinstance(aprilTagMessage, dai.AprilTags))
I noticed, the camera was detecting the April tags fines but I got below error and it kept happening later on until i stopped the pipeline.
dai.MessageQueue.QueueException
AprilTag queue closed unexpectedly: MessageQueue was closed. for below line
`wallTime, aprilTagMessage = time.time() , self.AprilTagNodeOutQueue.tryGet()`
This did not happen again. I did not stop the pipeline/ device. So, I am not sure why did it occur. Any ideas?
Camera: Oak4S 1.25.3
Depth AI: 3.2.1
Python: 3.13.9