Пример #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()
Пример #2
0
    def body_callback(self, dev, ctx):
        # _set_led hackery is required because for some reason calling set_led
        # from update loop hangs the process
        if self._set_led:
            freenect.set_led(dev, self._set_led)
            self._set_led = None

        if self._set_video is not None:
            freenect.stop_video(dev)
            freenect.set_video_mode(dev, freenect.RESOLUTION_MEDIUM,
                                    self._set_video)
            freenect.start_video(dev)
            self._set_video = None

        if self._last_setting_check + self.settings_delay < time.time():
            self.load_settings()
            self._last_setting_check = time.time()
Пример #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
Пример #4
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
Пример #5
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