eleni@5: #include 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@5: video_buf = cv::Mat::zeros(KINECT_VIDEO_HEIGHT, KINECT_VIDEO_WIDTH, CV_8UC3); eleni@5: depth_buf = cv::Mat::zeros(KINECT_DEPTH_HEIGHT, KINECT_DEPTH_WIDTH, CV_8UC1); eleni@5: eleni@5: tex_setup(); eleni@5: } eleni@5: eleni@5: void Frame::tex_setup() eleni@5: { eleni@5: glGenTextures(1, &video_tex); eleni@5: glGenTextures(1, &depth_tex); eleni@5: eleni@5: glBindTexture(GL_TEXTURE_2D, video_tex); eleni@5: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); eleni@5: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); eleni@5: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); eleni@5: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); eleni@5: glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA, video_buf.size().width, video_buf.size().height, eleni@5: 0, GL_BGRA, GL_UNSIGNED_BYTE, &video_buf); eleni@5: eleni@5: glBindTexture(GL_TEXTURE_2D, depth_tex); eleni@5: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); eleni@5: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); eleni@5: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); eleni@5: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); eleni@5: glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA, depth_buf.size().width, depth_buf.size().height, eleni@5: 0, GL_BGRA, GL_UNSIGNED_BYTE, &depth_buf); eleni@5: 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@5: /* freenect video data to cv mat: */ eleni@5: unsigned char* src = (unsigned char*)video; eleni@5: unsigned char* dest = frame->video_buf.data; eleni@5: eleni@5: for(int i=0; idepth_buf.data; eleni@5: eleni@5: for(int i=0; i