#!/bin/python from freenect import sync_get_depth as gdepth import cv2 import numpy as np def loopa(): global depth while True: (depth,_) = gdepth() npd=np.array(depth) mn=npd.min() npd[npd>1000]=1000 # Eliminate kinect artefacts, constant to be fitted manually #print(npd.max()) npd-=mn mx=npd.max() npd2=npd*(255/mx) npd=np.floor(npd2).astype(np.uint8) # Debugging histrogram START # himg=np.zeros((300,256,1)) # hst=cv2.calcHist([npd],[0],None,[256],[0,2048]) # cv2.normalize(hst,hst,0,255,cv2.NORM_MINMAX) # hst2=np.int32(np.around(hst)) # pts=np.column_stack((np.arange(256).reshape(256,1),hst2)) # cv2.polylines(himg,[pts],False,(255,0,0)) # Debugging histogram END fdepth=cv2.applyColorMap(npd,cv2.COLORMAP_JET) cv2.imshow('dpth',fdepth) #cv2.imshow('hst',himg) # Debugging histogram if cv2.waitKey(1) & 0xFF == ord('q'): break cv2.namedWindow("dpth", cv2.WND_PROP_FULLSCREEN) cv2.setWindowProperty("dpth",cv2.WND_PROP_FULLSCREEN,cv2.WINDOW_FULLSCREEN) loopa() cv2.destroyAllWindows()