invisible

view 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 source
1 #include <cxcore.h>
2 #include <highgui.h> //TODO remove
4 #include <pthread.h>
5 #include <stdio.h>
6 #include <string.h>
8 #include "frame.h"
9 #include "kinect.h"
11 extern Frame *frame;
12 extern KinectParams *kin_params;
14 extern bool has_video;
15 extern bool has_depth;
17 Frame::Frame()
18 {
19 video_buf = cv::Mat(FREENECT_VIDEO_WIDTH, FREENECT_VIDEO_HEIGHT, CV_8UC1, 0);
20 depth_buf = cv::Mat(FREENECT_DEPTH_WIDTH, FREENECT_DEPTH_HEIGHT, CV_16UC1, 0);
21 }
23 void Frame::process()
24 {
25 if(has_video && has_depth)
26 printf("Depth and Rgb\n");
27 }
29 void video_cb(freenect_device *kin_dev, void *video, uint32_t time)
30 {
31 if(!video || !frame) {
32 has_video = false;
33 return;
34 }
36 uint8_t* video_data = static_cast<uint8_t*>(video);
37 frame->video_buf.data = (uchar*)video_data;
38 //frame->video_buf.convertTo(frame->video_buf, CV_8UC1);
39 cv::imshow("wx", frame->video_buf);
40 cv::waitKey(100);
41 has_video = true;
42 }
44 void depth_cb(freenect_device *kin_dev, void *depth, uint32_t time)
45 {
46 if(!depth) {
47 has_depth = false;
48 return;
49 }
51 uint16_t* depth_data = static_cast<uint16_t*>(depth);
52 frame->depth_buf.data = (uchar*)depth_data;
53 has_depth = true;
54 }