invisible

diff src/frame.cc @ 4:1ff5a1a50b41

foo, TODO: fix conversions
author Eleni Maria Stea <eleni@mutantstargoat.com>
date Wed, 16 Oct 2013 15:41:08 +0300
parents b0b90ef993a0
children 700127288dc5
line diff
     1.1 --- a/src/frame.cc	Wed Oct 09 23:00:19 2013 +0300
     1.2 +++ b/src/frame.cc	Wed Oct 16 15:41:08 2013 +0300
     1.3 @@ -1,4 +1,6 @@
     1.4 -#include <cv.h>
     1.5 +#include <cxcore.h>
     1.6 +#include <highgui.h> //TODO remove
     1.7 +
     1.8  #include <pthread.h>
     1.9  #include <stdio.h>
    1.10  #include <string.h>
    1.11 @@ -14,12 +16,8 @@
    1.12  
    1.13  Frame::Frame()
    1.14  {
    1.15 -	if(video_buf.empty()) {
    1.16 -		video_buf = cv::Mat(FREENECT_VIDEO_WIDTH, FREENECT_VIDEO_HEIGHT, CV_32FC3, cv::Scalar(0, 0, 0));
    1.17 -	}
    1.18 -	if(depth_buf.empty()) {
    1.19 -		depth_buf = cv::Mat(FREENECT_DEPTH_WIDTH, FREENECT_VIDEO_HEIGHT, CV_16UC1, 0);
    1.20 -	}
    1.21 +    video_buf = cv::Mat(FREENECT_VIDEO_WIDTH, FREENECT_VIDEO_HEIGHT, CV_8UC1, 0);
    1.22 +    depth_buf = cv::Mat(FREENECT_DEPTH_WIDTH, FREENECT_DEPTH_HEIGHT, CV_16UC1, 0);
    1.23  }
    1.24  
    1.25  void Frame::process()
    1.26 @@ -30,12 +28,16 @@
    1.27  
    1.28  void video_cb(freenect_device *kin_dev, void *video, uint32_t time)
    1.29  {
    1.30 -	if(!video) {
    1.31 +	if(!video || !frame) {
    1.32  		has_video = false;
    1.33  		return;
    1.34  	}
    1.35  
    1.36 -	//copy *video to video_buf if fail => has_video = false
    1.37 +    uint8_t* video_data = static_cast<uint8_t*>(video);
    1.38 +    frame->video_buf.data = (uchar*)video_data;
    1.39 +    //frame->video_buf.convertTo(frame->video_buf, CV_8UC1);
    1.40 +    cv::imshow("wx", frame->video_buf);
    1.41 +    cv::waitKey(100);
    1.42  	has_video = true;
    1.43  }
    1.44  
    1.45 @@ -46,5 +48,7 @@
    1.46  		return;
    1.47  	}
    1.48  
    1.49 +    uint16_t* depth_data = static_cast<uint16_t*>(depth);
    1.50 +    frame->depth_buf.data = (uchar*)depth_data;
    1.51  	has_depth = true;
    1.52  }