Skip to content

Commit

Permalink
Python: Avoiding 8bits overflow of 11bits depth
Browse files Browse the repository at this point in the history
In python wrapper exemples for sync interface,
11bit depth data was mapped to 8bits without shift
and overflowed.
Now displaying a 16 bit depth image and shifting
all the depth pixels 5 bits left to maximize the
dynamic range of the image.

Signed-off-by: David García Garzón <[email protected]>
  • Loading branch information
David García Garzón authored and qdot committed Dec 27, 2010
1 parent bfe28d5 commit 45f614d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion wrappers/python/demo_cv_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
while 1:
depth, timestamp = freenect.sync_get_depth()
rgb, timestamp = freenect.sync_get_video()
cv.ShowImage('Depth', depth.astype(np.uint8))

# maximize dynamic range of the given 11 bits into the used 16 bits
depth<<=(16-11)

cv.ShowImage('Depth', depth.astype(np.uint16))
cv.ShowImage('Video', rgb[:, :, ::-1].astype(np.uint8))
cv.WaitKey(10)
4 changes: 3 additions & 1 deletion wrappers/python/demo_cv_sync_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
except TypeError:
ind = 0
continue
# maximize dynamic range of the given 11 bits into the used 16 bits
depth<<=(16-11)
ind += 1
cv.ShowImage('Depth', depth.astype(np.uint8))
cv.ShowImage('Depth', depth.astype(np.uint16))
cv.ShowImage('Video', rgb[:, :, ::-1].astype(np.uint8))
cv.WaitKey(10)
freenect.sync_stop()# NOTE: May remove if you have good USB bandwidth

0 comments on commit 45f614d

Please sign in to comment.