invisible
changeset 9:6f5f53d0d166
use 8bit mat to save depth frames to avoid convertions during inpaint
author | Eleni Maria Stea <eleni@mutantstargoat.com> |
---|---|
date | Mon, 04 Nov 2013 00:29:14 +0200 |
parents | bd1b0385a10b |
children | a0397f57c07f |
files | src/frame.cc |
diffstat | 1 files changed, 6 insertions(+), 5 deletions(-) [+] |
line diff
1.1 --- a/src/frame.cc Sun Nov 03 22:07:00 2013 +0200 1.2 +++ b/src/frame.cc Mon Nov 04 00:29:14 2013 +0200 1.3 @@ -1,5 +1,7 @@ 1.4 #include <GL/gl.h> 1.5 #include <cxcore.h> 1.6 +#include <opencv2/imgproc/imgproc.hpp> 1.7 + 1.8 #include <highgui.h> //TODO remove 1.9 #include <cv.h> //TODO remove 1.10 1.11 @@ -19,7 +21,7 @@ 1.12 Frame::Frame() 1.13 { 1.14 video_buf = cv::Mat::zeros(KINECT_VIDEO_HEIGHT, KINECT_VIDEO_WIDTH, CV_8UC3); 1.15 - depth_buf = cv::Mat::zeros(KINECT_DEPTH_HEIGHT, KINECT_DEPTH_WIDTH, CV_16UC1); 1.16 + depth_buf = cv::Mat::zeros(KINECT_DEPTH_HEIGHT, KINECT_DEPTH_WIDTH, CV_8UC1); 1.17 1.18 tex_setup(); 1.19 } 1.20 @@ -83,20 +85,19 @@ 1.21 1.22 /* freenect depth data to cv mat: */ 1.23 uint16_t* src = (uint16_t*)depth; 1.24 - uint16_t* dest = (uint16_t*)frame->depth_buf.data; 1.25 + uint8_t* dest = (uint8_t*)frame->depth_buf.data; 1.26 1.27 for(int i=0; i<KINECT_DEPTH_HEIGHT * KINECT_DEPTH_WIDTH; i++) { 1.28 uint16_t val = *src; 1.29 if(val >= 2047) { 1.30 val = 0; 1.31 } 1.32 - val = val << 5; 1.33 - *dest = val; 1.34 + *dest = val >> 3; 1.35 src++; 1.36 dest++; 1.37 } 1.38 1.39 - 1.40 + cv::medianBlur(frame->depth_buf, frame->depth_buf, 5); 1.41 cv::imshow("foo", frame->depth_buf); 1.42 cv::waitKey(100); 1.43 has_depth = true;