opencv / opencv-python

Automated CI toolchain to produce precompiled opencv-python, opencv-python-headless, opencv-contrib-python and opencv-contrib-python-headless packages.
https://pypi.org/project/opencv-python/
MIT License
4.54k stars 851 forks source link

Turn back on Qt support for macOS #540

Open daveisfera opened 3 years ago

daveisfera commented 3 years ago

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

Related to #376 and #423

Issue submission checklist

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

asmorkalov commented 3 years ago

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.

mshabunin commented 3 years ago

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())'
daveisfera commented 3 years ago

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

skvark commented 3 years ago

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

daveisfera commented 3 years ago

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?

skvark commented 3 years ago

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.

daveisfera commented 3 years ago

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

skvark commented 3 years ago

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.

alalek commented 3 years ago

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