Skip to content

Commit

Permalink
tweak depth preview
Browse files Browse the repository at this point in the history
  • Loading branch information
collinbrake committed May 24, 2021
1 parent b1504d6 commit a55de98
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions examples/depth_preview.py
Expand Up @@ -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

0 comments on commit a55de98

Please sign in to comment.