Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

cv::namedWindow with QT button AND CV_WINDOW_OPENGL ?

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);

setOpenGlContext("video"); 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 updateWindow("video"); }

//* 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); }

cv::namedWindow with QT button AND CV_WINDOW_OPENGL ?

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

// ***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);

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

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

&tex); for (;;){ // Do stuff on frame tex.copyFrom(frame); // copy current frame to texture updateWindow("video"); }

//* } //*** CALLBACK *** void on_opengl(void on_opengl(void* userdata){ ogl::Texture2D* pTex = static_cast<ogl::texture2d*>(userdata); 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); }

}