Skip to content

Commit

Permalink
1. Made glpclview not go "ape-shit" when no kinect is found
Browse files Browse the repository at this point in the history
2. cvdemo and glpclview give nicer messages when no kinect is found
Signed-off-by: Brandyn A. White <[email protected]>
  • Loading branch information
Brandyn A. White committed Dec 6, 2010
1 parent 3250951 commit eb3b04c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
16 changes: 10 additions & 6 deletions examples/glpclview.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <GL/gl.h>
#include <GL/glu.h>
#endif

#include <stdlib.h>
#include <math.h>

int window;
Expand Down Expand Up @@ -105,17 +105,21 @@ void mousePress(int button, int state, int x, int y)
}
}

void no_kinect_quit(void)
{
printf("Error: Kinect not connected?\n");
exit(1);
}

void DrawGLScene()
{
short *depth = 0;
char *rgb = 0;
uint32_t ts;
if (freenect_sync_get_depth((void**)&depth, &ts, 0, FREENECT_DEPTH_11BIT) < 0)
return;
if (freenect_sync_get_video((void**)&rgb, &ts, 0, FREENECT_VIDEO_RGB) < 0) {
free(depth);
return;
}
no_kinect_quit();
if (freenect_sync_get_video((void**)&rgb, &ts, 0, FREENECT_VIDEO_RGB) < 0)
no_kinect_quit();

static unsigned int indices[480][640];
static short xyz[480][640][3];
Expand Down
9 changes: 7 additions & 2 deletions wrappers/opencv/cvdemo.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <stdio.h>
#include "libfreenect_cv.h"

IplImage *GlViewColor(IplImage *depth)
Expand Down Expand Up @@ -56,12 +57,16 @@ int main(int argc, char **argv)
{
while (cvWaitKey(10) < 0) {
IplImage *image = freenect_sync_get_rgb_cv(0);
if (!image)
if (!image) {
printf("Error: Kinect not connected?\n");
return -1;
}
cvCvtColor(image, image, CV_RGB2BGR);
IplImage *depth = freenect_sync_get_depth_cv(0);
if (!depth)
if (!depth) {
printf("Error: Kinect not connected?\n");
return -1;
}
cvShowImage("RGB", image);
cvShowImage("Depth", GlViewColor(depth));
}
Expand Down

0 comments on commit eb3b04c

Please sign in to comment.