Hi,
thanks for the reply.
This is an example which lead to the warning:
import time
import depthai as dai
def resize_image(pipe, image, image_width, image_height, KeepAspectRatio=False):
manip = pipe.create(dai.node.ImageManip)
manip.initialConfig.setOutputSize(image_width, image_height, dai.ImageManipConfig.ResizeMode.NONE if KeepAspectRatio else dai.ImageManipConfig.ResizeMode.STRETCH )
image.link(manip.inputImage)
return manip
def rotate_image(pipe, image, angle=0):
manip = pipe.create(dai.node.ImageManip)
manip.initialConfig.addRotateDeg(angle)
image.link(manip.inputImage)
return manip
device_info = dai.Device.getFirstAvailableDevice()
pipeline = dai.Pipeline()
fps = 15
camRgb = pipeline.create(dai.node.Camera).build(boardSocket=dai.CameraBoardSocket.CAM_A, sensorFps=fps)
preview = camRgb.requestOutput((int(300 * 1.6), 300), type=dai.ImgFrame.Type.BGR888p)
rgbCamSocket = dai.CameraBoardSocket.CAM_A
monoLeft = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_B, sensorFps=fps)
monoRight = pipeline.create(dai.node.Camera).build(dai.CameraBoardSocket.CAM_C, sensorFps=fps)
depth = pipeline.create(dai.node.StereoDepth)
mono_width = 640
mono_height = 400
monoLeftOut = monoLeft.requestOutput((mono_width, mono_height), type=dai.ImgFrame.Type.NV12)
monoRightOut = monoRight.requestOutput((mono_width, mono_height),type=dai.ImgFrame.Type.NV12)
depth.setDepthAlign(dai.CameraBoardSocket.CAM_A)
depth.setDefaultProfilePreset(dai.node.StereoDepth.PresetMode.HIGH_DETAIL)
depth.setOutputSize(mono_width, mono_height)
depth.setLeftRightCheck(True)
depth.setExtendedDisparity(True)
depth.setSubpixel(False)
monoLeftOut.link(depth.left)
monoRightOut.link(depth.right)
depth.setDefaultProfilePreset(dai.node.StereoDepth.PresetMode.HIGH_DETAIL)
depth.setDepthAlign(dai.CameraBoardSocket.CAM_A)
image_width, image_height = (300,300)
resized_rgb = resize_image(pipeline, preview, image_width, image_width)
resized_rotated_rgb = rotate_image(pipeline, resized_rgb.out, angle=270)
resized_stereo = resize_image(pipeline, depth.depth, 320, 320)
rotated_stereo = rotate_image(
pipeline, resized_stereo.out, angle=270
)
modelDescription = dai.NNModelDescription("mobilenet-ssd")
spatialDetectionNetwork = pipeline.create(dai.node.SpatialDetectionNetwork).build(camRgb, depth, modelDescription, fps=fps)
nn_path = "blobs/mobilenet-ssd_openvino_2021.4_6shave.blob"
spatialDetectionNetwork.setBlobPath(nn_path)
spatialDetectionNetwork.setConfidenceThreshold(0.5)
spatialDetectionNetwork.input.setBlocking(False)
spatialDetectionNetwork.setBoundingBoxScaleFactor(0.5)
spatialDetectionNetwork.setSpatialCalculationAlgorithm(dai.SpatialLocationCalculatorAlgorithm.MEDIAN)
spatialDetectionNetwork.setDepthLowerThreshold(100)
spatialDetectionNetwork.setDepthUpperThreshold(5000)
objectTracker = pipeline.create(dai.node.ObjectTracker)
objectTracker.setDetectionLabelsToTrack([15]) # track only person
objectTracker.setTrackerType(dai.TrackerType.ZERO_TERM_COLOR_HISTOGRAM)
objectTracker.setTrackerIdAssignmentPolicy(dai.TrackerIdAssignmentPolicy.UNIQUE_ID)
resized_rotated_rgb.out.link(spatialDetectionNetwork.input)
spatialDetectionNetwork.passthrough.link(objectTracker.inputTrackerFrame)
spatialDetectionNetwork.passthrough.link(objectTracker.inputDetectionFrame)
spatialDetectionNetwork.out.link(objectTracker.inputDetections)
rotated_stereo.out.link(spatialDetectionNetwork.inputDepth)
tracklets_queue = objectTracker.out.createOutputQueue()
pipeline.start()
while pipeline.isRunning():
try:
while True:
det_pck = tracklets_queue.get()
time.sleep(0.01)
except Exception as e:
print(f"Error in main loop: {e}")````
Maybe the approach is the issue, but how do I correctly rotate the image before passing it to a NN?
Thanks,
Lukas