Ask Your Question

F_Michele's profile - activity

2016-08-18 16:30:46 -0600 received badge  Famous Question (source)
2016-08-18 16:30:46 -0600 received badge  Notable Question (source)
2016-08-18 16:30:46 -0600 received badge  Popular Question (source)
2013-03-21 11:46:45 -0600 received badge  Teacher (source)
2013-03-21 09:32:06 -0600 received badge  Student (source)
2013-03-21 08:53:16 -0600 received badge  Supporter (source)
2013-03-21 08:50:50 -0600 answered a question set size of an window

You can also use resizeWindow()

2013-03-21 08:47:02 -0600 commented question OpenGL interoperability

@berak: the outcome is that just the webcam image is displayed. I put setOpenGLDrawCallback in the loop because every time that imshow is called when the OpenGL support is present it resets the drawCallback to a commodity function in order to show the image as a texture.

2013-03-21 08:34:18 -0600 received badge  Editor (source)
2013-03-21 08:33:31 -0600 answered a question CMake option to remove version number from libraries

you can try putting -avoid-version or --avoid-version in CMAKE_SHARED_LINKER_FLAGS or any related variable

2013-03-21 08:23:14 -0600 asked a question OpenGL interoperability

Hello all!

I'm under Linux and compiled OpenCV 2.4.4 with OpenGL support, but I don't have any idea of how using the opengl_interop.hpp functions (some of them are even undocumented!, at least on my version of documentation). Looking at window.cpp in the section with OpenGL enabled I found some hints about the use of the functions setOpenGLContext, setOpenGLDrawCallback and updateView but I can't get working even this very simple piece of code:

#include <opencv2/opencv.hpp>
#include <GL/gl.h>
#include <GL/glut.h>
#include <opencv2/core/opengl_interop.hpp>

using namespace cv;

void on_opengl(void* userdata);

int main(void)
{
    VideoCapture webcam(CV_CAP_ANY);
    Mat frame;
    namedWindow("window", CV_WINDOW_OPENGL);
    setOpenGlContext("window");
    while(waitKey(30) < 0)
    {
        webcam >> frame;
        setOpenGlDrawCallback("window", on_opengl);
        imshow("window", frame);
        updateWindow("window");
    }

    return 0;
}

void on_opengl(void* userdata)
{
    glLoadIdentity();

    glTranslated(0.0, 0.0, 1.0);

    glRotatef( 55, 1, 0, 0 );
    glRotatef( 45, 0, 1, 0 );
    glRotatef( 0, 0, 0, 1 );

    static const int coords[6][4][3] = {
        { { +1, -1, -1 }, { -1, -1, -1 }, { -1, +1, -1 }, { +1, +1, -1 } },
        { { +1, +1, -1 }, { -1, +1, -1 }, { -1, +1, +1 }, { +1, +1, +1 } },
        { { +1, -1, +1 }, { +1, -1, -1 }, { +1, +1, -1 }, { +1, +1, +1 } },
        { { -1, -1, -1 }, { -1, -1, +1 }, { -1, +1, +1 }, { -1, +1, -1 } },
        { { +1, -1, +1 }, { -1, -1, +1 }, { -1, -1, -1 }, { +1, -1, -1 } },
        { { -1, -1, +1 }, { +1, -1, +1 }, { +1, +1, +1 }, { -1, +1, +1 } }
    };

    for (int i = 0; i < 6; ++i) {
                glColor3ub( i*20, 100+i*10, i*42 );
                glBegin(GL_QUADS);
                for (int j = 0; j < 4; ++j) {
                        glVertex3d(0.2*coords[i][j][0], 0.2 * coords[i][j][1], 0.2*coords[i][j][2]);
                }
                glEnd();
    }
}

What is the right way of using opengl on the webcam stream? bye!