# HG changeset patch # User Eleni Maria Stea # Date 1383509220 -7200 # Node ID bd1b0385a10b84c932f492300359354794f34a17 # Parent 4f1b8ddcd32ed0a94b2273f370b24e2e420955e3 fixed depth frame rendering diff -r 4f1b8ddcd32e -r bd1b0385a10b src/frame.cc --- a/src/frame.cc Sun Nov 03 21:58:56 2013 +0200 +++ b/src/frame.cc Sun Nov 03 22:07:00 2013 +0200 @@ -82,10 +82,21 @@ } /* freenect depth data to cv mat: */ + uint16_t* src = (uint16_t*)depth; + uint16_t* dest = (uint16_t*)frame->depth_buf.data; - memcpy(frame->depth_buf.data, depth, KINECT_DEPTH_WIDTH * KINECT_DEPTH_HEIGHT * 2); + for(int i=0; i= 2047) { + val = 0; + } + val = val << 5; + *dest = val; + src++; + dest++; + } - save_depth_ppm(depth, KINECT_DEPTH_WIDTH, KINECT_DEPTH_HEIGHT); + cv::imshow("foo", frame->depth_buf); cv::waitKey(100); has_depth = true; @@ -107,22 +118,3 @@ fclose(fp); return true; } - -bool save_depth_ppm(void *depth, int w, int h) -{ - FILE *fp; - if(!(fp = fopen("test_depth.ppm", "wb"))) { - fprintf(stderr, "Failed to open depth file for writing.\n"); - return false; - } - fprintf(fp, "P6\n%d %d\n255\n", w, h); - uint16_t *ptr = (uint16_t*)depth; - for(int i=0; i> 8; - fputc(c, fp); - fputc(c, fp); - fputc(c, fp); - } - fclose(fp); - return true; -}