コード例 #1
0
ファイル: jeffnect.py プロジェクト: krayon/kinect-punchcraft

def close(event, x, y, flags, param):
    if event == cv.CV_EVENT_LBUTTONDOWN:
        freenect.sync_stop()
        sys.exit()


color = (100, 255, 100)
cv.NamedWindow('Depth')
cv.SetMouseCallback('Depth', close, param=None)
depthThreshold = Threshold(0)
cv.CreateTrackbar('Depth Threshold', 'Depth', 0, 1200, depthThreshold)
depth_history = []
while 1:
    depth, dts = freenect.sync_get_depth_np()
    #rgb, rts = freenect.sync_get_rgb_np()
    depth = ((depth <= depthThreshold.p).astype(np.uint8) * depth).astype(
        np.uint16)
    dP = Points(np.argwhere(depth != 0))
    avg_dep = 0
    #depth = depth.astype(np.uint8)
    if dP.points.any():
        # Average of the depth values that meet threshold
        depth_values = depth[depth != 0]
        avg_dep = sum(depth_values) / len(depth_values)
        #if len(depth_history) == 5:
        depth = array2cv(depth.astype(np.uint8))
        bound_Rect = dP.boundingBox()
        cv.Rectangle(depth, bound_Rect[0], bound_Rect[1], color, thickness=3)
        #cv.PutText(detph, str(avg_dep), (50,50), ,
コード例 #2
0
ファイル: jeffnect.py プロジェクト: jhsu/punchcraft

def close(event, x, y, flags, param):
    if event == cv.CV_EVENT_LBUTTONDOWN:
        freenect.sync_stop()
        sys.exit()


color = (100,255, 100)
cv.NamedWindow('Depth')
cv.SetMouseCallback('Depth', close, param=None)
depthThreshold = Threshold(0)
cv.CreateTrackbar('Depth Threshold', 'Depth', 0, 1200, depthThreshold)
depth_history = []
while 1:
    depth, dts = freenect.sync_get_depth_np()
    #rgb, rts = freenect.sync_get_rgb_np()
    depth = ((depth <= depthThreshold.p).astype(np.uint8)*depth).astype(np.uint16)
    dP = Points(np.argwhere(depth!=0))
    avg_dep=0
        #depth = depth.astype(np.uint8)
    if dP.points.any():
        # Average of the depth values that meet threshold
        depth_values =depth[depth != 0]
        avg_dep=sum(depth_values)/len(depth_values)
        #if len(depth_history) == 5:
        depth = array2cv(depth.astype(np.uint8))
        bound_Rect = dP.boundingBox()
        cv.Rectangle(depth, bound_Rect[0], bound_Rect[1], color, thickness=3)
        #cv.PutText(detph, str(avg_dep), (50,50), ,  
        cv.Circle(depth, dP.calculateCenter(), 48, color)
コード例 #3
0
from queue import *
#from arrayfilter import *

DEFAULT_THRESHOLD = 640
COLOR = (100, 255, 100)

depthThreshold = Threshold(DEFAULT_THRESHOLD)

cv.NamedWindow('Depth')
cv.CreateTrackbar('Threshold', 'Depth', DEFAULT_THRESHOLD, 1200,
                  depthThreshold)

mouse_control = MouseControl(320, 240)
depth_values_queue = Queue(40)
while 1:
    depth, timestamp = freenect.sync_get_depth_np()
    depth = depth[::2, ::2]
    #depth = gaussian(depth)
    threshold_depths = ((depth <= depthThreshold.level).astype(np.uint8) *
                        depth).astype(np.uint16)
    depth_points = Points(np.argwhere(threshold_depths != 0))

    if depth_points.points.any():

        threshold_depths = array2cv(threshold_depths.astype(np.uint8))
        bound_rect = depth_points.boundingBox()
        cv.Rectangle(threshold_depths,
                     bound_rect[0],
                     bound_rect[1],
                     COLOR,
                     thickness=3)
コード例 #4
0
ファイル: demo_cv_sync.py プロジェクト: Aspe/libfreenect
#!/usr/bin/env python
import freenect
import cv
import numpy as np

cv.NamedWindow('Depth')
cv.NamedWindow('RGB')

while 1:
    depth, timestamp = freenect.sync_get_depth_np()
    rgb, timestamp = freenect.sync_get_rgb_np()
    cv.ShowImage('Depth', depth.astype(np.uint8))
    cv.ShowImage('RGB', rgb.astype(np.uint8))
    cv.WaitKey(10)
コード例 #5
0
#!/usr/bin/env python
import freenect
import matplotlib.pyplot as mp

mp.ion()
mp.figure(1)
image_depth = mp.imshow(freenect.sync_get_depth_np()[0], interpolation="nearest", animated=True)
mp.figure(2)
image_rgb = mp.imshow(freenect.sync_get_rgb_np()[0], interpolation="nearest", animated=True)

while 1:
    mp.figure(1)
    image_depth.set_data(freenect.sync_get_depth_np()[0])
    mp.figure(2)
    image_rgb.set_data(freenect.sync_get_rgb_np()[0])
    mp.draw()
コード例 #6
0
import freenect


while 1:
    a, t0 = freenect.sync_get_depth_np()
    b, t1 = freenect.sync_get_rgb_np()
    print(t0, t1)