From a55de98dffe6f6f2bd6dd6fc49d4d3ae4e3e5b9a Mon Sep 17 00:00:00 2001 From: Collin Brake Date: Mon, 24 May 2021 16:47:20 -0400 Subject: [PATCH] tweak depth preview --- examples/depth_preview.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/depth_preview.py b/examples/depth_preview.py index 351937c15..9c0de9700 100755 --- a/examples/depth_preview.py +++ b/examples/depth_preview.py @@ -44,20 +44,23 @@ # Connect to device and start pipeline with dai.Device(pipeline) as device: + device.startPipeline() + # Output queue will be used to get the disparity frames from the outputs defined above q = device.getOutputQueue(name="disparity", maxSize=4, blocking=False) while True: - inDepth = q.get() # blocking call, will wait until a new data has arrived - frame = inDepth.getFrame() - # Normalization for better visualization - frame = (frame * (255 / depth.getMaxDisparity())).astype(np.uint8) + inDepth = q.tryGet() # blocking call, will wait until a new data has arrived + if inDepth is not None: + frame = inDepth.getFrame() + # Normalization for better visualization + frame = (frame * (255 / 95)).astype(np.uint8) - cv2.imshow("disparity", frame) + cv2.imshow("disparity", frame) - # Available color maps: https://docs.opencv.org/3.4/d3/d50/group__imgproc__colormap.html - frame = cv2.applyColorMap(frame, cv2.COLORMAP_JET) - cv2.imshow("disparity_color", frame) + # Available color maps: https://docs.opencv.org/3.4/d3/d50/group__imgproc__colormap.html + frame = cv2.applyColorMap(frame, cv2.COLORMAP_JET) + cv2.imshow("disparity_color", frame) if cv2.waitKey(1) == ord('q'): break