opencv-python: Opencv imshow() not showing icons

System information

OS: Ubutun 16.04 Container: Yes created with singularity 3.2.1 Pylibfreenect2 installation: Installed with pip Python version: 3.7 Virtual environment: Conda Enviroment

Problem description

When running the pylibfreenect multiframe_listener.py example the cv2.imshow window doesn’t show icons. I also raised an issue on the repository of the pylibfreenect package but as I am not sure if the problem has to do with a missing pylibfreenect or opencv dependency I also opened a topic here.

Expected

image

Current

image

Troubleshooting steps

I am currently looking at whether a system icon package is missing and whether this is a bug related to opencv.

What I already tried

  1. Installing opencv from different channels:
  • pip install opencv
  • conda install opencv
  • conda install opencv-python
  1. Installing GTK and VTK as explained in this topic.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 23 (6 by maintainers)

Most upvoted comments

This is not a bug. Shipping the icons along the packages would be a license violation and cannot be done. OpenCV team is looking for an alternative icon set that does not have such a restrictive license. Please follow the issue here: https://github.com/opencv/opencv-python/issues/585

Had the same issue and solved it by installing & removing opencv-contrib-python.

pip install --user opencv-contrib-python
pip uninstall  opencv-contrib-python

FYI, I’m on Fedora 31.

@TheodoreT Thanks for your message. For me, the only solution that help was to switch to the conda package. I However opened the topic so that @native-api or any of the other maintainers can look into your question.

@jcbritobr This issue was closed since it is not a problem with the opencv-python package but is the result of how a user sets up the python environment and installs the required packages. The comments above, especially #213 (comment) explain how to solve the icons missing problem.

I did a fresh installation that way

julio@jcbritobr:~/Workspace/python$ mkdir test_issue
julio@jcbritobr:~/Workspace/python$ cd test_issue/
julio@jcbritobr:~/Workspace/python/test_issue$ python3 -m venv test_issue
julio@jcbritobr:~/Workspace/python/test_issue$ . test_issue/bin/activate
(test_issue) julio@jcbritobr:~/Workspace/python/test_issue$ pip install opencv-python
Collecting opencv-python
  Using cached opencv_python-4.5.5.62-cp36-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (60.4 MB)
Collecting numpy>=1.17.3; python_version >= "3.8"
  Using cached numpy-1.22.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.8 MB)
Installing collected packages: numpy, opencv-python
Successfully installed numpy-1.22.0 opencv-python-4.5.5.62
(test_issue) julio@jcbritobr:~/Workspace/python/test_issue$ code .

Its happening yet even only installing that way you show in #213 image

Why this bug is closed, if it is still happenning?

On a clean MacOS Catalina withous macports od homebrew I have created a virtual environment and installed numpy, opencv, and QT5

pip install numpy
pip install opencv-python
pip install pyqt5

And then ran the following program

import cv2
img = cv2.imread("m.png")
cv2.imshow("Mountains", img)
cv2.waitKey(0)
cv2.destroyAllWindows()

I had an error

qt.qpa.plugin: Could not find the Qt platform plugin "cocoa" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling  the application may fix this problem.

I removed opencv-python and verified that PyQt5 was working properly. Finally, i removed opencv-python and installed opencv-python-headless instead, allong with PyQt5. This time it worked well.

Is this the expected behavior? I found the package list and the installation order in a tutorial on OpenCV with Python on MacOS. The tutorial did not mention installation conflicts.

I found that if I do not install PyQt5 and install opencv-python in isolation, I have the same error.

@rickstaa thanks for the pkgs list. However, it does not seem that any of the other packages has to do anything with the icons. I would argue that the issue is related with the opencv pkg itself. Most likely the conda version and this one are kind of different created, or I do not know I might actually be wrong here.

@native-api Thanks for your response. This was indeed a problem with the opencv-contrib-pyton and opencv-python packages:

pip install opencv-python
pip install opencv-contrib-python

Like you stated above when creating a fresh conda environment and installing OpenCV directly using conda install -c conda-forge opencv both the error and the icon problem disappeared.