Projecting an image with opengl and anti-aliasing

In my work, I overlap part of the captured frame with the image. I open my webcam with openCV, and then convert the captured frame to a texture and display it in the GLUT window. In addition, I overlay part of this texture on this image:

enter image description here

I am doing this in real time, and the result is:

enter image description here

As you can see, the edges of the projected image are inaccurate. I think this is a smoothing problem, but I don't know how to make the smoothing process with opengl. I tried to search the Internet, but I did not find a good solution to my problem.

In my compute function, I will convert the mat image to a texture using the following code:

GLvoid calculate(){
...
...
cvtColor(image, image, CV_BGR2RGB);
    glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    glBindTexture(GL_TEXTURE_2D, textures[1]);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
    //glTexImage2D(GL_TEXTURE_2D, 0, 4,image.cols, image.rows, 0, GL_RGB,GL_UNSIGNED_BYTE, image.data);
    gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, image.cols, image.rows, GL_RGB, GL_UNSIGNED_BYTE, image.data);
}

and I will show the result using this code:

GLvoid Show(void) {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glEnable(GL_TEXTURE_2D);

    // Matrice di proiezione
    glMatrixMode (GL_PROJECTION);
    glLoadIdentity();
    gluOrtho2D(0, WIDTH, HEIGHT, 0); 

    // Matrice model view
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity(); 
...
...
glBindTexture(GL_TEXTURE_2D, textures[1]);
        glBegin(GL_QUADS);
        glTexCoord2f(0.0f, 0.0f); glVertex2f((GLfloat)((coord[3].x)),(GLfloat)(coord[3].y));
        glTexCoord2f(1.0f, 0.0f); glVertex2f((GLfloat)((coord[0].x)),(GLfloat)(coord[0].y));
        glTexCoord2f(1.0f, 1.0f); glVertex2f((GLfloat)((coord[1].x)),(GLfloat)(coord[1].y));
        glTexCoord2f(0.0f, 1.0f); glVertex2f((GLfloat)((coord[2].x)),(GLfloat)(coord[2].y)); 

        glEnd();    
    }
    glFlush();
    glutSwapBuffers();

}

In the initialization function, I write this:

GLvoid Init() {  

    glGenTextures(2, textures);
    glClearColor (0.0, 0.0, 0.0, 0.0);

    glEnable (GL_POLYGON_SMOOTH);
    glHint (GL_POLYGON_SMOOTH_HINT, GL_DONT_CARE);
    glDisable(GL_DEPTH_TEST);

}

but it does not work ...

Win7 x64, OPENGL 4.0 Glut 3.7. - NVidia GeForce gt 630. Nvidia, . - , ?

+5
2

, OpenGL 4.0 () ... . , MSAA. , . . GLUT, MSAA. , , GLFW. - , , FBO. FBO MSAA MSAA ( -, ). - .

GLFW MSAA . . API.

MSAA , , , OpenGL.

+2

! GLFW, GLUT, @Michael IV!

GLFW, :

glfwOpenWindowHint(GLFW_FSAA_SAMPLES,4);

, .

enter image description here

!

+3

All Articles