eleni@4: #include eleni@4: #include //TODO remove eleni@4: eleni@2: #include eleni@1: #include eleni@2: #include eleni@1: eleni@1: #include "frame.h" eleni@2: #include "kinect.h" eleni@1: eleni@2: extern Frame *frame; eleni@2: extern KinectParams *kin_params; eleni@1: eleni@2: extern bool has_video; eleni@2: extern bool has_depth; eleni@2: eleni@2: Frame::Frame() eleni@1: { eleni@4: video_buf = cv::Mat(FREENECT_VIDEO_WIDTH, FREENECT_VIDEO_HEIGHT, CV_8UC1, 0); eleni@4: depth_buf = cv::Mat(FREENECT_DEPTH_WIDTH, FREENECT_DEPTH_HEIGHT, CV_16UC1, 0); eleni@1: } eleni@1: eleni@2: void Frame::process() eleni@1: { eleni@2: if(has_video && has_depth) eleni@2: printf("Depth and Rgb\n"); eleni@2: } eleni@2: eleni@2: void video_cb(freenect_device *kin_dev, void *video, uint32_t time) eleni@2: { eleni@4: if(!video || !frame) { eleni@2: has_video = false; eleni@2: return; eleni@2: } eleni@2: eleni@4: uint8_t* video_data = static_cast(video); eleni@4: frame->video_buf.data = (uchar*)video_data; eleni@4: //frame->video_buf.convertTo(frame->video_buf, CV_8UC1); eleni@4: cv::imshow("wx", frame->video_buf); eleni@4: cv::waitKey(100); eleni@2: has_video = true; eleni@1: } eleni@1: eleni@1: void depth_cb(freenect_device *kin_dev, void *depth, uint32_t time) eleni@1: { eleni@2: if(!depth) { eleni@2: has_depth = false; eleni@2: return; eleni@2: } eleni@2: eleni@4: uint16_t* depth_data = static_cast(depth); eleni@4: frame->depth_buf.data = (uchar*)depth_data; eleni@2: has_depth = true; eleni@1: }