Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV function within openGL program

Hi,

I have an OpenGL program that uses an OpenCV function call to calculate the coordinates relative to some markers. The problem (most of the program shown below, except for header files, variable declarations and image processing functions) is that the openGL graphics does not update (seems like it runs once, though webcam light is still active) but if I comment out capture = cvCaptureFromCAM(CV_CAP_ANY) , then the OpenGL graphics output updates continually as expected.

The OpenGL and OpenCV functions run as separate programs. Would appreciate any pointers you may have.

Regards

void setup(void)
{
glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
glPointSize(10);
}

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0, 0.0, 1.0);

glBegin(GL_POINTS);
glVertex2f(mid, 50);
glEnd();

glFlush();
}

void resize(int width, int height)
{
glViewport(0, 0, (GLsizei)width, (GLsizei)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 100.0, 0.0, 100.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

void capture(void) //OpenCV function
{
CvCapture* capture = 0;
IplImage* frame = 0;

capture = cvCaptureFromCAM(CV_CAP_ANY);
if(!capture)
{
printf("Could not initialise capturing...\n");
}

frame = cvQueryFrame(capture);
...
}

int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500, 500);
glutInitWindowPosition(100, 100);
glutCreateWindow("Lumbar Tracking");
setup();
capture();
glutDisplayFunc(display);
glutReshapeFunc(resize);
glutMainLoop();

return 0; 
}

OpenCV function within openGL program

Hi,

I have an OpenGL program that uses an OpenCV function call to calculate the coordinates relative to some markers. The problem (most of the program shown below, except for header files, variable declarations and image processing functions) is that the openGL graphics does not update (seems like it runs once, though webcam light is still active) but if I comment out capture = cvCaptureFromCAM(CV_CAP_ANY) , then the OpenGL graphics output updates continually as expected.

The OpenGL and OpenCV functions run as separate programs. Would appreciate any pointers you may have.

Regards

void setup(void)
{
glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
glPointSize(10);
}

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0, 0.0, 1.0);

glBegin(GL_POINTS);
glVertex2f(mid, 50);
glEnd();

glFlush();
}

void resize(int width, int height)
{
glViewport(0, 0, (GLsizei)width, (GLsizei)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 100.0, 0.0, 100.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

void capture(void) //OpenCV function
{
CvCapture* capture = 0;
IplImage* frame = 0;

capture = cvCaptureFromCAM(CV_CAP_ANY);
if(!capture)
{
printf("Could not initialise capturing...\n");
}

frame = cvQueryFrame(capture);
...
}

int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500, 500);
glutInitWindowPosition(100, 100);
glutCreateWindow("Lumbar Tracking");
glutCreateWindow("Ltest");
setup();
capture();
glutDisplayFunc(display);
glutReshapeFunc(resize);
glutMainLoop();

return 0; 
}