Skip to content

Instantly share code, notes, and snippets.

Created September 23, 2016 17:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/126c50cf9233ade3c79b35e4e22f7629 to your computer and use it in GitHub Desktop.
Save anonymous/126c50cf9233ade3c79b35e4e22f7629 to your computer and use it in GitHub Desktop.
import freenect
import cv2
import numpy as np
# all credits go to http://vaaiibhav.me/openkinect-python-and-opencv/
"""
Grabs a depth map from the Kinect sensor and creates an image from it.
"""
def getDepthMap():
depth, timestamp = freenect.sync_get_depth()
np.clip(depth, 0, 2**10 - 1, depth)
depth >>= 2
depth = depth.astype(np.uint8)
return depth
while True:
depth = getDepthMap()
blur = cv2.GaussianBlur(depth, (5, 5), 0)
cv2.imshow('image', blur)
cv2.waitKey(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment