@@ -221,7 +221,7 @@ static void init_thread(void)
221
221
pthread_create (& thread , NULL , init , NULL );
222
222
}
223
223
224
- static int change_video_format (sync_kinect_t * kinect , freenect_resolution res , freenect_video_format fmt )
224
+ static int change_video_format_with_res (sync_kinect_t * kinect , freenect_resolution res , freenect_video_format fmt )
225
225
{
226
226
freenect_stop_video (kinect -> dev );
227
227
free_buffer_ring (& kinect -> video );
@@ -233,7 +233,12 @@ static int change_video_format(sync_kinect_t *kinect, freenect_resolution res, f
233
233
return 0 ;
234
234
}
235
235
236
- static int change_depth_format (sync_kinect_t * kinect , freenect_resolution res , freenect_depth_format fmt )
236
+ static int change_video_format (sync_kinect_t * kinect , freenect_resolution res , freenect_video_format fmt )
237
+ {
238
+ return change_video_format_with_res (kinect , FREENECT_RESOLUTION_MEDIUM , fmt );
239
+ }
240
+
241
+ static int change_depth_format_with_res (sync_kinect_t * kinect , freenect_resolution res , freenect_depth_format fmt )
237
242
{
238
243
freenect_stop_depth (kinect -> dev );
239
244
free_buffer_ring (& kinect -> depth );
@@ -245,6 +250,11 @@ static int change_depth_format(sync_kinect_t *kinect, freenect_resolution res, f
245
250
return 0 ;
246
251
}
247
252
253
+ static int change_depth_format (sync_kinect_t * kinect , freenect_resolution res , freenect_depth_format fmt )
254
+ {
255
+ return change_depth_format_with_res (kinect , FREENECT_RESOLUTION_MEDIUM , fmt );
256
+ }
257
+
248
258
static sync_kinect_t * alloc_kinect (int index )
249
259
{
250
260
sync_kinect_t * kinect = (sync_kinect_t * )malloc (sizeof (sync_kinect_t ));
@@ -270,7 +280,7 @@ static sync_kinect_t *alloc_kinect(int index)
270
280
return kinect ;
271
281
}
272
282
273
- static int setup_kinect (int index , int res , int fmt , int is_depth )
283
+ static int setup_kinect_with_res (int index , int res , int fmt , int is_depth )
274
284
{
275
285
pending_runloop_tasks_inc ();
276
286
pthread_mutex_lock (& runloop_lock );
@@ -303,16 +313,20 @@ static int setup_kinect(int index, int res, int fmt, int is_depth)
303
313
pthread_mutex_lock (& buf -> lock );
304
314
if ((buf -> fmt != fmt ) || (buf -> res != res )) {
305
315
if (is_depth )
306
- change_depth_format (kinects [index ], (freenect_resolution )res , (freenect_depth_format )fmt );
316
+ change_depth_format_with_res (kinects [index ], (freenect_resolution )res , (freenect_depth_format )fmt );
307
317
else
308
- change_video_format (kinects [index ], (freenect_resolution )res , (freenect_video_format )fmt );
318
+ change_video_format_with_res (kinects [index ], (freenect_resolution )res , (freenect_video_format )fmt );
309
319
}
310
320
pthread_mutex_unlock (& buf -> lock );
311
321
pthread_mutex_unlock (& runloop_lock );
312
322
pending_runloop_tasks_dec ();
313
323
return 0 ;
314
324
}
315
325
326
+ static int setup_kinect (int index , int fmt , int is_depth ) {
327
+ return setup_kinect_with_res (index , FREENECT_RESOLUTION_MEDIUM , fmt , is_depth );
328
+ }
329
+
316
330
static int sync_get (void * * data , uint32_t * timestamp , buffer_ring_t * buf )
317
331
{
318
332
pthread_mutex_lock (& buf -> lock );
@@ -345,7 +359,7 @@ static int runloop_enter(int index)
345
359
return -1 ;
346
360
}
347
361
if (!thread_running || !kinects [index ])
348
- if (setup_kinect (index , FREENECT_RESOLUTION_MEDIUM , FREENECT_DEPTH_11BIT , 1 ))
362
+ if (setup_kinect_with_res (index , FREENECT_RESOLUTION_MEDIUM , FREENECT_DEPTH_11BIT , 1 ))
349
363
return -1 ;
350
364
351
365
pending_runloop_tasks_inc ();
@@ -359,7 +373,7 @@ static void runloop_exit()
359
373
pending_runloop_tasks_dec ();
360
374
}
361
375
362
- int freenect_sync_get_video (void * * video , uint32_t * timestamp , int index ,
376
+ int freenect_sync_get_video_with_res (void * * video , uint32_t * timestamp , int index ,
363
377
freenect_resolution res , freenect_video_format fmt )
364
378
{
365
379
if (index < 0 || index >= MAX_KINECTS ) {
@@ -368,13 +382,18 @@ int freenect_sync_get_video(void **video, uint32_t *timestamp, int index,
368
382
}
369
383
if (!thread_running || !kinects [index ] || kinects [index ]-> video .fmt != fmt
370
384
|| kinects [index ]-> video .res != res )
371
- if (setup_kinect (index , res , fmt , 0 ))
385
+ if (setup_kinect_with_res (index , res , fmt , 0 ))
372
386
return -1 ;
373
387
sync_get (video , timestamp , & kinects [index ]-> video );
374
388
return 0 ;
375
389
}
376
390
377
- int freenect_sync_get_depth (void * * depth , uint32_t * timestamp , int index ,
391
+ int freenect_sync_get_video (void * * video , uint32_t * timestamp , int index , freenect_video_format fmt )
392
+ {
393
+ return freenect_sync_get_video_with_res (video , timestamp , index , FREENECT_RESOLUTION_MEDIUM , fmt );
394
+ }
395
+
396
+ int freenect_sync_get_depth_with_res (void * * depth , uint32_t * timestamp , int index ,
378
397
freenect_resolution res , freenect_depth_format fmt )
379
398
{
380
399
if (index < 0 || index >= MAX_KINECTS ) {
@@ -383,12 +402,17 @@ int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index,
383
402
}
384
403
if (!thread_running || !kinects [index ] || kinects [index ]-> depth .fmt != fmt
385
404
|| kinects [index ]-> depth .res != res )
386
- if (setup_kinect (index , res , fmt , 1 ))
405
+ if (setup_kinect_with_res (index , res , fmt , 1 ))
387
406
return -1 ;
388
407
sync_get (depth , timestamp , & kinects [index ]-> depth );
389
408
return 0 ;
390
409
}
391
410
411
+ int freenect_sync_get_depth (void * * depth , uint32_t * timestamp , int index , freenect_depth_format fmt )
412
+ {
413
+ return freenect_sync_get_depth_with_res (depth , timestamp , index , FREENECT_RESOLUTION_MEDIUM , fmt );
414
+ }
415
+
392
416
int freenect_sync_get_tilt_state (freenect_raw_tilt_state * * state , int index )
393
417
{
394
418
if (runloop_enter (index )) return -1 ;
0 commit comments