invisible

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