Exemplo n.º 1
0
int freenect_sync_get_video(void **video, uint32_t *timestamp, int index, freenect_video_format fmt)
{
	if (index < 0 || index >= MAX_KINECTS) {
		printf("Error: Invalid index [%d]\n", index);
		return -1;
	}
	if (!thread_running || !kinects[index] || kinects[index]->video.fmt != fmt)
		if (setup_kinect(index, fmt, 0))
			return -1;
	sync_get(video, timestamp, &kinects[index]->video);
	return 0;
}
Exemplo n.º 2
0
int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index, freenect_depth_format fmt)
{
	if (index < 0 || index >= MAX_KINECTS) {
		printf("Error: Invalid index [%d]\n", index);
		return -1;
	}
	if (!thread_running || !kinects[index] || kinects[index]->depth.fmt != fmt)
		if (setup_kinect(index, fmt, 1))
			return -1;
	sync_get(depth, timestamp, &kinects[index]->depth);
	return 0;
}
Exemplo n.º 3
0
/* 
  Use this to make sure the runloop is locked and no one is in it. Then you can
  call arbitrary functions from libfreenect.h in a safe way. If the kinect with
  this index has not been initialized yet, then it will try to set it up. If 
  this function is successful, then you can access kinects[index]. Don't forget
  to unlock the runloop when you're done.
  
  Returns 0 if successful, nonzero if kinect[index] is unvailable
 */ 
static int runloop_enter(int index)
{
	if (index < 0 || index >= MAX_KINECTS) {
		printf("Error: Invalid index [%d]\n", index);
		return -1;
	}
	if (!thread_running || !kinects[index])
		if (setup_kinect(index, FREENECT_DEPTH_11BIT, 1))
			return -1;
		
	pending_runloop_tasks_inc();
	pthread_mutex_lock(&runloop_lock);
	return 0;
}