Hi @jakaskerl
The link is using the same Depthai Tools to transfer model as I did ,It's just that I'm not using Colab rather and using my laptop,I think there should be no difference,
I refer to the old yoloDetect example and modify it like this
import cv2
import depthai as dai
import argparse
# Specify the path to your own model weights file
model_weights_path = "C:/catdog320.blob"
parser = argparse.ArgumentParser()
parser.add_argument('nnPath', nargs='?', help="Path to mobilenet detection network blob", default=model_weights_path)
parser.add_argument('-ff', '--full_frame', action="store_true", help="Perform tracking on full RGB frame", default=False)
args = parser.parse_args()
fullFrameTracking = args.full_frame
# Load model weights using dai.OpenVINO.Blob
custom_model_blob = dai.OpenVINO.Blob(model_weights_path)
numClasses = 80
dim = next(iter(custom_model_blob.networkInputs.values())).dims
output_name, output_tenser = next(iter(custom_model_blob.networkOutputs.items()))
numClasses = output_tenser.dims[2] - 5
labelMap = ["class_%s" % i
for i in range(numClasses)
]
# Create a pipeline
pipeline = dai.Pipeline()
monoL = pipeline.create(dai.node.MonoCamera)
manip = pipeline.create(dai.node.ImageManip)
detectionNetwork = pipeline.create(dai.node.YoloDetectionNetwork)
objectTracker = pipeline.create(dai.node.ObjectTracker)
manipOut = pipeline.create(dai.node.XLinkOut)
trackerOut = pipeline.create(dai.node.XLinkOut)
manipOut.setStreamName('flood-left')
trackerOut.setStreamName("tracklets")
monoL.setNumFramesPool(24)
monoL.setResolution(dai.MonoCameraProperties.SensorResolution.THE_400_P)
script = pipeline.create(dai.node.Script)
script.setProcessor(dai.ProcessorType.LEON_CSS)
script.setScript("""
floodBright = 0.1
node.warn(f'IR drivers detected: {str(Device.getIrDrivers())}')
while True:
event = node.io['event'].get()
Device.setIrFloodLightIntensity(floodBright)
frameL = node.io['frameL'].get()
node.io['floodL'].send(frameL)
""")
# Model-specific settings
detectionNetwork.setBlob(custom_model_blob)
detectionNetwork.setConfidenceThreshold(0.7)
detectionNetwork.input.setBlocking(False)
objectTracker.setDetectionLabelsToTrack([]) #all
objectTracker.setTrackerType(dai.TrackerType.ZERO_TERM_COLOR_HISTOGRAM)
objectTracker.setTrackerIdAssignmentPolicy(dai.TrackerIdAssignmentPolicy.SMALLEST_ID)
manip.initialConfig.setResize(320, 320)
manip.initialConfig.setFrameType(dai.ImgFrame.Type.BGR888p)
#link
monoL.out.link(manip.inputImage)
manip.out.link(detectionNetwork.input)
monoL.frameEvent.link(script.inputs['event'])
monoL.out.link(script.inputs['frameL'])
script.outputs['floodL'].link(manipOut.input)
if fullFrameTracking:
manip.video.link(objectTracker.inputTrackerFrame)
else:
detectionNetwork.passthrough.link(objectTracker.inputTrackerFrame)
detectionNetwork.passthrough.link(objectTracker.inputDetectionFrame)
detectionNetwork.out.link(objectTracker.inputDetections)
objectTracker.out.link(trackerOut.input)
# Connect to the device and start the Pipeline
with dai.Device(pipeline) as device:
preview = device.getOutputQueue("flood-left", 4, False)
tracklets = device.getOutputQueue(name="tracklets", maxSize=4, blocking=False)
while True:
imgFrame = preview.get()
track = tracklets.get()
print('track',track)
color = (255, 0, 0)
frame = imgFrame.getCvFrame()
trackletsData = track.tracklets
print('trackdata',trackletsData)
for t in trackletsData:
print('t',t)
roi = t.roi.denormalize(frame.shape[1], frame.shape[0])
x1 = int(roi.topLeft().x)
y1 = int(roi.topLeft().y)
x2 = int(roi.bottomRight().x)
y2 = int(roi.bottomRight().y)
try:
label = labelMap[t.label]
except:
label = t.label
cv2.putText(frame, str(label), (x1 + 10, y1 + 20), cv2.FONT_HERSHEY_TRIPLEX, 0.5, 255)
cv2.putText(frame, f"ID: {[t.id]}", (x1 + 10, y1 + 35), cv2.FONT_HERSHEY_TRIPLEX, 0.5, 255)
cv2.putText(frame, t.status.name, (x1 + 10, y1 + 50), cv2.FONT_HERSHEY_TRIPLEX, 0.5, 255)
cv2.rectangle(frame, (x1, y1), (x2, y2), color, cv2.FONT_HERSHEY_SIMPLEX)
cv2.imshow("tracker", frame)
if cv2.waitKey(1) == ord('q'):
break
The program can run but cannot recognize anything, If adding detectionNetwork.out.link(trackerOut.input),
it will show " trackletsData = track.tracklets AttributeError: 'depthai.ImgDetections' object has no attribute 'tracklets' " ,Can you help me debug