opencv-python icon indicating copy to clipboard operation
opencv-python copied to clipboard

Turn back on Qt support for macOS

Open daveisfera opened this issue 2 years ago • 9 comments

Expected behaviour

Qt support is still used on macOS

Actual behaviour

Cocoa support is used so advanced functionality (like zooming) isn't available

Steps to reproduce

  • example code pip install opencv-python
  • operating system 11.5.2
  • architecture (e.g. x86) x86
  • opencv-python version 4.5.3.56

Related to #376 and #423

Issue submission checklist
  • [X] This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)
  • [X] I have read the README of this repository and understand that this repository provides only an automated build toolchain for OpenCV Python packages (there is no actual OpenCV code here)
  • [X] The issue is related to the build scripts in this repository, to the pre-built binaries or is a feature request (such as "please enable this additional dependency")
  • [X] I'm using the latest version of opencv-python

I'd like to help get the Qt support turned back on. Qt 5.15.2 is available now and there were 56 macOS bug fixes in 5.15.1 and then 11 macOS bug fixes in 5.15.2, so I'm hopeful that the issue is resolved and turning back on Qt support would work again

daveisfera avatar Sep 08 '21 20:09 daveisfera

Qt back-end is heavy dependency to build, maintain and update for each MacOS version. Also the dependency raises conflict with other Qt-based packages like PyQT. OpenCV team does not plan to step back to Qt back-end in nearest future without strong technical reason or strong community demand. As alternative you can build own instance of package with custom dependencies.

asmorkalov avatar Sep 10 '21 08:09 asmorkalov

I believe OpenCV in conda-forge uses Qt:

# install miniconda
conda create -n opencv -c conda-forge opencv
conda activate opencv
python -c 'import cv2; print(cv2.getBuildInformation())'

mshabunin avatar Sep 10 '21 09:09 mshabunin

I definitely agree that Qt is a heavy dependency, but it also adds several very useful features to the image viewer (the zoom and pan is what I use the most), so I'd love to see it turned back on because I prefer being able to use software from pip whenever possible to keep things portable and simple

daveisfera avatar Sep 10 '21 23:09 daveisfera

To build a custom version with your own dependencies (including Qt): pip install --no-binary opencv-python opencv-python

Check readme for more detailed build instructions: https://github.com/opencv/opencv-python#manual-builds

skvark avatar Sep 13 '21 10:09 skvark

For a custom build to add Qt support, wouldn't the removed code/build need to be put back and a flag added to enable it?

daveisfera avatar Sep 13 '21 16:09 daveisfera

For a custom build to add Qt support, wouldn't the removed code/build need to be put back and a flag added to enable it?

I'm not sure if I follow, but if CMake does not find Qt (or other dependencies) from your system automatically, then you'll need to provide custom flags such as WITH_QT=5 etc. before the build command.

skvark avatar Sep 15 '21 13:09 skvark

Doesn't this commit remove the ability to build with Qt?

daveisfera avatar Sep 15 '21 22:09 daveisfera

No, it doesn't. All those lines are related to the CI build in this repository when CI_BUILD flag has been set to true. They are run only on CI to create the portable wheel packages.

See: https://github.com/opencv/opencv-python/blob/c1cc7e5652d2a55e0bf603a9e021f5300a99caee/setup.py#L175

Local builds can be configured freely to include anything you wish. By default setup.py (which is executed when you call pip install --no-binary opencv-python opencv-python) runs the OpenCV CMake script which will enable all dependencies it can find from your system.

skvark avatar Sep 18 '21 12:09 skvark

BTW, Qt automatic searching is disabled by default in OpenCV upstream repo: https://github.com/opencv/opencv/blob/4.5.3/CMakeLists.txt#L332

alalek avatar Sep 18 '21 13:09 alalek