Skip to content

Commit

Permalink
Updated code.
Browse files Browse the repository at this point in the history
git-svn-id: http://ehci.googlecode.com/svn/trunk@235 90b23a45-e14c-0410-b226-357bb290934b
  • Loading branch information
danielbaggio@gmail.com committed Nov 14, 2010
1 parent ce2dfb4 commit 94d330b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 24 deletions.
6 changes: 4 additions & 2 deletions samples/6dofhand.cpp
Expand Up @@ -375,7 +375,7 @@ void DrawGLScene(void)
double glPositMatrix[16];
//TODO: correct the constants
//int detected = ehciLoop(EHCI6DHANDDETECT,initialGuess);
int detected = ehciLoop(12,initialGuess);
int detected = ehciLoop(12,initialGuess,0,640.0, 480.0);

getReferenceHeadBounds(&headRefX,&headRefY,&aLastHeadW, &aLastHeadH);

Expand Down Expand Up @@ -541,7 +541,9 @@ void keyPressed(unsigned char key, int x, int y)
void InitGL(GLsizei Width, GLsizei Height) // We call this right after our OpenGL window is created.
{

setGLProjectionMatrix(projectionMatrix);
double width = (double)Width;
double height = (double)Height;
setGLProjectionMatrix(projectionMatrix,width,height);


glEnable(GL_TEXTURE_2D); // Enable texture mapping.
Expand Down
35 changes: 19 additions & 16 deletions samples/6dofhead.cpp
Expand Up @@ -76,7 +76,7 @@ void drawHelpText(){
glColor3f(0.0f,0.0f,0.0f);

glRasterPos2f(10, 20);
const unsigned char text[100] ="Press I to reinitialize. You must focus this window\n(face the camera in a still position)";
const unsigned char text[100] ="Press \'I\' to reinitialize. You must focus this window\n(face the camera in a still position)";
for (int i = 0; i < 100; i++)
{
glutBitmapCharacter(font, text[i]);
Expand Down Expand Up @@ -619,20 +619,20 @@ void keyframeRelated(){

char *data=NULL;

void generateTexture(){
int dataPtr=640*480*3-1;
void generateTexture(int width, int height){
int dataPtr=width*height*3-1;
if(data==NULL)
data = (char*) malloc(640*480*3);
data = (char*) malloc(width*height*3);

glReadPixels(0,0,640,480,GL_BGR_EXT, GL_UNSIGNED_BYTE, data);
glReadPixels(0,0,width,height,GL_BGR_EXT, GL_UNSIGNED_BYTE, data);
if(!getGeneratedImage()){
setGeneratedImage(cvCreateImage( cvSize( 640, 480 ),
setGeneratedImage(cvCreateImage( cvSize( width, height),
IPL_DEPTH_8U, 3));
}
//TODO: try to use the pointer for increased performance
//generatedImage->imageData = data;

for( int y=0; y<480; y++ ) {
for( int y=0; y<height; y++ ) {
uchar* ptr = (uchar*) (
getGeneratedImage()->imageData + y * getGeneratedImage()->widthStep
);
Expand All @@ -649,17 +649,19 @@ void generateTexture(){
/* The main drawing function. */
void DrawGLScene(void)
{
double width = 320.0f;
double height = 240.0f;
static int bootstrap = 0;
CvMatr32f rotation_matrix = new float[9];
CvVect32f translation_vector = new float[3];
double glPositMatrix[16];
//cvWaitKey(0);
int detected=0;
if(getGeneratedImage()){
detected = ehciLoop(EHCI6DFACEDETECT,initialGuess,getGeneratedImage());
detected = ehciLoop(EHCI6DFACEDETECT,initialGuess,getGeneratedImage(),width,height);
}
else{
detected= ehciLoop(EHCI6DFACEDETECT,initialGuess);
detected= ehciLoop(EHCI6DFACEDETECT,initialGuess,0,width, height);
}
//detected= ehciLoop(EHCI6DFACEDETECT,initialGuess);

Expand Down Expand Up @@ -749,7 +751,7 @@ void DrawGLScene(void)


if(bootstrap)
generateTexture();
generateTexture(320,240);


if(drawAxis){
Expand Down Expand Up @@ -853,8 +855,9 @@ void keyPressed(unsigned char key, int x, int y)
/* A general OpenGL initialization function. Sets all of the initial parameters. */
void InitGL(GLsizei Width, GLsizei Height) // We call this right after our OpenGL window is created.
{

setGLProjectionMatrix(projectionMatrix);
double width = (double)Width;
double height = (double)Height;
setGLProjectionMatrix(projectionMatrix,width,height);


glEnable(GL_TEXTURE_2D); // Enable texture mapping.
Expand Down Expand Up @@ -913,14 +916,14 @@ void InitGL(GLsizei Width, GLsizei Height) // We call this right after our OpenG

}

void openGLCustomInit(int argc, char** argv ){
void openGLCustomInit(int argc, char** argv, double width, double height ){

glutInit(&argc, argv);

glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH);

/* get a 640 x 480 window */
glutInitWindowSize(640, 480);
glutInitWindowSize(width, height);

/* the window starts at the upper left corner of the screen */
glutInitWindowPosition(500, 0);
Expand Down Expand Up @@ -948,7 +951,7 @@ void openGLCustomInit(int argc, char** argv ){
// glutSpecialFunc(&specialKeyPressed);

/* Initialize our window. */
InitGL(640, 480);
InitGL(width, height);


/* Start Event Processing Engine */
Expand All @@ -966,7 +969,7 @@ int main( int argc, char** argv )
// cvNamedWindow( "6dofHead", 1 );
ehciInit();
atexit(ehciExit);
openGLCustomInit(argc,argv);
openGLCustomInit(argc,argv,320.0, 240.0);


//cvDestroyWindow("6dofHead");
Expand Down
2 changes: 1 addition & 1 deletion samples/boxView3d.cpp
Expand Up @@ -97,7 +97,7 @@ void detect_and_draw( )
int detectedHeadWidth,detectedHeadHeight;
int upperHeadX,upperHeadY;

ehciLoop(EHCI2DFACEDETECT,0);
ehciLoop(EHCI2DFACEDETECT,0,0,640.0, 480.0);
getHeadBounds(&upperHeadX,&upperHeadY,&detectedHeadWidth,&detectedHeadHeight );
CvPoint upperHeadCorner;
upperHeadCorner.x = upperHeadX;
Expand Down
2 changes: 1 addition & 1 deletion samples/simple2d.cpp
Expand Up @@ -18,7 +18,7 @@ int main(){
//so that the frame could be grabbed and processed
//the EHCI2DFACEDETECT parameter tells ehci that only 2d detection will be
//made
ehciLoop(EHCI2DFACEDETECT,0);
ehciLoop(EHCI2DFACEDETECT,0,0,640.0,480.0);
getHeadBounds(&upperX,&upperY,&headWidth,&headHeight);
printf("Head Coordinates %3d %3d head width %3d height %3d (count%d) (Press Ctrl+C to finish)\n",
upperX,upperY,headWidth,headHeight,loopCount);
Expand Down
2 changes: 1 addition & 1 deletion samples/simple3d.cpp
Expand Up @@ -25,7 +25,7 @@ int main(){
//initialize, when it is set to zero
//and tells ehci to track when it is set to one

ehciLoop(EHCI6DFACEDETECT,initialGuess);
ehciLoop(EHCI6DFACEDETECT,initialGuess,0,640.0, 480.0);

//returns translation and rotation matrix in openGl format
getGlPositMatrix(glPositMatrix);
Expand Down
7 changes: 4 additions & 3 deletions samples/zoomHand.cpp
Expand Up @@ -453,7 +453,7 @@ void DrawGLScene(void)
CvMatr32f rotation_matrix = new float[9];
CvVect32f translation_vector = new float[3];
double glPositMatrix[16];
int detected = ehciLoop(EHCI6DHANDDETECT,initialGuess);
int detected = ehciLoop(EHCI6DHANDDETECT,initialGuess,0,640.0, 480.0);

getReferenceHeadBounds(&headRefX,&headRefY,&aLastHeadW, &aLastHeadH);

Expand Down Expand Up @@ -646,8 +646,9 @@ void keyPressed(unsigned char key, int x, int y)
/* A general OpenGL initialization function. Sets all of the initial parameters. */
void InitGL(GLsizei Width, GLsizei Height) // We call this right after our OpenGL window is created.
{

setGLProjectionMatrix(projectionMatrix);
double width = (double)Width;
double height = (double)Height;
setGLProjectionMatrix(projectionMatrix,width,height);


glEnable(GL_TEXTURE_2D); // Enable texture mapping.
Expand Down

0 comments on commit 94d330b

Please sign in to comment.