invisible
changeset 13:65fd6d7c42b1
foo: show/hide rgb video and depth frames
author | Eleni Maria Stea <eleni@mutantstargoat.com> |
---|---|
date | Tue, 05 Nov 2013 00:24:25 +0200 |
parents | 226073258785 |
children | b6de02e21d82 |
files | src/frame.cc src/kinect.cc src/main.cc |
diffstat | 3 files changed, 20 insertions(+), 13 deletions(-) [+] |
line diff
1.1 --- a/src/frame.cc Mon Nov 04 23:39:22 2013 +0200 1.2 +++ b/src/frame.cc Tue Nov 05 00:24:25 2013 +0200 1.3 @@ -1,5 +1,4 @@ 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 @@ -55,8 +54,10 @@ 1.10 if(has_video) { 1.11 glBindTexture(GL_TEXTURE_2D, video_tex); 1.12 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, KINECT_VIDEO_WIDTH, KINECT_VIDEO_HEIGHT, GL_BGR, GL_UNSIGNED_BYTE, video_buf.data); 1.13 - //glBindTexture(GL_TEXTURE_2D, depth_tex); 1.14 - //subi; 1.15 + } 1.16 + if(has_depth) { 1.17 + glBindTexture(GL_TEXTURE_2D, depth_tex); 1.18 + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, KINECT_DEPTH_WIDTH, KINECT_DEPTH_HEIGHT, GL_LUMINANCE, GL_UNSIGNED_BYTE, depth_buf.data); 1.19 } 1.20 if(has_video && has_depth) {//pot 1.21 }
2.1 --- a/src/kinect.cc Mon Nov 04 23:39:22 2013 +0200 2.2 +++ b/src/kinect.cc Tue Nov 05 00:24:25 2013 +0200 2.3 @@ -42,12 +42,12 @@ 2.4 return false; 2.5 } 2.6 2.7 - if(freenect_set_tilt_degs(*kin_dev, kin_params->angle) < 0) { 2.8 +/* if(freenect_set_tilt_degs(*kin_dev, kin_params->angle) < 0) { 2.9 stop_kinect(*kin_ctx, *kin_dev); 2.10 fprintf(stderr, "Failed to set kinect angle\n"); 2.11 return false; 2.12 } 2.13 - 2.14 +*/ 2.15 if(freenect_set_led(*kin_dev, kin_params->led_color) < 0) { 2.16 fprintf(stderr, "Failed to set kinect LED\n"); 2.17 stop_kinect(*kin_ctx, *kin_dev);
3.1 --- a/src/main.cc Mon Nov 04 23:39:22 2013 +0200 3.2 +++ b/src/main.cc Tue Nov 05 00:24:25 2013 +0200 3.3 @@ -1,7 +1,6 @@ 3.4 #include <GL/glew.h> 3.5 #include <GL/glut.h> 3.6 3.7 -#include <assert.h> 3.8 #include <stdio.h> 3.9 3.10 #include "kinect.h" 3.11 @@ -13,6 +12,8 @@ 3.12 KinectParams kin_params; 3.13 Frame *frame; 3.14 3.15 +static bool show; 3.16 + 3.17 static void cleanup(); 3.18 3.19 static void display(); 3.20 @@ -67,19 +68,18 @@ 3.21 fprintf(stderr, "Failed to process events.\n"); 3.22 exit(0); 3.23 } 3.24 - assert(glGetError() == GL_NO_ERROR); 3.25 frame->process(); 3.26 3.27 glEnable(GL_TEXTURE_2D); 3.28 - glBindTexture(GL_TEXTURE_2D, frame->video_tex); 3.29 - assert(glGetError() == GL_NO_ERROR); 3.30 - draw_tess_quad(-1, -1, 0.6, 0.6, 1, 1); 3.31 -// glBindTexture(GL_TEXTURE_2D, frame->depth_tex); 3.32 -// draw_tes.. 3.33 + if(show) { 3.34 + glBindTexture(GL_TEXTURE_2D, frame->video_tex); 3.35 + draw_tess_quad(-1, -1, 1, 2, 1, 1); 3.36 + glBindTexture(GL_TEXTURE_2D, frame->depth_tex); 3.37 + draw_tess_quad(0, -1, 1, 2, 1, 1); 3.38 + } 3.39 glDisable(GL_TEXTURE_2D); 3.40 3.41 glutSwapBuffers(); 3.42 - assert(glGetError() == GL_NO_ERROR); 3.43 } 3.44 3.45 static void reshape(int w, int h) 3.46 @@ -93,6 +93,12 @@ 3.47 static void keyb(unsigned char key, int x, int y) 3.48 { 3.49 switch(key) { 3.50 + case 's': 3.51 + if(show) 3.52 + show = false; 3.53 + else 3.54 + show = true; 3.55 + break; 3.56 case 27: 3.57 exit(0); 3.58 default: