invisible
changeset 12:226073258785
quick backup: display video, draw tesselated quads
author | Eleni Maria Stea <eleni@mutantstargoat.com> |
---|---|
date | Mon, 04 Nov 2013 23:39:22 +0200 |
parents | d2158a527488 |
children | 65fd6d7c42b1 |
files | src/frame.cc src/main.cc |
diffstat | 2 files changed, 27 insertions(+), 12 deletions(-) [+] |
line diff
1.1 --- a/src/frame.cc Mon Nov 04 21:53:21 2013 +0200 1.2 +++ b/src/frame.cc Mon Nov 04 23:39:22 2013 +0200 1.3 @@ -1,4 +1,5 @@ 1.4 #include <GL/gl.h> 1.5 +#include <assert.h> 1.6 #include <cxcore.h> 1.7 #include <opencv2/imgproc/imgproc.hpp> 1.8 #include <opencv2/photo/photo.hpp> 1.9 @@ -37,23 +38,28 @@ 1.10 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 1.11 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 1.12 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 1.13 - glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA, video_buf.size().width, video_buf.size().height, 1.14 - 0, GL_BGRA, GL_UNSIGNED_BYTE, &video_buf); 1.15 + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, KINECT_VIDEO_WIDTH, KINECT_VIDEO_HEIGHT, 1.16 + 0, GL_BGR, GL_UNSIGNED_BYTE, 0); 1.17 1.18 glBindTexture(GL_TEXTURE_2D, depth_tex); 1.19 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 1.20 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 1.21 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 1.22 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 1.23 - glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA, depth_buf.size().width, depth_buf.size().height, 1.24 - 0, GL_BGRA, GL_UNSIGNED_BYTE, &depth_buf); 1.25 - 1.26 + glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, KINECT_DEPTH_WIDTH, KINECT_DEPTH_HEIGHT, 1.27 + 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, 0); 1.28 } 1.29 1.30 void Frame::process() 1.31 { 1.32 - if(has_video && has_depth) 1.33 - printf("Depth and Rgb\n"); 1.34 + if(has_video) { 1.35 + glBindTexture(GL_TEXTURE_2D, video_tex); 1.36 + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, KINECT_VIDEO_WIDTH, KINECT_VIDEO_HEIGHT, GL_BGR, GL_UNSIGNED_BYTE, video_buf.data); 1.37 + //glBindTexture(GL_TEXTURE_2D, depth_tex); 1.38 + //subi; 1.39 + } 1.40 + if(has_video && has_depth) {//pot 1.41 + } 1.42 } 1.43 1.44 void video_cb(freenect_device *kin_dev, void *video, uint32_t time) 1.45 @@ -107,8 +113,6 @@ 1.46 cv::threshold(mask, mask, 254, 255, 3); 1.47 cv::inpaint(frame->depth_buf, mask, frame->depth_buf, 1, cv::INPAINT_NS); 1.48 */ 1.49 - cv::imshow("foo", frame->depth_buf); 1.50 - cv::waitKey(30); 1.51 has_depth = true; 1.52 } 1.53
2.1 --- a/src/main.cc Mon Nov 04 21:53:21 2013 +0200 2.2 +++ b/src/main.cc Mon Nov 04 23:39:22 2013 +0200 2.3 @@ -1,11 +1,12 @@ 2.4 #include <GL/glew.h> 2.5 #include <GL/glut.h> 2.6 + 2.7 +#include <assert.h> 2.8 #include <stdio.h> 2.9 2.10 -#include <pthread.h> 2.11 - 2.12 #include "kinect.h" 2.13 #include "frame.h" 2.14 +#include "tesquad.h" 2.15 2.16 freenect_context *kin_ctx; 2.17 freenect_device *kin_dev; 2.18 @@ -45,7 +46,7 @@ 2.19 glutIdleFunc(idle); 2.20 2.21 glClearColor(1, 1, 1, 1); 2.22 - frame = new Frame(); 2.23 + frame = new Frame; 2.24 2.25 atexit(cleanup); 2.26 glutMainLoop(); 2.27 @@ -66,9 +67,19 @@ 2.28 fprintf(stderr, "Failed to process events.\n"); 2.29 exit(0); 2.30 } 2.31 + assert(glGetError() == GL_NO_ERROR); 2.32 frame->process(); 2.33 2.34 + glEnable(GL_TEXTURE_2D); 2.35 + glBindTexture(GL_TEXTURE_2D, frame->video_tex); 2.36 + assert(glGetError() == GL_NO_ERROR); 2.37 + draw_tess_quad(-1, -1, 0.6, 0.6, 1, 1); 2.38 +// glBindTexture(GL_TEXTURE_2D, frame->depth_tex); 2.39 +// draw_tes.. 2.40 + glDisable(GL_TEXTURE_2D); 2.41 + 2.42 glutSwapBuffers(); 2.43 + assert(glGetError() == GL_NO_ERROR); 2.44 } 2.45 2.46 static void reshape(int w, int h)