/* Image Processing and Recognition Module for the IUPGLCAP application. */ /* It should not contain interface code, neither OpenGL nor IUP. */ #ifdef WIN32 #include /* necessary because of the Microsoft OpenGL headers dependency */ #endif #include #include #include #include #include "glut.h" #include "ARProcess.h" #include "PatternMatchDLL.h" #include "tsai.h" #include #include #include #include #include #include int safeArea[1000]; int calibrated; double modelview[16]; double projection[16]; int width, height; unsigned char* rgbImageAux[2]; unsigned char *leftImage; unsigned char *rightImage; /* * Primitivas para inicializar o OpenGL */ void initOpenGL() { // gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f); glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.5f); glClearDepth(1.0f); // glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); } /* * Inicializa o módulo. */ void arInit(int w, int h) { int i; width = w; height = h; for(i=0; i<2; i++) rgbImageAux[i] = (unsigned char*)malloc(3*w*h*sizeof(unsigned char)); initPatternMatch(w, h); initOpenGL(); } /* * Acende um pixel em uma imagem. */ __inline void drawPixel(unsigned char* img, int width, int height, int x, int y, unsigned char r, unsigned char g, unsigned char b) { int index = 3*(y*width + x); img[index ] = r; img[index+1] = g; img[index+2] = b; } /* * Desenha um ponto em uma imagem. */ __inline void drawPoint(unsigned char* img, int width, int height, int x, int y, unsigned char r, unsigned char g, unsigned char b) { if((x<1)||(x>=width-1)||(y<1)||(y>=height-1)) return; drawPixel(img, width, height, x, y, r, g, b); drawPixel(img, width, height, x-1, y, r, g, b); drawPixel(img, width, height, x+1, y, r, g, b); drawPixel(img, width, height, x, y-1, r, g, b); drawPixel(img, width, height, x, y+1, r, g, b); drawPixel(img, width, height, x-1, y-1, r, g, b); drawPixel(img, width, height, x+1, y+1, r, g, b); drawPixel(img, width, height, x+1, y-1, r, g, b); drawPixel(img, width, height, x-1, y+1, r, g, b); } /* * Copia uma imagem. */ __inline void copyImg(unsigned char* rgb_from, unsigned char* rgb_to, int width, int height) { int i, lastIndex; lastIndex = width*height*3; for(i=0; i