Skip to content

Commit 2402fcd

Browse files
committed
Server depth format fix. RGB/DEPTH FIX, images should look OK now in client.
Signed-off-by: Juan Carlos del Valle <jc.ekinox@gmail.com> (imekinox)
1 parent ffdaebb commit 2402fcd

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

wrappers/actionscript/server/as3-server.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void send_policy_file(int child){
8383
if(psent == 0){
8484
int n;
8585
char * str = "<?xml version='1.0'?><!DOCTYPE cross-domain-policy SYSTEM '/xml/dtds/cross-domain-policy.dtd'><cross-domain-policy><site-control permitted-cross-domain-policies='all'/><allow-access-from domain='*' to-ports='*'/></cross-domain-policy>\n";
86-
n = write(child,str , 237);
86+
//n = write(child,str , 237);
8787
if ( n < 0 || n != 237)
8888
{
8989
fprintf(stderr, "Error on write() for depth (%d instead of %d)\n",n, 237);
@@ -344,39 +344,39 @@ void depth_cb(freenect_device *dev, void *v_depth, uint32_t timestamp)
344344
int lb = pval & 0xff;
345345
switch (pval>>8) {
346346
case 0:
347-
buf_depth[4 * i + 0] = 255;
347+
buf_depth[4 * i + 2] = 255;
348348
buf_depth[4 * i + 1] = 255-lb;
349-
buf_depth[4 * i + 2] = 255-lb;
349+
buf_depth[4 * i + 0] = 255-lb;
350350
break;
351351
case 1:
352-
buf_depth[4 * i + 0] = 255;
352+
buf_depth[4 * i + 2] = 255;
353353
buf_depth[4 * i + 1] = lb;
354-
buf_depth[4 * i + 2] = 0;
354+
buf_depth[4 * i + 0] = 0;
355355
break;
356356
case 2:
357-
buf_depth[4 * i + 0] = 255-lb;
357+
buf_depth[4 * i + 2] = 255-lb;
358358
buf_depth[4 * i + 1] = 255;
359-
buf_depth[4 * i + 2] = 0;
359+
buf_depth[4 * i + 0] = 0;
360360
break;
361361
case 3:
362-
buf_depth[4 * i + 0] = 0;
362+
buf_depth[4 * i + 2] = 0;
363363
buf_depth[4 * i + 1] = 255;
364-
buf_depth[4 * i + 2] = lb;
364+
buf_depth[4 * i + 0] = lb;
365365
break;
366366
case 4:
367-
buf_depth[4 * i + 0] = 0;
367+
buf_depth[4 * i + 2] = 0;
368368
buf_depth[4 * i + 1] = 255-lb;
369-
buf_depth[4 * i + 2] = 255;
369+
buf_depth[4 * i + 0] = 255;
370370
break;
371371
case 5:
372-
buf_depth[4 * i + 0] = 0;
372+
buf_depth[4 * i + 2] = 0;
373373
buf_depth[4 * i + 1] = 0;
374-
buf_depth[4 * i + 2] = 255-lb;
374+
buf_depth[4 * i + 0] = 255-lb;
375375
break;
376376
default:
377-
buf_depth[4 * i + 0] = 0;
378-
buf_depth[4 * i + 1] = 0;
379377
buf_depth[4 * i + 2] = 0;
378+
buf_depth[4 * i + 1] = 0;
379+
buf_depth[4 * i + 0] = 0;
380380
break;
381381
}
382382
buf_depth[4 * i + 3] = 0x00;
@@ -406,9 +406,9 @@ void rgb_cb(freenect_device *dev, void *rgb, uint32_t timestamp)
406406
//printf("size: %d", compressed_size);
407407
int x;
408408
for (x=0; x<640 * 480; x++) {
409-
buf_rgb[4 * x + 0] = ((uint8_t*)rgb)[3 * x + 0];
409+
buf_rgb[4 * x + 0] = ((uint8_t*)rgb)[3 * x + 2];
410410
buf_rgb[4 * x + 1] = ((uint8_t*)rgb)[3 * x + 1];
411-
buf_rgb[4 * x + 2] = ((uint8_t*)rgb)[3 * x + 2];
411+
buf_rgb[4 * x + 2] = ((uint8_t*)rgb)[3 * x + 0];
412412
buf_rgb[4 * x + 3] = 0x00;
413413
}
414414
printf("rgb received\n ");
@@ -432,8 +432,8 @@ void *freenect_threadfunc(void *arg)
432432
freenect_set_depth_callback(f_dev, depth_cb);
433433
freenect_set_video_callback(f_dev, rgb_cb);
434434
freenect_set_video_format(f_dev, FREENECT_VIDEO_RGB);
435-
freenect_set_depth_format(f_dev, FREENECT_VIDEO_IR_10BIT);
436-
435+
freenect_set_depth_format(f_dev, FREENECT_DEPTH_11BIT);
436+
437437
printf("'w'-tilt up, 's'-level, 'x'-tilt down, '0'-'6'-select LED mode\n");
438438
if ( pthread_create(&data_in_thread, NULL, data_in, NULL) )
439439
{

0 commit comments

Comments
 (0)