Defining Source Node
source_node = self.pipeline.create(dai.node.ColorCamera)
source_node.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
source_node.setPreviewSize((1920, 1080))
source_node.setInterleaved(False)
source_node.setColorOrder(dai.ColorCameraProperties.ColorOrder.BGR)
Defining Manip Node
manip_node = self.pipeline.create(dai.node.ImageManip)
max_output_frame_size = int(640 x 640 x 3)
manip_node.setMaxOutputFrameSize(max_output_frame_size)
manip_node.setResizeThumbnail(640, 640, 0, 0, 0)
manip_node.initialConfig.setFrameType(dai.ImgFrame.Type.BGR888p)
manip_node.inputImage.setBlocking(True)
Defining Yolov8 Node (Trained through Ultralytics)
detector_network = self.pipeline.create(dai.node.YoloDetectionNetwork) detector_network*.setBlobPath('model.blob'*)
detector_network.setConfidenceThreshold(0.5)
detector_network.setNumClasses(3)
detector_network.setCoordinateSize(4)
detector_network.setIouThreshold(0.5)
detector_network.input.setBlocking(False)
Defining Tracker Node
object_tracker = self.pipeline.create(dai.node.ObjectTracker)
object_tracker.setDetectionLabelsToTrack([0, 1, 2])
object_tracker.setTrackerType(tracker_type)
object_tracker.setTrackerIdAssignmentPolicy(dai.TrackerIdAssignmentPolicy.UNIQUE_ID)
object_tracker.inputTrackerFrame.setBlocking(True)
object_tracker.inputDetectionFrame.setBlocking(True)
object_tracker.inputDetections.setBlocking(True)
object_tracker.setStreamName("tracklets")
Defining XLinkOut Node
xlink_out = self.pipeline.create(dai.node.XLinkOut)
xlink_out.setStreamName("outFrame")
Linking Frame
source_node.preview.link(manip_node.inputImage)
manip_node.out.link(detector_network.input)
detector_network.input.setBlocking(False)
detector_network.out.link(object_tracker.inputDetections)
detector_network.passthrough.link(object_tracker.inputDetectionFrame)
source_node.video.link(object_tracker.inputTrackerFrame)
object_tracker.out.link(tracker_out.input)
object_tracker.passthroughTrackerFrame.link(xlink_out.input)
Execute Pipeline
pipeline = dai.Pipeline()
with dai.Device(pipeline=pipeline ) as device:
q_frame_out = device.getOutputQueue(name="outFrame", maxSize=4, blocking=False)
q_tracklets = device.getOutputQueue(name="tracklets", maxSize=4)
While True:
track = q_tracklets.get()
track_frame = q_frame_out.get()
tracklets_data = track.tracklets
tracker_frame = track_frame.getCvFrame()
I am not getting anything from tracklets_data. Its returning empty list.