invisible

changeset 4:1ff5a1a50b41

foo, TODO: fix conversions
author Eleni Maria Stea <eleni@mutantstargoat.com>
date Wed, 16 Oct 2013 15:41:08 +0300
parents b479136a1ab3
children 700127288dc5
files src/frame.cc src/frame.h src/main.cc
diffstat 3 files changed, 16 insertions(+), 9 deletions(-) [+]
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  }
     2.1 --- a/src/frame.h	Wed Oct 09 23:00:19 2013 +0300
     2.2 +++ b/src/frame.h	Wed Oct 16 15:41:08 2013 +0300
     2.3 @@ -9,6 +9,8 @@
     2.4  	cv::Mat video_buf;
     2.5  
     2.6  	Frame();
     2.7 +    ~Frame(); //TODO delete Mat
     2.8 +
     2.9  	void process();
    2.10  };
    2.11  
     3.1 --- a/src/main.cc	Wed Oct 09 23:00:19 2013 +0300
     3.2 +++ b/src/main.cc	Wed Oct 16 15:41:08 2013 +0300
     3.3 @@ -45,6 +45,7 @@
     3.4  	glutIdleFunc(idle);
     3.5  
     3.6  	glClearColor(1, 1, 1, 1);
     3.7 +    frame = new Frame();
     3.8  
     3.9  	atexit(cleanup);
    3.10  	glutMainLoop();