3D in OpenGL/CV How to connect with transmitter
  1 / 2    
Hi all,

I wrote a program using OpenGL and Opencv to do the page-flipping between right and left frames for 3D vision. I purchased the 3D shutter glasses and the quadro FX1800 from Nvidia. The 3D glasses including the IR transmitter came with a driver that allows you to play a 3D video by combining a left and right video. However, I would like to play real time 3D straight from my OpenGL + OpenCV program. How do I connect my program to the Nvidia transmitter so that they can be synchronized with the shutter glasses? This is my codes;

#include <windows.h>
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <glew.h>
#include <glut.h>
#include <highgui.h>
//#include "imageloader.h"

using namespace std;

//The length of each side of the cube
const float BOX_SIZE = 7.0f;
//The OpenGL id of the texture

bool LEye=TRUE;
bool check = false;

GLuint cameraImageTextureID;
CvCapture * captureL = 0;
CvCapture * captureR = 0;

void handleKeypress(unsigned char key, int x, int y) {
switch (key) {
//Escape key
case 27:
glDeleteTextures(1, &cameraImageTextureID);
cvReleaseCapture( &captureL );
cvReleaseCapture( &captureR );
exit(0);
}
}


void initRendering()
{
glEnable(GL_DEPTH_TEST);
//glEnable(GL_LIGHTING);
//glEnable(GL_LIGHT0);
//glEnable(GL_NORMALIZE);
//glEnable(GL_COLOR_MATERIAL);

if (!check)
{
glEnable(GL_TEXTURE_RECTANGLE_ARB);
glGenTextures(2, &cameraImageTextureID);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, cameraImageTextureID);

captureL = cvCreateCameraCapture(0);

captureR = cvCreateCameraCapture(1);



}

check = true;
}

void handleResize(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, (float)w / (float)h, 1.0, 200.0);
}

void drawScene()
{

// initialize camera
IplImage* newImageL = cvQueryFrame( captureL );
IplImage* newImageR = cvQueryFrame( captureR );

glDrawBuffer(GL_BACK);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

//glTranslatef(0.0f, 0.0f, -20.0f);

//GLfloat ambientLight[] = {0.3f, 0.3f, 0.3f, 1.0f};
//glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight);

//GLfloat lightColor[] = {0.7f, 0.7f, 0.7f, 1.0f};
//GLfloat lightPos[] = {-2 * BOX_SIZE, BOX_SIZE, 4 * BOX_SIZE, 1.0f};
//glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor);
//glLightfv(GL_LIGHT0, GL_POSITION, lightPos);

if (LEye)
{

glDrawBuffer(GL_BACK_LEFT);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,(GLdouble)newImageL->width,(GLdouble)newImageL->height,0.0);

glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective
glLoadIdentity(); //Reset the drawing perspective

glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, newImageL->width, newImageL->height, 0, GL_BGR, GL_UNSIGNED_BYTE, newImageL->imageData);

glBegin(GL_QUADS);
glTexCoord2i(0,0); glVertex2i(0,0);
glTexCoord2i(0,newImageL->height); glVertex2i(0,newImageL->height);
glTexCoord2i(newImageL->width,newImageL->height); glVertex2i(newImageL->width,newImageL->height);
glTexCoord2i(newImageL->width,0); glVertex2i(newImageL->width,0);
glEnd();

LEye = FALSE;
}
else
{

glDrawBuffer(GL_BACK_RIGHT);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,(GLdouble)newImageR->width,(GLdouble)newImageR->height,0.0);

glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective
glLoadIdentity(); //Reset the drawing perspective

glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, newImageR->width, newImageR->height, 0, GL_BGR, GL_UNSIGNED_BYTE, newImageR->imageData);

glBegin(GL_QUADS);
glTexCoord2i(0,0); glVertex2i(0,0);
glTexCoord2i(0,newImageR->height); glVertex2i(0,newImageR->height);
glTexCoord2i(newImageR->width,newImageR->height); glVertex2i(newImageR->width,newImageR->height);
glTexCoord2i(newImageR->width,0); glVertex2i(newImageR->width,0);
glEnd();

LEye = TRUE;
}
glDisable(GL_TEXTURE_2D);

glutSwapBuffers();
}

//Called every 25 milliseconds
void update(int value) {

glutPostRedisplay();
glutTimerFunc((1/30)*1000, update, 0); // 30 f/s
// glutTimerFunc(100, update, 0);
}

int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(400, 400);

glutCreateWindow("Shutter");
initRendering();



glutDisplayFunc(drawScene);
glutKeyboardFunc(handleKeypress);
glutReshapeFunc(handleResize);
glutTimerFunc((1/30)*1000, update, 0);
// glutTimerFunc(100, update, 0);

glutMainLoop();
return 0;
}



Thank you for your help.
Hi all,



I wrote a program using OpenGL and Opencv to do the page-flipping between right and left frames for 3D vision. I purchased the 3D shutter glasses and the quadro FX1800 from Nvidia. The 3D glasses including the IR transmitter came with a driver that allows you to play a 3D video by combining a left and right video. However, I would like to play real time 3D straight from my OpenGL + OpenCV program. How do I connect my program to the Nvidia transmitter so that they can be synchronized with the shutter glasses? This is my codes;



#include <windows.h>

#include <stdio.h>

#include <iostream>

#include <stdlib.h>

#include <glew.h>

#include <glut.h>

#include <highgui.h>

//#include "imageloader.h"



using namespace std;



//The length of each side of the cube

const float BOX_SIZE = 7.0f;

//The OpenGL id of the texture



bool LEye=TRUE;

bool check = false;



GLuint cameraImageTextureID;

CvCapture * captureL = 0;

CvCapture * captureR = 0;



void handleKeypress(unsigned char key, int x, int y) {

switch (key) {

//Escape key

case 27:

glDeleteTextures(1, &cameraImageTextureID);

cvReleaseCapture( &captureL );

cvReleaseCapture( &captureR );

exit(0);

}

}





void initRendering()

{

glEnable(GL_DEPTH_TEST);

//glEnable(GL_LIGHTING);

//glEnable(GL_LIGHT0);

//glEnable(GL_NORMALIZE);

//glEnable(GL_COLOR_MATERIAL);



if (!check)

{

glEnable(GL_TEXTURE_RECTANGLE_ARB);

glGenTextures(2, &cameraImageTextureID);

glBindTexture(GL_TEXTURE_RECTANGLE_ARB, cameraImageTextureID);



captureL = cvCreateCameraCapture(0);



captureR = cvCreateCameraCapture(1);







}



check = true;

}



void handleResize(int w, int h)

{

glViewport(0, 0, w, h);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluPerspective(45.0, (float)w / (float)h, 1.0, 200.0);

}



void drawScene()

{



// initialize camera

IplImage* newImageL = cvQueryFrame( captureL );

IplImage* newImageR = cvQueryFrame( captureR );



glDrawBuffer(GL_BACK);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);



glMatrixMode(GL_MODELVIEW);

glLoadIdentity();



//glTranslatef(0.0f, 0.0f, -20.0f);



//GLfloat ambientLight[] = {0.3f, 0.3f, 0.3f, 1.0f};

//glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight);



//GLfloat lightColor[] = {0.7f, 0.7f, 0.7f, 1.0f};

//GLfloat lightPos[] = {-2 * BOX_SIZE, BOX_SIZE, 4 * BOX_SIZE, 1.0f};

//glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor);

//glLightfv(GL_LIGHT0, GL_POSITION, lightPos);



if (LEye)

{



glDrawBuffer(GL_BACK_LEFT);



glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluOrtho2D(0.0,(GLdouble)newImageL->width,(GLdouble)newImageL->height,0.0);



glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective

glLoadIdentity(); //Reset the drawing perspective



glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, newImageL->width, newImageL->height, 0, GL_BGR, GL_UNSIGNED_BYTE, newImageL->imageData);



glBegin(GL_QUADS);

glTexCoord2i(0,0); glVertex2i(0,0);

glTexCoord2i(0,newImageL->height); glVertex2i(0,newImageL->height);

glTexCoord2i(newImageL->width,newImageL->height); glVertex2i(newImageL->width,newImageL->height);

glTexCoord2i(newImageL->width,0); glVertex2i(newImageL->width,0);

glEnd();



LEye = FALSE;

}

else

{



glDrawBuffer(GL_BACK_RIGHT);



glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluOrtho2D(0.0,(GLdouble)newImageR->width,(GLdouble)newImageR->height,0.0);



glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective

glLoadIdentity(); //Reset the drawing perspective



glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, newImageR->width, newImageR->height, 0, GL_BGR, GL_UNSIGNED_BYTE, newImageR->imageData);



glBegin(GL_QUADS);

glTexCoord2i(0,0); glVertex2i(0,0);

glTexCoord2i(0,newImageR->height); glVertex2i(0,newImageR->height);

glTexCoord2i(newImageR->width,newImageR->height); glVertex2i(newImageR->width,newImageR->height);

glTexCoord2i(newImageR->width,0); glVertex2i(newImageR->width,0);

glEnd();



LEye = TRUE;

}

glDisable(GL_TEXTURE_2D);



glutSwapBuffers();

}



//Called every 25 milliseconds

void update(int value) {



glutPostRedisplay();

glutTimerFunc((1/30)*1000, update, 0); // 30 f/s

// glutTimerFunc(100, update, 0);

}



int main(int argc, char** argv) {

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

glutInitWindowSize(400, 400);



glutCreateWindow("Shutter");

initRendering();







glutDisplayFunc(drawScene);

glutKeyboardFunc(handleKeypress);

glutReshapeFunc(handleResize);

glutTimerFunc((1/30)*1000, update, 0);

// glutTimerFunc(100, update, 0);



glutMainLoop();

return 0;

}







Thank you for your help.

#1
Posted 10/13/2010 05:52 PM   
Hi all,

I wrote a program using OpenGL and Opencv to do the page-flipping between right and left frames for 3D vision. I purchased the 3D shutter glasses and the quadro FX1800 from Nvidia. The 3D glasses including the IR transmitter came with a driver that allows you to play a 3D video by combining a left and right video. However, I would like to play real time 3D straight from my OpenGL + OpenCV program. How do I connect my program to the Nvidia transmitter so that they can be synchronized with the shutter glasses? This is my codes;

#include <windows.h>
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <glew.h>
#include <glut.h>
#include <highgui.h>
//#include "imageloader.h"

using namespace std;

//The length of each side of the cube
const float BOX_SIZE = 7.0f;
//The OpenGL id of the texture

bool LEye=TRUE;
bool check = false;

GLuint cameraImageTextureID;
CvCapture * captureL = 0;
CvCapture * captureR = 0;

void handleKeypress(unsigned char key, int x, int y) {
switch (key) {
//Escape key
case 27:
glDeleteTextures(1, &cameraImageTextureID);
cvReleaseCapture( &captureL );
cvReleaseCapture( &captureR );
exit(0);
}
}


void initRendering()
{
glEnable(GL_DEPTH_TEST);
//glEnable(GL_LIGHTING);
//glEnable(GL_LIGHT0);
//glEnable(GL_NORMALIZE);
//glEnable(GL_COLOR_MATERIAL);

if (!check)
{
glEnable(GL_TEXTURE_RECTANGLE_ARB);
glGenTextures(2, &cameraImageTextureID);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, cameraImageTextureID);

captureL = cvCreateCameraCapture(0);

captureR = cvCreateCameraCapture(1);



}

check = true;
}

void handleResize(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, (float)w / (float)h, 1.0, 200.0);
}

void drawScene()
{

// initialize camera
IplImage* newImageL = cvQueryFrame( captureL );
IplImage* newImageR = cvQueryFrame( captureR );

glDrawBuffer(GL_BACK);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

//glTranslatef(0.0f, 0.0f, -20.0f);

//GLfloat ambientLight[] = {0.3f, 0.3f, 0.3f, 1.0f};
//glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight);

//GLfloat lightColor[] = {0.7f, 0.7f, 0.7f, 1.0f};
//GLfloat lightPos[] = {-2 * BOX_SIZE, BOX_SIZE, 4 * BOX_SIZE, 1.0f};
//glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor);
//glLightfv(GL_LIGHT0, GL_POSITION, lightPos);

if (LEye)
{

glDrawBuffer(GL_BACK_LEFT);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,(GLdouble)newImageL->width,(GLdouble)newImageL->height,0.0);

glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective
glLoadIdentity(); //Reset the drawing perspective

glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, newImageL->width, newImageL->height, 0, GL_BGR, GL_UNSIGNED_BYTE, newImageL->imageData);

glBegin(GL_QUADS);
glTexCoord2i(0,0); glVertex2i(0,0);
glTexCoord2i(0,newImageL->height); glVertex2i(0,newImageL->height);
glTexCoord2i(newImageL->width,newImageL->height); glVertex2i(newImageL->width,newImageL->height);
glTexCoord2i(newImageL->width,0); glVertex2i(newImageL->width,0);
glEnd();

LEye = FALSE;
}
else
{

glDrawBuffer(GL_BACK_RIGHT);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,(GLdouble)newImageR->width,(GLdouble)newImageR->height,0.0);

glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective
glLoadIdentity(); //Reset the drawing perspective

glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, newImageR->width, newImageR->height, 0, GL_BGR, GL_UNSIGNED_BYTE, newImageR->imageData);

glBegin(GL_QUADS);
glTexCoord2i(0,0); glVertex2i(0,0);
glTexCoord2i(0,newImageR->height); glVertex2i(0,newImageR->height);
glTexCoord2i(newImageR->width,newImageR->height); glVertex2i(newImageR->width,newImageR->height);
glTexCoord2i(newImageR->width,0); glVertex2i(newImageR->width,0);
glEnd();

LEye = TRUE;
}
glDisable(GL_TEXTURE_2D);

glutSwapBuffers();
}

//Called every 25 milliseconds
void update(int value) {

glutPostRedisplay();
glutTimerFunc((1/30)*1000, update, 0); // 30 f/s
// glutTimerFunc(100, update, 0);
}

int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(400, 400);

glutCreateWindow("Shutter");
initRendering();



glutDisplayFunc(drawScene);
glutKeyboardFunc(handleKeypress);
glutReshapeFunc(handleResize);
glutTimerFunc((1/30)*1000, update, 0);
// glutTimerFunc(100, update, 0);

glutMainLoop();
return 0;
}



Thank you for your help.
Hi all,



I wrote a program using OpenGL and Opencv to do the page-flipping between right and left frames for 3D vision. I purchased the 3D shutter glasses and the quadro FX1800 from Nvidia. The 3D glasses including the IR transmitter came with a driver that allows you to play a 3D video by combining a left and right video. However, I would like to play real time 3D straight from my OpenGL + OpenCV program. How do I connect my program to the Nvidia transmitter so that they can be synchronized with the shutter glasses? This is my codes;



#include <windows.h>

#include <stdio.h>

#include <iostream>

#include <stdlib.h>

#include <glew.h>

#include <glut.h>

#include <highgui.h>

//#include "imageloader.h"



using namespace std;



//The length of each side of the cube

const float BOX_SIZE = 7.0f;

//The OpenGL id of the texture



bool LEye=TRUE;

bool check = false;



GLuint cameraImageTextureID;

CvCapture * captureL = 0;

CvCapture * captureR = 0;



void handleKeypress(unsigned char key, int x, int y) {

switch (key) {

//Escape key

case 27:

glDeleteTextures(1, &cameraImageTextureID);

cvReleaseCapture( &captureL );

cvReleaseCapture( &captureR );

exit(0);

}

}





void initRendering()

{

glEnable(GL_DEPTH_TEST);

//glEnable(GL_LIGHTING);

//glEnable(GL_LIGHT0);

//glEnable(GL_NORMALIZE);

//glEnable(GL_COLOR_MATERIAL);



if (!check)

{

glEnable(GL_TEXTURE_RECTANGLE_ARB);

glGenTextures(2, &cameraImageTextureID);

glBindTexture(GL_TEXTURE_RECTANGLE_ARB, cameraImageTextureID);



captureL = cvCreateCameraCapture(0);



captureR = cvCreateCameraCapture(1);







}



check = true;

}



void handleResize(int w, int h)

{

glViewport(0, 0, w, h);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluPerspective(45.0, (float)w / (float)h, 1.0, 200.0);

}



void drawScene()

{



// initialize camera

IplImage* newImageL = cvQueryFrame( captureL );

IplImage* newImageR = cvQueryFrame( captureR );



glDrawBuffer(GL_BACK);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);



glMatrixMode(GL_MODELVIEW);

glLoadIdentity();



//glTranslatef(0.0f, 0.0f, -20.0f);



//GLfloat ambientLight[] = {0.3f, 0.3f, 0.3f, 1.0f};

//glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight);



//GLfloat lightColor[] = {0.7f, 0.7f, 0.7f, 1.0f};

//GLfloat lightPos[] = {-2 * BOX_SIZE, BOX_SIZE, 4 * BOX_SIZE, 1.0f};

//glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor);

//glLightfv(GL_LIGHT0, GL_POSITION, lightPos);



if (LEye)

{



glDrawBuffer(GL_BACK_LEFT);



glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluOrtho2D(0.0,(GLdouble)newImageL->width,(GLdouble)newImageL->height,0.0);



glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective

glLoadIdentity(); //Reset the drawing perspective



glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, newImageL->width, newImageL->height, 0, GL_BGR, GL_UNSIGNED_BYTE, newImageL->imageData);



glBegin(GL_QUADS);

glTexCoord2i(0,0); glVertex2i(0,0);

glTexCoord2i(0,newImageL->height); glVertex2i(0,newImageL->height);

glTexCoord2i(newImageL->width,newImageL->height); glVertex2i(newImageL->width,newImageL->height);

glTexCoord2i(newImageL->width,0); glVertex2i(newImageL->width,0);

glEnd();



LEye = FALSE;

}

else

{



glDrawBuffer(GL_BACK_RIGHT);



glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluOrtho2D(0.0,(GLdouble)newImageR->width,(GLdouble)newImageR->height,0.0);



glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective

glLoadIdentity(); //Reset the drawing perspective



glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, newImageR->width, newImageR->height, 0, GL_BGR, GL_UNSIGNED_BYTE, newImageR->imageData);



glBegin(GL_QUADS);

glTexCoord2i(0,0); glVertex2i(0,0);

glTexCoord2i(0,newImageR->height); glVertex2i(0,newImageR->height);

glTexCoord2i(newImageR->width,newImageR->height); glVertex2i(newImageR->width,newImageR->height);

glTexCoord2i(newImageR->width,0); glVertex2i(newImageR->width,0);

glEnd();



LEye = TRUE;

}

glDisable(GL_TEXTURE_2D);



glutSwapBuffers();

}



//Called every 25 milliseconds

void update(int value) {



glutPostRedisplay();

glutTimerFunc((1/30)*1000, update, 0); // 30 f/s

// glutTimerFunc(100, update, 0);

}



int main(int argc, char** argv) {

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

glutInitWindowSize(400, 400);



glutCreateWindow("Shutter");

initRendering();







glutDisplayFunc(drawScene);

glutKeyboardFunc(handleKeypress);

glutReshapeFunc(handleResize);

glutTimerFunc((1/30)*1000, update, 0);

// glutTimerFunc(100, update, 0);



glutMainLoop();

return 0;

}







Thank you for your help.

#2
Posted 10/13/2010 05:52 PM   
You need to enable quad buffered stereo in your application. Look the following link for settings in nvidia control panel

[url="http://www.nvidia.com/object/quadro_pro_graphics_boards.html"]http://www.nvidia.com/object/quadro_pro_graphics_boards.html[/url]


Look at the following website for sample code:

[url="http://www.gali-3d.com/archive/articles/StereoOpenGL/StereoscopicOpenGLTutorial.php"]http://www.gali-3d.com/archive/articles/St...nGLTutorial.php[/url]
You need to enable quad buffered stereo in your application. Look the following link for settings in nvidia control panel



http://www.nvidia.com/object/quadro_pro_graphics_boards.html





Look at the following website for sample code:



http://www.gali-3d.com/archive/articles/St...nGLTutorial.php

#3
Posted 10/14/2010 04:27 AM   
You need to enable quad buffered stereo in your application. Look the following link for settings in nvidia control panel

[url="http://www.nvidia.com/object/quadro_pro_graphics_boards.html"]http://www.nvidia.com/object/quadro_pro_graphics_boards.html[/url]


Look at the following website for sample code:

[url="http://www.gali-3d.com/archive/articles/StereoOpenGL/StereoscopicOpenGLTutorial.php"]http://www.gali-3d.com/archive/articles/St...nGLTutorial.php[/url]
You need to enable quad buffered stereo in your application. Look the following link for settings in nvidia control panel



http://www.nvidia.com/object/quadro_pro_graphics_boards.html





Look at the following website for sample code:



http://www.gali-3d.com/archive/articles/St...nGLTutorial.php

#4
Posted 10/14/2010 04:27 AM   
Thank you for the website with the sample codes but for some reasons when I try to run their example (such as fire_stereo), the program exits prematurely. I am not sure if it’s because it cannot identify my quadro graphic card or it is just a common error. Did you have a chance to test it? Did you experience the same problem? Please let me know what you think.
Thank you for the website with the sample codes but for some reasons when I try to run their example (such as fire_stereo), the program exits prematurely. I am not sure if it’s because it cannot identify my quadro graphic card or it is just a common error. Did you have a chance to test it? Did you experience the same problem? Please let me know what you think.

#5
Posted 10/18/2010 02:28 PM   
Thank you for the website with the sample codes but for some reasons when I try to run their example (such as fire_stereo), the program exits prematurely. I am not sure if it’s because it cannot identify my quadro graphic card or it is just a common error. Did you have a chance to test it? Did you experience the same problem? Please let me know what you think.
Thank you for the website with the sample codes but for some reasons when I try to run their example (such as fire_stereo), the program exits prematurely. I am not sure if it’s because it cannot identify my quadro graphic card or it is just a common error. Did you have a chance to test it? Did you experience the same problem? Please let me know what you think.

#6
Posted 10/18/2010 02:28 PM   
i think it aint gonna work. nvidia does not support opengl for a reason
i think it aint gonna work. nvidia does not support opengl for a reason

#7
Posted 10/18/2010 03:48 PM   
i think it aint gonna work. nvidia does not support opengl for a reason
i think it aint gonna work. nvidia does not support opengl for a reason

#8
Posted 10/18/2010 03:48 PM   
[quote name='dreamingawake' post='1132642' date='Oct 18 2010, 10:48 AM']i think it aint gonna work. nvidia does not support opengl for a reason[/quote]

OpenGL quad buffered stereo is supported by nvidia on the quadro cards. We use it everyday.
[quote name='dreamingawake' post='1132642' date='Oct 18 2010, 10:48 AM']i think it aint gonna work. nvidia does not support opengl for a reason



OpenGL quad buffered stereo is supported by nvidia on the quadro cards. We use it everyday.

#9
Posted 10/18/2010 04:03 PM   
[quote name='dreamingawake' post='1132642' date='Oct 18 2010, 10:48 AM']i think it aint gonna work. nvidia does not support opengl for a reason[/quote]

OpenGL quad buffered stereo is supported by nvidia on the quadro cards. We use it everyday.
[quote name='dreamingawake' post='1132642' date='Oct 18 2010, 10:48 AM']i think it aint gonna work. nvidia does not support opengl for a reason



OpenGL quad buffered stereo is supported by nvidia on the quadro cards. We use it everyday.

#10
Posted 10/18/2010 04:03 PM   
I don't use glut but from looking at your code, the GLUT_STEREO display mode bit mask is missing from your glutInitDisplayMode() call. You are not creating a stereo context so the GL_BACK_RIGHT drawbuffer does not exist. The glDrawBuffer(GL_BACK_RIGHT) call will fail and you will be rendering your right scene in the GL_BACK_LEFT drawbuffer.

Also, in drawScene() do you realize that you are only drawing either the left scene or the right scene - not both. Remove the "if (LEye) else" test to get both the left scene and right scene rendered each time drawScene() is called.


[quote name='lbv' post='1130306' date='Oct 13 2010, 12:52 PM']Hi all,

I wrote a program using OpenGL and Opencv to do the page-flipping between right and left frames for 3D vision. I purchased the 3D shutter glasses and the quadro FX1800 from Nvidia. The 3D glasses including the IR transmitter came with a driver that allows you to play a 3D video by combining a left and right video. However, I would like to play real time 3D straight from my OpenGL + OpenCV program. How do I connect my program to the Nvidia transmitter so that they can be synchronized with the shutter glasses? This is my codes;

#include <windows.h>
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <glew.h>
#include <glut.h>
#include <highgui.h>
//#include "imageloader.h"

using namespace std;

//The length of each side of the cube
const float BOX_SIZE = 7.0f;
//The OpenGL id of the texture

bool LEye=TRUE;
bool check = false;

GLuint cameraImageTextureID;
CvCapture * captureL = 0;
CvCapture * captureR = 0;

void handleKeypress(unsigned char key, int x, int y) {
switch (key) {
//Escape key
case 27:
glDeleteTextures(1, &cameraImageTextureID);
cvReleaseCapture( &captureL );
cvReleaseCapture( &captureR );
exit(0);
}
}


void initRendering()
{
glEnable(GL_DEPTH_TEST);
//glEnable(GL_LIGHTING);
//glEnable(GL_LIGHT0);
//glEnable(GL_NORMALIZE);
//glEnable(GL_COLOR_MATERIAL);

if (!check)
{
glEnable(GL_TEXTURE_RECTANGLE_ARB);
glGenTextures(2, &cameraImageTextureID);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, cameraImageTextureID);

captureL = cvCreateCameraCapture(0);

captureR = cvCreateCameraCapture(1);



}

check = true;
}

void handleResize(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, (float)w / (float)h, 1.0, 200.0);
}

void drawScene()
{

// initialize camera
IplImage* newImageL = cvQueryFrame( captureL );
IplImage* newImageR = cvQueryFrame( captureR );

glDrawBuffer(GL_BACK);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

//glTranslatef(0.0f, 0.0f, -20.0f);

//GLfloat ambientLight[] = {0.3f, 0.3f, 0.3f, 1.0f};
//glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight);

//GLfloat lightColor[] = {0.7f, 0.7f, 0.7f, 1.0f};
//GLfloat lightPos[] = {-2 * BOX_SIZE, BOX_SIZE, 4 * BOX_SIZE, 1.0f};
//glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor);
//glLightfv(GL_LIGHT0, GL_POSITION, lightPos);

if (LEye)
{

glDrawBuffer(GL_BACK_LEFT);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,(GLdouble)newImageL->width,(GLdouble)newImageL->height,0.0);

glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective
glLoadIdentity(); //Reset the drawing perspective

glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, newImageL->width, newImageL->height, 0, GL_BGR, GL_UNSIGNED_BYTE, newImageL->imageData);

glBegin(GL_QUADS);
glTexCoord2i(0,0); glVertex2i(0,0);
glTexCoord2i(0,newImageL->height); glVertex2i(0,newImageL->height);
glTexCoord2i(newImageL->width,newImageL->height); glVertex2i(newImageL->width,newImageL->height);
glTexCoord2i(newImageL->width,0); glVertex2i(newImageL->width,0);
glEnd();

LEye = FALSE;
}
else
{

glDrawBuffer(GL_BACK_RIGHT);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,(GLdouble)newImageR->width,(GLdouble)newImageR->height,0.0);

glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective
glLoadIdentity(); //Reset the drawing perspective

glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, newImageR->width, newImageR->height, 0, GL_BGR, GL_UNSIGNED_BYTE, newImageR->imageData);

glBegin(GL_QUADS);
glTexCoord2i(0,0); glVertex2i(0,0);
glTexCoord2i(0,newImageR->height); glVertex2i(0,newImageR->height);
glTexCoord2i(newImageR->width,newImageR->height); glVertex2i(newImageR->width,newImageR->height);
glTexCoord2i(newImageR->width,0); glVertex2i(newImageR->width,0);
glEnd();

LEye = TRUE;
}
glDisable(GL_TEXTURE_2D);

glutSwapBuffers();
}

//Called every 25 milliseconds
void update(int value) {

glutPostRedisplay();
glutTimerFunc((1/30)*1000, update, 0); // 30 f/s
// glutTimerFunc(100, update, 0);
}

int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(400, 400);

glutCreateWindow("Shutter");
initRendering();



glutDisplayFunc(drawScene);
glutKeyboardFunc(handleKeypress);
glutReshapeFunc(handleResize);
glutTimerFunc((1/30)*1000, update, 0);
// glutTimerFunc(100, update, 0);

glutMainLoop();
return 0;
}



Thank you for your help.[/quote]
I don't use glut but from looking at your code, the GLUT_STEREO display mode bit mask is missing from your glutInitDisplayMode() call. You are not creating a stereo context so the GL_BACK_RIGHT drawbuffer does not exist. The glDrawBuffer(GL_BACK_RIGHT) call will fail and you will be rendering your right scene in the GL_BACK_LEFT drawbuffer.



Also, in drawScene() do you realize that you are only drawing either the left scene or the right scene - not both. Remove the "if (LEye) else" test to get both the left scene and right scene rendered each time drawScene() is called.





[quote name='lbv' post='1130306' date='Oct 13 2010, 12:52 PM']Hi all,



I wrote a program using OpenGL and Opencv to do the page-flipping between right and left frames for 3D vision. I purchased the 3D shutter glasses and the quadro FX1800 from Nvidia. The 3D glasses including the IR transmitter came with a driver that allows you to play a 3D video by combining a left and right video. However, I would like to play real time 3D straight from my OpenGL + OpenCV program. How do I connect my program to the Nvidia transmitter so that they can be synchronized with the shutter glasses? This is my codes;



#include <windows.h>

#include <stdio.h>

#include <iostream>

#include <stdlib.h>

#include <glew.h>

#include <glut.h>

#include <highgui.h>

//#include "imageloader.h"



using namespace std;



//The length of each side of the cube

const float BOX_SIZE = 7.0f;

//The OpenGL id of the texture



bool LEye=TRUE;

bool check = false;



GLuint cameraImageTextureID;

CvCapture * captureL = 0;

CvCapture * captureR = 0;



void handleKeypress(unsigned char key, int x, int y) {

switch (key) {

//Escape key

case 27:

glDeleteTextures(1, &cameraImageTextureID);

cvReleaseCapture( &captureL );

cvReleaseCapture( &captureR );

exit(0);

}

}





void initRendering()

{

glEnable(GL_DEPTH_TEST);

//glEnable(GL_LIGHTING);

//glEnable(GL_LIGHT0);

//glEnable(GL_NORMALIZE);

//glEnable(GL_COLOR_MATERIAL);



if (!check)

{

glEnable(GL_TEXTURE_RECTANGLE_ARB);

glGenTextures(2, &cameraImageTextureID);

glBindTexture(GL_TEXTURE_RECTANGLE_ARB, cameraImageTextureID);



captureL = cvCreateCameraCapture(0);



captureR = cvCreateCameraCapture(1);







}



check = true;

}



void handleResize(int w, int h)

{

glViewport(0, 0, w, h);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluPerspective(45.0, (float)w / (float)h, 1.0, 200.0);

}



void drawScene()

{



// initialize camera

IplImage* newImageL = cvQueryFrame( captureL );

IplImage* newImageR = cvQueryFrame( captureR );



glDrawBuffer(GL_BACK);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);



glMatrixMode(GL_MODELVIEW);

glLoadIdentity();



//glTranslatef(0.0f, 0.0f, -20.0f);



//GLfloat ambientLight[] = {0.3f, 0.3f, 0.3f, 1.0f};

//glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight);



//GLfloat lightColor[] = {0.7f, 0.7f, 0.7f, 1.0f};

//GLfloat lightPos[] = {-2 * BOX_SIZE, BOX_SIZE, 4 * BOX_SIZE, 1.0f};

//glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor);

//glLightfv(GL_LIGHT0, GL_POSITION, lightPos);



if (LEye)

{



glDrawBuffer(GL_BACK_LEFT);



glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluOrtho2D(0.0,(GLdouble)newImageL->width,(GLdouble)newImageL->height,0.0);



glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective

glLoadIdentity(); //Reset the drawing perspective



glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, newImageL->width, newImageL->height, 0, GL_BGR, GL_UNSIGNED_BYTE, newImageL->imageData);



glBegin(GL_QUADS);

glTexCoord2i(0,0); glVertex2i(0,0);

glTexCoord2i(0,newImageL->height); glVertex2i(0,newImageL->height);

glTexCoord2i(newImageL->width,newImageL->height); glVertex2i(newImageL->width,newImageL->height);

glTexCoord2i(newImageL->width,0); glVertex2i(newImageL->width,0);

glEnd();



LEye = FALSE;

}

else

{



glDrawBuffer(GL_BACK_RIGHT);



glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluOrtho2D(0.0,(GLdouble)newImageR->width,(GLdouble)newImageR->height,0.0);



glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective

glLoadIdentity(); //Reset the drawing perspective



glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, newImageR->width, newImageR->height, 0, GL_BGR, GL_UNSIGNED_BYTE, newImageR->imageData);



glBegin(GL_QUADS);

glTexCoord2i(0,0); glVertex2i(0,0);

glTexCoord2i(0,newImageR->height); glVertex2i(0,newImageR->height);

glTexCoord2i(newImageR->width,newImageR->height); glVertex2i(newImageR->width,newImageR->height);

glTexCoord2i(newImageR->width,0); glVertex2i(newImageR->width,0);

glEnd();



LEye = TRUE;

}

glDisable(GL_TEXTURE_2D);



glutSwapBuffers();

}



//Called every 25 milliseconds

void update(int value) {



glutPostRedisplay();

glutTimerFunc((1/30)*1000, update, 0); // 30 f/s

// glutTimerFunc(100, update, 0);

}



int main(int argc, char** argv) {

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

glutInitWindowSize(400, 400);



glutCreateWindow("Shutter");

initRendering();







glutDisplayFunc(drawScene);

glutKeyboardFunc(handleKeypress);

glutReshapeFunc(handleResize);

glutTimerFunc((1/30)*1000, update, 0);

// glutTimerFunc(100, update, 0);



glutMainLoop();

return 0;

}







Thank you for your help.

#11
Posted 10/18/2010 04:08 PM   
I don't use glut but from looking at your code, the GLUT_STEREO display mode bit mask is missing from your glutInitDisplayMode() call. You are not creating a stereo context so the GL_BACK_RIGHT drawbuffer does not exist. The glDrawBuffer(GL_BACK_RIGHT) call will fail and you will be rendering your right scene in the GL_BACK_LEFT drawbuffer.

Also, in drawScene() do you realize that you are only drawing either the left scene or the right scene - not both. Remove the "if (LEye) else" test to get both the left scene and right scene rendered each time drawScene() is called.


[quote name='lbv' post='1130306' date='Oct 13 2010, 12:52 PM']Hi all,

I wrote a program using OpenGL and Opencv to do the page-flipping between right and left frames for 3D vision. I purchased the 3D shutter glasses and the quadro FX1800 from Nvidia. The 3D glasses including the IR transmitter came with a driver that allows you to play a 3D video by combining a left and right video. However, I would like to play real time 3D straight from my OpenGL + OpenCV program. How do I connect my program to the Nvidia transmitter so that they can be synchronized with the shutter glasses? This is my codes;

#include <windows.h>
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <glew.h>
#include <glut.h>
#include <highgui.h>
//#include "imageloader.h"

using namespace std;

//The length of each side of the cube
const float BOX_SIZE = 7.0f;
//The OpenGL id of the texture

bool LEye=TRUE;
bool check = false;

GLuint cameraImageTextureID;
CvCapture * captureL = 0;
CvCapture * captureR = 0;

void handleKeypress(unsigned char key, int x, int y) {
switch (key) {
//Escape key
case 27:
glDeleteTextures(1, &cameraImageTextureID);
cvReleaseCapture( &captureL );
cvReleaseCapture( &captureR );
exit(0);
}
}


void initRendering()
{
glEnable(GL_DEPTH_TEST);
//glEnable(GL_LIGHTING);
//glEnable(GL_LIGHT0);
//glEnable(GL_NORMALIZE);
//glEnable(GL_COLOR_MATERIAL);

if (!check)
{
glEnable(GL_TEXTURE_RECTANGLE_ARB);
glGenTextures(2, &cameraImageTextureID);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, cameraImageTextureID);

captureL = cvCreateCameraCapture(0);

captureR = cvCreateCameraCapture(1);



}

check = true;
}

void handleResize(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, (float)w / (float)h, 1.0, 200.0);
}

void drawScene()
{

// initialize camera
IplImage* newImageL = cvQueryFrame( captureL );
IplImage* newImageR = cvQueryFrame( captureR );

glDrawBuffer(GL_BACK);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

//glTranslatef(0.0f, 0.0f, -20.0f);

//GLfloat ambientLight[] = {0.3f, 0.3f, 0.3f, 1.0f};
//glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight);

//GLfloat lightColor[] = {0.7f, 0.7f, 0.7f, 1.0f};
//GLfloat lightPos[] = {-2 * BOX_SIZE, BOX_SIZE, 4 * BOX_SIZE, 1.0f};
//glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor);
//glLightfv(GL_LIGHT0, GL_POSITION, lightPos);

if (LEye)
{

glDrawBuffer(GL_BACK_LEFT);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,(GLdouble)newImageL->width,(GLdouble)newImageL->height,0.0);

glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective
glLoadIdentity(); //Reset the drawing perspective

glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, newImageL->width, newImageL->height, 0, GL_BGR, GL_UNSIGNED_BYTE, newImageL->imageData);

glBegin(GL_QUADS);
glTexCoord2i(0,0); glVertex2i(0,0);
glTexCoord2i(0,newImageL->height); glVertex2i(0,newImageL->height);
glTexCoord2i(newImageL->width,newImageL->height); glVertex2i(newImageL->width,newImageL->height);
glTexCoord2i(newImageL->width,0); glVertex2i(newImageL->width,0);
glEnd();

LEye = FALSE;
}
else
{

glDrawBuffer(GL_BACK_RIGHT);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,(GLdouble)newImageR->width,(GLdouble)newImageR->height,0.0);

glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective
glLoadIdentity(); //Reset the drawing perspective

glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, newImageR->width, newImageR->height, 0, GL_BGR, GL_UNSIGNED_BYTE, newImageR->imageData);

glBegin(GL_QUADS);
glTexCoord2i(0,0); glVertex2i(0,0);
glTexCoord2i(0,newImageR->height); glVertex2i(0,newImageR->height);
glTexCoord2i(newImageR->width,newImageR->height); glVertex2i(newImageR->width,newImageR->height);
glTexCoord2i(newImageR->width,0); glVertex2i(newImageR->width,0);
glEnd();

LEye = TRUE;
}
glDisable(GL_TEXTURE_2D);

glutSwapBuffers();
}

//Called every 25 milliseconds
void update(int value) {

glutPostRedisplay();
glutTimerFunc((1/30)*1000, update, 0); // 30 f/s
// glutTimerFunc(100, update, 0);
}

int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(400, 400);

glutCreateWindow("Shutter");
initRendering();



glutDisplayFunc(drawScene);
glutKeyboardFunc(handleKeypress);
glutReshapeFunc(handleResize);
glutTimerFunc((1/30)*1000, update, 0);
// glutTimerFunc(100, update, 0);

glutMainLoop();
return 0;
}



Thank you for your help.[/quote]
I don't use glut but from looking at your code, the GLUT_STEREO display mode bit mask is missing from your glutInitDisplayMode() call. You are not creating a stereo context so the GL_BACK_RIGHT drawbuffer does not exist. The glDrawBuffer(GL_BACK_RIGHT) call will fail and you will be rendering your right scene in the GL_BACK_LEFT drawbuffer.



Also, in drawScene() do you realize that you are only drawing either the left scene or the right scene - not both. Remove the "if (LEye) else" test to get both the left scene and right scene rendered each time drawScene() is called.





[quote name='lbv' post='1130306' date='Oct 13 2010, 12:52 PM']Hi all,



I wrote a program using OpenGL and Opencv to do the page-flipping between right and left frames for 3D vision. I purchased the 3D shutter glasses and the quadro FX1800 from Nvidia. The 3D glasses including the IR transmitter came with a driver that allows you to play a 3D video by combining a left and right video. However, I would like to play real time 3D straight from my OpenGL + OpenCV program. How do I connect my program to the Nvidia transmitter so that they can be synchronized with the shutter glasses? This is my codes;



#include <windows.h>

#include <stdio.h>

#include <iostream>

#include <stdlib.h>

#include <glew.h>

#include <glut.h>

#include <highgui.h>

//#include "imageloader.h"



using namespace std;



//The length of each side of the cube

const float BOX_SIZE = 7.0f;

//The OpenGL id of the texture



bool LEye=TRUE;

bool check = false;



GLuint cameraImageTextureID;

CvCapture * captureL = 0;

CvCapture * captureR = 0;



void handleKeypress(unsigned char key, int x, int y) {

switch (key) {

//Escape key

case 27:

glDeleteTextures(1, &cameraImageTextureID);

cvReleaseCapture( &captureL );

cvReleaseCapture( &captureR );

exit(0);

}

}





void initRendering()

{

glEnable(GL_DEPTH_TEST);

//glEnable(GL_LIGHTING);

//glEnable(GL_LIGHT0);

//glEnable(GL_NORMALIZE);

//glEnable(GL_COLOR_MATERIAL);



if (!check)

{

glEnable(GL_TEXTURE_RECTANGLE_ARB);

glGenTextures(2, &cameraImageTextureID);

glBindTexture(GL_TEXTURE_RECTANGLE_ARB, cameraImageTextureID);



captureL = cvCreateCameraCapture(0);



captureR = cvCreateCameraCapture(1);







}



check = true;

}



void handleResize(int w, int h)

{

glViewport(0, 0, w, h);

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluPerspective(45.0, (float)w / (float)h, 1.0, 200.0);

}



void drawScene()

{



// initialize camera

IplImage* newImageL = cvQueryFrame( captureL );

IplImage* newImageR = cvQueryFrame( captureR );



glDrawBuffer(GL_BACK);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);



glMatrixMode(GL_MODELVIEW);

glLoadIdentity();



//glTranslatef(0.0f, 0.0f, -20.0f);



//GLfloat ambientLight[] = {0.3f, 0.3f, 0.3f, 1.0f};

//glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight);



//GLfloat lightColor[] = {0.7f, 0.7f, 0.7f, 1.0f};

//GLfloat lightPos[] = {-2 * BOX_SIZE, BOX_SIZE, 4 * BOX_SIZE, 1.0f};

//glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor);

//glLightfv(GL_LIGHT0, GL_POSITION, lightPos);



if (LEye)

{



glDrawBuffer(GL_BACK_LEFT);



glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluOrtho2D(0.0,(GLdouble)newImageL->width,(GLdouble)newImageL->height,0.0);



glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective

glLoadIdentity(); //Reset the drawing perspective



glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, newImageL->width, newImageL->height, 0, GL_BGR, GL_UNSIGNED_BYTE, newImageL->imageData);



glBegin(GL_QUADS);

glTexCoord2i(0,0); glVertex2i(0,0);

glTexCoord2i(0,newImageL->height); glVertex2i(0,newImageL->height);

glTexCoord2i(newImageL->width,newImageL->height); glVertex2i(newImageL->width,newImageL->height);

glTexCoord2i(newImageL->width,0); glVertex2i(newImageL->width,0);

glEnd();



LEye = FALSE;

}

else

{



glDrawBuffer(GL_BACK_RIGHT);



glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluOrtho2D(0.0,(GLdouble)newImageR->width,(GLdouble)newImageR->height,0.0);



glMatrixMode(GL_MODELVIEW); //Switch to the drawing perspective

glLoadIdentity(); //Reset the drawing perspective



glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGB, newImageR->width, newImageR->height, 0, GL_BGR, GL_UNSIGNED_BYTE, newImageR->imageData);



glBegin(GL_QUADS);

glTexCoord2i(0,0); glVertex2i(0,0);

glTexCoord2i(0,newImageR->height); glVertex2i(0,newImageR->height);

glTexCoord2i(newImageR->width,newImageR->height); glVertex2i(newImageR->width,newImageR->height);

glTexCoord2i(newImageR->width,0); glVertex2i(newImageR->width,0);

glEnd();



LEye = TRUE;

}

glDisable(GL_TEXTURE_2D);



glutSwapBuffers();

}



//Called every 25 milliseconds

void update(int value) {



glutPostRedisplay();

glutTimerFunc((1/30)*1000, update, 0); // 30 f/s

// glutTimerFunc(100, update, 0);

}



int main(int argc, char** argv) {

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);

glutInitWindowSize(400, 400);



glutCreateWindow("Shutter");

initRendering();







glutDisplayFunc(drawScene);

glutKeyboardFunc(handleKeypress);

glutReshapeFunc(handleResize);

glutTimerFunc((1/30)*1000, update, 0);

// glutTimerFunc(100, update, 0);



glutMainLoop();

return 0;

}







Thank you for your help.

#12
Posted 10/18/2010 04:08 PM   
[quote name='lbv' post='1132593' date='Oct 18 2010, 10:28 AM']Thank you for the website with the sample codes but for some reasons when I try to run their example (such as fire_stereo), the program exits prematurely. I am not sure if it’s because it cannot identify my quadro graphic card or it is just a common error. Did you have a chance to test it? Did you experience the same problem? Please let me know what you think.[/quote]


I have no problem running fire_stereo. I have tested it with quadro 580 as well as quadro 4000. Which quadro board are you using? In the sample code fire has three versions. Original would work on any board but interlaced and hwflipping would work only on a quadro board. If you run those on a non-quadro board then they exit prematurely. If you want to use it with nvidia 3d vision then you need to run hwflipping version. But it will work only when you have correct stereo settings in nvidia control panel. So did you set the parameters described in the following link?

[url="http://www.nvidia.com/object/quadro_pro_graphics_boards.html"]http://www.nvidia.com/object/quadro_pro_graphics_boards.html[/url]
[quote name='lbv' post='1132593' date='Oct 18 2010, 10:28 AM']Thank you for the website with the sample codes but for some reasons when I try to run their example (such as fire_stereo), the program exits prematurely. I am not sure if it’s because it cannot identify my quadro graphic card or it is just a common error. Did you have a chance to test it? Did you experience the same problem? Please let me know what you think.





I have no problem running fire_stereo. I have tested it with quadro 580 as well as quadro 4000. Which quadro board are you using? In the sample code fire has three versions. Original would work on any board but interlaced and hwflipping would work only on a quadro board. If you run those on a non-quadro board then they exit prematurely. If you want to use it with nvidia 3d vision then you need to run hwflipping version. But it will work only when you have correct stereo settings in nvidia control panel. So did you set the parameters described in the following link?



http://www.nvidia.com/object/quadro_pro_graphics_boards.html

#13
Posted 10/19/2010 05:24 PM   
[quote name='lbv' post='1132593' date='Oct 18 2010, 10:28 AM']Thank you for the website with the sample codes but for some reasons when I try to run their example (such as fire_stereo), the program exits prematurely. I am not sure if it’s because it cannot identify my quadro graphic card or it is just a common error. Did you have a chance to test it? Did you experience the same problem? Please let me know what you think.[/quote]


I have no problem running fire_stereo. I have tested it with quadro 580 as well as quadro 4000. Which quadro board are you using? In the sample code fire has three versions. Original would work on any board but interlaced and hwflipping would work only on a quadro board. If you run those on a non-quadro board then they exit prematurely. If you want to use it with nvidia 3d vision then you need to run hwflipping version. But it will work only when you have correct stereo settings in nvidia control panel. So did you set the parameters described in the following link?

[url="http://www.nvidia.com/object/quadro_pro_graphics_boards.html"]http://www.nvidia.com/object/quadro_pro_graphics_boards.html[/url]
[quote name='lbv' post='1132593' date='Oct 18 2010, 10:28 AM']Thank you for the website with the sample codes but for some reasons when I try to run their example (such as fire_stereo), the program exits prematurely. I am not sure if it’s because it cannot identify my quadro graphic card or it is just a common error. Did you have a chance to test it? Did you experience the same problem? Please let me know what you think.





I have no problem running fire_stereo. I have tested it with quadro 580 as well as quadro 4000. Which quadro board are you using? In the sample code fire has three versions. Original would work on any board but interlaced and hwflipping would work only on a quadro board. If you run those on a non-quadro board then they exit prematurely. If you want to use it with nvidia 3d vision then you need to run hwflipping version. But it will work only when you have correct stereo settings in nvidia control panel. So did you set the parameters described in the following link?



http://www.nvidia.com/object/quadro_pro_graphics_boards.html

#14
Posted 10/19/2010 05:24 PM   
Fire_stereo is working! I reinstalled all the drivers and adjusted the settings. Thank you for your help guys!
Fire_stereo is working! I reinstalled all the drivers and adjusted the settings. Thank you for your help guys!

#15
Posted 10/27/2010 02:46 PM   
  1 / 2    
Scroll To Top