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)

    Hi DarshitDesai
    Do depthai-python examples work? What does echo $DISPLAY print? SDK will automatically run OpenCV when on RPI.

    Thanks,
    Jaka

      jakaskerl I will check that out and send back the output of echo $DISPLAY

      What I wanted to say was I get the object positions while running the above code, only open cv window doesn't open.

      This only happens in VNC mode, when I connect a separate physical monitor to the pi directly the opencv window works

      @jakaskerl I see the below thing when I do echo $DISPLAY

      Edit: When I run an example depth ai python code it works, in my code it is not working, what could be the issue?

      Hi @DarshitDesai
      I remember older versions of SDK having issues displaying the windows. Which version are you running? If below 1.12, try upgrading, see if it fixes the issue.

      Thanks,
      Jaka

        jakaskerl version details of sdk

        pi@luxonis:~/latest code $ pip show depthai-sdk

        Name: depthai-sdk

        Version: 1.12.1

        Summary: This package provides an abstraction of the DepthAI API library.

        Home-page: luxonis/depthaitree/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: blobconverter, depthai, depthai-pipeline-graph, marshmallow, numpy, opencv-contrib-python, pytube, PyTurboJPEG, sentry-sdk, xmltodict

        Required-by:

        Hi @DarshitDesai
        That's fine then. I also tested your script on the RPI4 with 64bit luxonis image. The windows work fine, so it likely has something to do with your OS configuration.

        Thanks,
        Jaka

        I both hope this is a fix and for your sanity hope it isn't...

        In this line, you have a space between visualize and ([...
        oak.visualize ([nn.out.tracker], callback=cb2)

        Python is an odd beast and this may be acceptable to it without throwing an error, it's worth removing the space to be certain either way though.