Hi after updating the depthai-sdk I got the following error:
pi@luxonis:~ $ python3 latest\ code/cameratest.py
[2024-01-02 18:49:40] INFO [root.__init__:118] Setting IR laser dot projector brightness to 800mA
[18443010B1A6980F00] [1.1.1] [1.850] [SpatialDetectionNetwork(9)] [warning] Network compiled for 6 shaves, maximum available 11, compiling for 5 shaves likely will yield in better performance
[2024-01-02 18:49:41] INFO [root.close:456] Closing OAK camera
Traceback (most recent call last):
File "/home/pi/latest code/cameratest.py", line 59, in <module>
oak.start(blocking=True)
File "/home/pi/.local/lib/python3.9/site-packages/depthai_sdk/oak_camera.py", line 521, in start
self.poll()
File "/home/pi/.local/lib/python3.9/site-packages/depthai_sdk/oak_camera.py", line 558, in poll
poll() # Poll all callbacks
File "/home/pi/.local/lib/python3.9/site-packages/depthai_sdk/classes/packet_handlers.py", line 79, in _poll
self.new_packet(packet)
File "/home/pi/.local/lib/python3.9/site-packages/depthai_sdk/classes/packet_handlers.py", line 167, in new_packet
self.callback(packet)
File "/home/pi/latest code/cameratest.py", line 13, in cb2
message = packet.detections
AttributeError: 'TrackerPacket' object has no attribute 'detections'
Sentry is attempting to send 2 pending error messages
Waiting up to 2 seconds
Press Ctrl-C to quit
The pip show depthai-sdk shows the following version:
pi@luxonis:~ $ pip3 show depthai
Name: depthai
Version: 2.22.0.0
Summary: DepthAI Python Library
Home-page: https://github.com/luxonis/depthai-python
Author: Luxonis
Author-email: support@luxonis.com
License: MIT
Location: /home/pi/.local/lib/python3.9/site-packages
Requires:
Required-by: depthai-sdk
pi@luxonis:~ $ pip3 show depthai-sdk
Name: depthai-sdk
Version: 1.13.1
Summary: This package provides an abstraction of the DepthAI API library.
Home-page: https://github.com/luxonis/depthai/tree/main/depthai_sdk
Author: Luxonis
Author-email: support@luxonis.com
License: MIT
Location: /home/pi/.local/lib/python3.9/site-packages
Editable project location: /home/pi/.local/lib/python3.9/site-packages
Requires: ahrs, blobconverter, depthai, depthai-pipeline-graph, marshmallow, numpy, opencv-contrib-python, pytube, PyTurboJPEG, sentry-sdk, xmltodict
Required-by:
pi@luxonis:~ $
If I change in my code from detections to tracklets in the line message = packet.tracklets
, the camera is not launched at all nothing is executed after that:
#!/usr/bin/python3
from depthai_sdk import OakCamera
import depthai as dai
from depthai_sdk.classes import *
import cv2 as cv
import numpy as np
def cb2 (packet: TrackerPacket):
#GPIO.output(relaypin, not GPIO.input(27)) # read the inverse value of input
visualizer = packet.visualizer
visualizer.draw(packet.frame)
tframe = cv.resize(packet.frame,(720,480))
cv.imshow(packet.name, tframe)
message = packet.tracklets
z_disp = (4.547 *25.4)/1000
#t_vect = np.array([[0],[0],[0],[1]])
#H_mat = np.concatenate((rotation_x,t_vect),axis = 1)
for m in message:
x_obj, y_obj, z_obj = m.tracklet.spatialCoordinates.x, m.tracklet.spatialCoordinates.y, m.tracklet.spatialCoordinates.z
#t_camera = np.array([[x_obj],[y_obj],[z_obj],[1]])
#t_rotated = H_mat @ t_camera
#print("x = ", t_rotated[0][0],"y = ", t_rotated[1][0],"z = ", t_rotated[2][0])
#t_rotated_ = rotation_matrix @ t_rotated
#x, y, z = t_rotated_[0][0], t_rotated_[1][0], t_rotated_[2][0]
#print("x = ", x_obj,"y = ", y_obj,"z = ", z_obj,"frame shape=",packet.frame.shape)
yaw = np.degrees(np.arctan2(x_obj , z_obj))
pitch = np.degrees(np.arctan2(y_obj+z_disp,np.sqrt(x_obj**2 + z_obj**2)))
print("yaw = ", yaw, "pitch = ", pitch, "z_dist = ", z_obj)
while True:
#GPIO.output(relaypin, not GPIO.input(27)) # read the inverse value of input
with OakCamera(usb_speed='usb2') as oak:
color = oak.create_camera('color')
# List of models that are supported out-of-the-box by the SDK:
# https://docs.luxonis.com/projects/sdk/en/latest/features/ai_models/#sdk-supported-models
nn = oak.create_nn('yolov8n_coco_640x352', color, tracker=True, spatial=True)
nn.config_nn(resize_mode='stretch')
nn.config_tracker(
tracker_type=dai.TrackerType.ZERO_TERM_COLOR_HISTOGRAM,
track_labels=[0], # Track only 1st object from the object map. If unspecified, track all object types
# track_labels=['person'] # Track only people (for coco datasets, person is 1st object in the map)
assignment_policy=dai.TrackerIdAssignmentPolicy.SMALLEST_ID,
max_obj=1, # Max objects to track, which can improve performance
threshold=0.1 # Tracker threshold
)
nn.config_spatial(
bb_scale_factor=0.3, # Scaling bounding box before averaging the depth in that ROI
lower_threshold=500, # Discard depth points below 30cm
upper_threshold=8000, # Discard depth pints above 10m
# Average depth points before calculating X and Y spatial coordinates:
calc_algo=dai.SpatialLocationCalculatorAlgorithm.AVERAGE
)
#oak.visualize([nn.out.tracker], fps=True)
oak.visualize ([nn.out.tracker], callback=cb2)
#oak.visualize([nn.out.spatials], fps=True)
#oak.callback([nn.out.spatials], callback=cb)
#oak.visualize(nn.out.passthrough)
oak.start(blocking=True)
And later after freezing for 10-20 mins it shows this error, In the earlier version of the code and another raspberry pi image the packet.detections
worked but now it shows an error that it doesn't exist and the packet.tracklets
thing doesn't work, here's the error which I get while using tracklets
pi@luxonis:~/latest code $ python3 cameratest.py
[2024-01-02 18:58:29] INFO [root.__init__:118] Setting IR laser dot projector brightness to 800mA
[18443010B1A6980F00] [1.1.1] [2.024] [SpatialDetectionNetwork(9)] [warning] Network compiled for 6 shaves, maximum available 11, compiling for 5 shaves likely will yield in better performance
[2024-01-02 19:09:47] INFO [root.close:456] Closing OAK camera
Traceback (most recent call last):
File "/home/pi/latest code/cameratest.py", line 61, in <module>
oak.start(blocking=True)
File "/home/pi/.local/lib/python3.9/site-packages/depthai_sdk/oak_camera.py", line 521, in start
self.poll()
File "/home/pi/.local/lib/python3.9/site-packages/depthai_sdk/oak_camera.py", line 558, in poll
poll() # Poll all callbacks
File "/home/pi/.local/lib/python3.9/site-packages/depthai_sdk/classes/packet_handlers.py", line 79, in _poll
self.new_packet(packet)
File "/home/pi/.local/lib/python3.9/site-packages/depthai_sdk/classes/packet_handlers.py", line 167, in new_packet
self.callback(packet)
File "/home/pi/latest code/cameratest.py", line 20, in cb2
x_obj, y_obj, z_obj = m.tracklet.spatialCoordinates.x, m.tracklet.spatialCoordinates.y, m.tracklet.spatialCoordinates.z
AttributeError: 'int' object has no attribute 'tracklet'
Sentry is attempting to send 2 pending error messages
Waiting up to 2 seconds
Press Ctrl-C to quit