demo_cv_thresh_sweep.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 """Sweeps throught the depth image showing 100 range at a time"""
3 import freenect
4 import cv
5 import numpy as np
6 import time
7 
8 cv.NamedWindow('Depth')
9 
10 
11 def disp_thresh(lower, upper):
12  depth, timestamp = freenect.sync_get_depth()
13  depth = 255 * np.logical_and(depth > lower, depth < upper)
14  depth = depth.astype(np.uint8)
15  image = cv.CreateImageHeader((depth.shape[1], depth.shape[0]),
16  cv.IPL_DEPTH_8U,
17  1)
18  cv.SetData(image, depth.tostring(),
19  depth.dtype.itemsize * depth.shape[1])
20  cv.ShowImage('Depth', image)
21  cv.WaitKey(10)
22 
23 
24 lower = 0
25 upper = 100
26 max_upper = 2048
27 while upper < max_upper:
28  print('%d < depth < %d' % (lower, upper))
29  disp_thresh(lower, upper)
30  time.sleep(.1)
31  lower += 20
32  upper += 20
def disp_thresh(lower, upper)


libfreenect
Author(s): Hector Martin, Josh Blake, Kyle Machulis, OpenKinect community
autogenerated on Mon Jun 10 2019 13:46:42