Hi I am using vnc viewer to run the following code but the camera view isn't streaming is there a way to adjust this?
Code:
#!/usr/bin/python3
from depthai_sdk import OakCamera
import depthai as dai
from depthai_sdk.classes import *
import cv2 as cv
def cb2 (packet: TrackerPacket):
visualizer = packet.visualizer
visualizer.draw(packet.frame)
tframe = cv.resize(packet.frame,(720,480))
cv.imshow(packet.name, tframe)
message = packet.detections
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)
dutycycle_yaw = (-555.5333)*yaw + 71666.66667
dutycycle_pitch = 71666.67 + 1083.33 * pitch
with OakCamera() 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)
#pi.hardware_PWM(20,50,int(71666.66667))
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)