with our Bootloader 0.0.28 which is the newest , and our Script
import depthai as dai
import cv2
import time
\# ----------------------------
\# MODEL
\# ----------------------------
model = dai.NNModelDescription("yolov6-nano")
\# COCO labels (80 classes)
labels = [
"person","bicycle","car","motorcycle","airplane","bus","train","truck","boat",
"traffic light","fire hydrant","stop sign","parking meter","bench","bird","cat",
"dog","horse","sheep","cow","elephant","bear","zebra","giraffe","backpack",
"umbrella","handbag","tie","suitcase","frisbee","skis","snowboard","sports ball",
"kite","baseball bat","baseball glove","skateboard","surfboard","tennis racket",
"bottle","wine glass","cup","fork","knife","spoon","bowl","banana","apple",
"sandwich","orange","broccoli","carrot","hot dog","pizza","donut","cake","chair",
"couch","potted plant","bed","dining table","toilet","tv","laptop","mouse",
"remote","keyboard","cell phone","microwave","oven","toaster","sink",
"refrigerator","book","clock","vase","scissors","teddy bear","hair drier",
"toothbrush"
]
\# ----------------------------
\# PIPELINE
\# ----------------------------
pipeline = dai.Pipeline()
\# RGB camera
camRgb = pipeline.create(dai.node.Camera).build(
dai.CameraBoardSocket.CAM_A
)
\# Mono cameras
monoLeft = pipeline.create(dai.node.Camera).build(
dai.CameraBoardSocket.CAM_B
)
monoRight = pipeline.create(dai.node.Camera).build(
dai.CameraBoardSocket.CAM_C
)
\# Stereo depth
stereo = pipeline.create(dai.node.StereoDepth).build(
monoLeft.requestOutput((640, 400)),
monoRight.requestOutput((640, 400))
)
\# Spatial Detection Network
spatialNN = pipeline.create(dai.node.SpatialDetectionNetwork).build(
camRgb,
stereo,
model,
fps=10,
resizeMode=dai.ImgResizeMode.CROP
)
\# RGB output
rgbQueue = camRgb.requestOutput((640, 352)).createOutputQueue()
\# Detection output
detQueue = spatialNN.out.createOutputQueue()
\# ----------------------------
\# RUN
\# ----------------------------
\# RUN
with dai.Device() as device:
device.startPipeline(pipeline)
print("Device started")
startTime = time.time()
counter = 0
fps = 0
while True:
frame = rgbQueue.get().getCvFrame()
detections = detQueue.get().detections
counter += 1
if time.time() - startTime > 1:
fps = counter / (time.time() - startTime)
counter = 0
startTime = time.time()
h, w = frame.shape[:2]
for det in detections:
x1 = int(det.xmin \* w)
y1 = int(det.ymin \* h)
x2 = int(det.xmax \* w)
y2 = int(det.ymax \* h)
label = labels[det.label] if det.label < len(labels) else str(det.label)
x = det.spatialCoordinates.x / 1000
y = det.spatialCoordinates.y / 1000
z = det.spatialCoordinates.z / 1000
cv2.rectangle(frame, (x1,y1), (x2,y2), (255,0,0), 2)
cv2.putText(frame,
f"{label} {det.confidence:.0%}",
(x1, y1-10),
cv2.FONT_HERSHEY_SIMPLEX,
0\.5,
(255,255,255),
2)
cv2.putText(frame,
f"X:{x:.2f} Y:{y:.2f} Z:{z:.2f}m",
(x1, y1+15),
cv2.FONT_HERSHEY_SIMPLEX,
0\.5,
(0,255,0),
2)
cv2.putText(frame,
f"FPS: {fps:.1f}",
(20,30),
cv2.FONT_HERSHEY_SIMPLEX,
1,
(0,0,255),
2)
cv2.imshow("OAK-D LR YOLOv6 Spatial", frame)
if cv2.waitKey(1) == ord('q'):
break
cv2.destroyAllWindows()
we get the error of bootloader RuntimeError: Insufficient permissions to communicate with X_LINK_BOOTED device with name "0.1". Make sure udev rules are set. Error: X_LINK_INSUFFICIENT_PERMISSIONS when we tried to use Depthai v3 , it's possible that our cam doesn't run with any Version above 2.29.0