cv::namedWindow with QT button AND CV_WINDOW_OPENGL ?

asked 2015-06-09 12:09:55 -0500

zazarb gravatar image

updated 2020-03-14 22:08:44 -0500

supra56 gravatar image

Hello, I am trying to use opencv with opengl support. So far, using the provided example in the documentation and some help on the web I've managed to create a callback on a window created with opengl support that displays my webcam's video as a texture inside the window (see code below). However, when I add QT buttons to a control panel with cv::createButton() the control panel does not show, even if I use CV_GUI_EXPANDED (the mouse's right button menu doesnt show up). Is there something that I am doing wrong or is it not possible to combine QT and OpenGL ? Thanks for your help.

// ***MAIN***

// create window
cv::namedWindow("video", CV_GUI_EXPANDED | CV_WINDOW_OPENGL); 

// create buttons
char* calibBtn = "calibrate camera";
cv::createButton(calibBtn, CalibCallBack, &frame, QT_PUSH_BUTTON, 1);

resizeWindow("video", frame.cols, frame.rows);

ogl::Texture2D tex;
setOpenGlDrawCallback("video", on_opengl, &tex);

for (;;){
  // Do stuff on frame
  tex.copyFrom(frame); // copy current frame to texture

//*** CALLBACK ***
void on_opengl(void* userdata){
    ogl::Texture2D* pTex = static_cast<ogl::Texture2D*>(userdata);
        cv::Rect_<double> wndRect = Rect_<double>(0.0, 0.0, 1.0, 1.0);
    cv::Rect_<double> texRect = Rect_<double>(0.0, 0.0, 1.0, 1.0);
    ogl::render(*pTex, wndRect, texRect);
edit retag flag offensive close merge delete


You could test this without OpenGL to see if the problem is there or just dome Qt related issue.

mvuori gravatar imagemvuori ( 2020-03-16 02:54:27 -0500 )edit