Skip to content

Commit 36eae29

Browse files
mcteomcteo
mcteo
authored andcommitted
Changed the names of the modified functions, and added wrapper functions (under original names) that maintain backwards compatibilty, and functionality
Signed-off-by: Thomas Dunne <[email protected]>
1 parent ae32bfb commit 36eae29

File tree

4 files changed

+56
-18
lines changed

4 files changed

+56
-18
lines changed

examples/glpclview.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ void DrawGLScene()
117117
short *depth = 0;
118118
char *rgb = 0;
119119
uint32_t ts;
120-
if (freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT) < 0)
120+
if (freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_DEPTH_11BIT) < 0)
121121
no_kinect_quit();
122-
if (freenect_sync_get_video((void**)&rgb, &ts, 0, FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB) < 0)
122+
if (freenect_sync_get_video((void**)&rgb, &ts, 0, FREENECT_VIDEO_RGB) < 0)
123123
no_kinect_quit();
124124

125125
static unsigned int indices[480][640];

examples/regtest.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,31 +67,31 @@ int main(void)
6767
FILE *fp;
6868
int ret;
6969

70-
ret = freenect_sync_get_video((void**)&rgb, &ts, 0, FREENECT_RESOLUTION_MEDIUM, FREENECT_VIDEO_RGB);
70+
ret = freenect_sync_get_video((void**)&rgb, &ts, 0, FREENECT_VIDEO_RGB);
7171
if (ret < 0)
7272
no_kinect_quit();
7373

7474
fp = open_dump("registration_test_rgb.ppm");
7575
dump_rgb(fp, rgb, 640, 480);
7676
fclose(fp);
7777

78-
ret = freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_11BIT);
78+
ret = freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_DEPTH_11BIT);
7979
if (ret < 0)
8080
no_kinect_quit();
8181

8282
fp = open_dump("registration_test_depth_raw.pgm");
8383
dump_depth(fp, depth, 640, 480);
8484
fclose(fp);
8585

86-
ret = freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_REGISTERED);
86+
ret = freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_DEPTH_REGISTERED);
8787
if (ret < 0)
8888
no_kinect_quit();
8989

9090
fp = open_dump("registration_test_depth_registered.pgm");
9191
dump_depth(fp, depth, 640, 480);
9292
fclose(fp);
9393

94-
ret = freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_RESOLUTION_MEDIUM, FREENECT_DEPTH_MM);
94+
ret = freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_DEPTH_MM);
9595
if (ret < 0)
9696
no_kinect_quit();
9797

wrappers/c_sync/libfreenect_sync.c

+34-10
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ static void init_thread(void)
221221
pthread_create(&thread, NULL, init, NULL);
222222
}
223223

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)
225225
{
226226
freenect_stop_video(kinect->dev);
227227
free_buffer_ring(&kinect->video);
@@ -233,7 +233,12 @@ static int change_video_format(sync_kinect_t *kinect, freenect_resolution res, f
233233
return 0;
234234
}
235235

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)
237242
{
238243
freenect_stop_depth(kinect->dev);
239244
free_buffer_ring(&kinect->depth);
@@ -245,6 +250,11 @@ static int change_depth_format(sync_kinect_t *kinect, freenect_resolution res, f
245250
return 0;
246251
}
247252

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+
248258
static sync_kinect_t *alloc_kinect(int index)
249259
{
250260
sync_kinect_t *kinect = (sync_kinect_t*)malloc(sizeof(sync_kinect_t));
@@ -270,7 +280,7 @@ static sync_kinect_t *alloc_kinect(int index)
270280
return kinect;
271281
}
272282

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)
274284
{
275285
pending_runloop_tasks_inc();
276286
pthread_mutex_lock(&runloop_lock);
@@ -303,16 +313,20 @@ static int setup_kinect(int index, int res, int fmt, int is_depth)
303313
pthread_mutex_lock(&buf->lock);
304314
if ((buf->fmt != fmt) || (buf->res != res)) {
305315
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);
307317
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);
309319
}
310320
pthread_mutex_unlock(&buf->lock);
311321
pthread_mutex_unlock(&runloop_lock);
312322
pending_runloop_tasks_dec();
313323
return 0;
314324
}
315325

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+
316330
static int sync_get(void **data, uint32_t *timestamp, buffer_ring_t *buf)
317331
{
318332
pthread_mutex_lock(&buf->lock);
@@ -345,7 +359,7 @@ static int runloop_enter(int index)
345359
return -1;
346360
}
347361
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))
349363
return -1;
350364

351365
pending_runloop_tasks_inc();
@@ -359,7 +373,7 @@ static void runloop_exit()
359373
pending_runloop_tasks_dec();
360374
}
361375

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,
363377
freenect_resolution res, freenect_video_format fmt)
364378
{
365379
if (index < 0 || index >= MAX_KINECTS) {
@@ -368,13 +382,18 @@ int freenect_sync_get_video(void **video, uint32_t *timestamp, int index,
368382
}
369383
if (!thread_running || !kinects[index] || kinects[index]->video.fmt != fmt
370384
|| kinects[index]->video.res != res)
371-
if (setup_kinect(index, res, fmt, 0))
385+
if (setup_kinect_with_res(index, res, fmt, 0))
372386
return -1;
373387
sync_get(video, timestamp, &kinects[index]->video);
374388
return 0;
375389
}
376390

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,
378397
freenect_resolution res, freenect_depth_format fmt)
379398
{
380399
if (index < 0 || index >= MAX_KINECTS) {
@@ -383,12 +402,17 @@ int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index,
383402
}
384403
if (!thread_running || !kinects[index] || kinects[index]->depth.fmt != fmt
385404
|| kinects[index]->depth.res != res)
386-
if (setup_kinect(index, res, fmt, 1))
405+
if (setup_kinect_with_res(index, res, fmt, 1))
387406
return -1;
388407
sync_get(depth, timestamp, &kinects[index]->depth);
389408
return 0;
390409
}
391410

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+
392416
int freenect_sync_get_tilt_state(freenect_raw_tilt_state **state, int index)
393417
{
394418
if (runloop_enter(index)) return -1;

wrappers/c_sync/libfreenect_sync.h

+16-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
extern "C" {
3434
#endif
3535

36-
int freenect_sync_get_video(void **video, uint32_t *timestamp, int index,
36+
int freenect_sync_get_video_with_res(void **video, uint32_t *timestamp, int index,
3737
freenect_resolution res, freenect_video_format fmt);
3838
/* Synchronous video function, starts the runloop if it isn't running
3939
@@ -44,13 +44,20 @@ int freenect_sync_get_video(void **video, uint32_t *timestamp, int index,
4444
video: Populated with a pointer to a video buffer with a size of the requested type
4545
timestamp: Populated with the associated timestamp
4646
index: Device index (0 is the first)
47+
res: Valid resolution
4748
fmt: Valid format
4849
4950
Returns:
5051
Nonzero on error.
5152
*/
5253

53-
int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index,
54+
int freenect_sync_get_video(void **video, uint32_t *timestamp, int index, freenect_video_format fmt);
55+
/* Does the exact same as above, but with a default resolution,
56+
so backwards compatibilty is maintained.
57+
The Resolution is kept at the default FREENECT_RESOLUTION_MEDIUM
58+
*/
59+
60+
int freenect_sync_get_depth_with_res(void **depth, uint32_t *timestamp, int index,
5461
freenect_resolution res, freenect_depth_format fmt);
5562
/* Synchronous depth function, starts the runloop if it isn't running
5663
@@ -61,12 +68,19 @@ int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index,
6168
depth: Populated with a pointer to a depth buffer with a size of the requested type
6269
timestamp: Populated with the associated timestamp
6370
index: Device index (0 is the first)
71+
res: Valid resolution
6472
fmt: Valid format
6573
6674
Returns:
6775
Nonzero on error.
6876
*/
6977

78+
int freenect_sync_get_depth(void **depth, uint32_t *timestamp, int index, freenect_depth_format fmt);
79+
/* Again, a wrapper function to keep backward compatibility.
80+
The Resolution is kept at the default FREENECT_RESOLUTION_MEDIUM
81+
82+
*/
83+
7084
int freenect_sync_set_tilt_degs(int angle, int index);
7185
/* Tilt function, starts the runloop if it isn't running
7286

0 commit comments

Comments
 (0)