Skip to content

Qt opengl build fix#21194

Merged
opencv-pushbot merged 1 commit intoopencv:4.xfrom
whalenpt:qt_opengl_build_fix
Dec 10, 2021
Merged

Qt opengl build fix#21194
opencv-pushbot merged 1 commit intoopencv:4.xfrom
whalenpt:qt_opengl_build_fix

Conversation

@whalenpt
Copy link
Copy Markdown
Contributor

@whalenpt whalenpt commented Dec 4, 2021

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • [ x] I agree to contribute to the project under Apache 2 License.
  • [ x] To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • [x ] The PR is proposed to proper branch
  • [ x] There is reference to original bug report and related work
  • [ x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • [ x] The feature is well documented and sample code can be built with the project CMake
force_builders=Custom
build_image:Custom=qt:16.04
buildworker:Custom=linux-1,linux-4,linux-6

@whalenpt whalenpt mentioned this pull request Dec 4, 2021
6 tasks
@whalenpt whalenpt force-pushed the qt_opengl_build_fix branch from 5b8ca58 to c4f7e40 Compare December 4, 2021 15:55
@whalenpt
Copy link
Copy Markdown
Contributor Author

whalenpt commented Dec 4, 2021

Strange build test error:

Features2d_FLANN_Auto.regression :
C:\build\precommit_opencl\4.x\opencv\modules\features2d\test\test_nearestneighbors.cpp(115): error: Expected: (correctPerc) >= (.75), actual: 0.747 vs 0.75
correctMatches=747 pointsCount=1000

Test passed on my local Windows desktop and my updates didn't touch any code from the feature2d module.
Seems like this issue has been around awhile #9179

@alalek
Copy link
Copy Markdown
Member

alalek commented Dec 4, 2021

Ignore: #9179

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take a look on comments below.

@whalenpt whalenpt force-pushed the qt_opengl_build_fix branch from c4f7e40 to 6743e8d Compare December 9, 2021 05:14
Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for update!

find_package(Qt${QT_VERSION_MAJOR} COMPONENTS OpenGLWidgets QUIET)
if(NOT Qt${QT_VERSION_MAJOR}OpenGLWidgets_FOUND)
message(STATUS "Qt OpenGLWidgets component not found: turning off openGL")
set(WITH_OPENGL FALSE) # Alternatively set(WITH_QT FALSE)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WITH_OPENGL

It is global option for all OpenCV modules.

WITH_ variables should NOT be changed by detection scripts (its meaning - try to run auto-detection script for related feature).
We use HAVE_ variables to specify that mentioned feature is available and enabled.

Perhaps we should run set(QT_QTOPENGL_FOUND OFF) here.
This variable is used in this script only to enable HAVE_QT_OPENGL below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented change

public:
explicit OpenGlViewPort(QWidget* parent);

// Note: #define CV_OVERIDE = override (#include < opencv2/core/cvdef.h >)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we don't need this note really.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped the note

{
icvmouseEvent((QMouseEvent *)evnt, mouse_wheel);
QGLWidget::wheelEvent(evnt);
QWidget::wheelEvent(evnt);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenCVQtWidgetBase:: ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rescoped from QWidget to OpenCVQtWidgetBase

@whalenpt whalenpt force-pushed the qt_opengl_build_fix branch from 6743e8d to 5fa3b88 Compare December 9, 2021 20:49
Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for update!

Looks good to me 👍

if(QT_VERSION_MAJOR GREATER 5) # QGL -> QOpenGL
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS OpenGLWidgets QUIET)
if(NOT Qt${QT_VERSION_MAJOR}OpenGLWidgets_FOUND)
message(STATUS "Qt OpenGLWidgets component not found: turning off Qt openGL functionality")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

openGL

OpenGL

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to OpenGL

- QGLWidget changed to QOpenGLWidget in window_QT.h for Qt6 using
  typedef OpenCVQtWidgetBase for handling Qt version

- Implement Qt6/OpenGL functionality in window_QT.cpp

- Swap QGLWidget:: function calls for OpenCVQtWidgetBase:: function calls

- QGLWidget::updateGL deprecated, swap to QOpenGLWidget::update for Qt6

- Add preprocessor definition to detect Qt6 -- HAVE_QT6

- Add OpenGLWidgets to qdeps list in highgui CMakeLists.txt

- find_package CMake command added for locating Qt module OpenGLWidgets

- Added check that Qt6::OpenGLWidgets component is found. Shut off Qt-openGL functionality if not found.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants