Exemplo n.º 1
0
def kill():
    [ctx, dev] = initkinect()
    cv2.destroyAllWindows()
    freenect.sync_stop()
    freenect.stop_video(dev)
    freenect.stop_depth(dev)
    freenect.close_device(dev)
    freenect.shutdown(ctx)
    quit()
Exemplo n.º 2
0
	def update_streams(self):
		if self.depth_started and not self.depth_consumers:
			logging.info("Stopping depth")
			freenect.stop_depth(self.dev)
			self.depth_started = False
		elif not self.depth_started and self.depth_consumers:
			logging.info("Starting depth")
			freenect.start_depth(self.dev)
			self.depth_started = True

		if self.video_started and not self.video_consumers:
			logging.info("Stopping video")
			freenect.stop_video(self.dev)
			self.video_started = False
		elif not self.video_started and self.video_consumers:
			logging.info("Starting video")
			freenect.start_video(self.dev)
			self.video_started = True
Exemplo n.º 3
0
    def update_streams(self):
        if self.depth_started and not self.depth_consumers:
            logging.info("Stopping depth")
            freenect.stop_depth(self.dev)
            self.depth_started = False
        elif not self.depth_started and self.depth_consumers:
            logging.info("Starting depth")
            freenect.start_depth(self.dev)
            self.depth_started = True

        if self.video_started and not self.video_consumers:
            logging.info("Stopping video")
            freenect.stop_video(self.dev)
            self.video_started = False
        elif not self.video_started and self.video_consumers:
            logging.info("Starting video")
            freenect.start_video(self.dev)
            self.video_started = True
Exemplo n.º 4
0
 def stop_depth(self):
     freenect.stop_depth(self._dev)
     self._depth_callback = None
Exemplo n.º 5
0
 def stop_depth(self):
     freenect.stop_depth(self._dev)
     self._depth_callback = None
Exemplo n.º 6
0
    cv.Resize(cv.fromarray(raw_image), cv.fromarray(image), cv.CV_INTER_AREA)
    cv.CvtColor(cv.fromarray(image), cv.fromarray(image), cv.CV_RGB2HSV)
    
    # Downsample the depth frame using nearest-neighbor to make sure 
    # invalid pixels are handled properly.
    cv.Resize(cv.fromarray(raw_depth), cv.fromarray(depth), cv.CV_INTER_NN)
    
    # Do the object recognition
    color.identify(image, constants, colors)
    global balls, yellow_walls, green_walls
    balls = blobs.find_blobs(colors, depth, color=0)
    yellow_walls = blobs.find_blobs(colors, depth, color=1, min_size=100)
    green_walls = blobs.find_blobs(colors, depth, color=2, min_size=10)

# Work around an initialization bug for synchronous image
try:
    ctx = freenect.init()
    dev = freenect.open_device(ctx, 0)
    if not dev:
        raise Exception
    freenect.start_video(dev) # sync_get_video hangs if we don't do this
    freenect.start_depth(dev) # sync_get_depth hangs if we don't do this
    freenect.stop_depth(dev)
    freenect.stop_video(dev)
    freenect.close_device(dev) # close the device so that c_sync can open it
    freenect.shutdown(ctx)
    process_frame()
    initialized = True
except:
    pass