Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GUI support (Qt) #17

Closed
esc opened this issue Oct 26, 2016 · 22 comments
Closed

Add GUI support (Qt) #17

esc opened this issue Oct 26, 2016 · 22 comments

Comments

@esc
Copy link

esc commented Oct 26, 2016

Hi, I am having trouble with the library, I installed it and tried to use it on:

https://github.com/gliese581gg/YOLO_tensorflow

But the error I get when trying to run it is:

OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvShowImage, file /io/opencv/modules/highgui/src/window.cpp, line 545
Traceback (most recent call last):
  File "YOLO_small_tf.py", line 250, in <module>
    main(sys.argv)
  File "YOLO_small_tf.py", line 245, in main
    yolo = YOLO_TF(argvs)
  File "YOLO_small_tf.py", line 30, in __init__
    if self.fromfile is not None: self.detect_from_file(self.fromfile)
  File "YOLO_small_tf.py", line 137, in detect_from_file
    self.detect_from_cvmat(img)
  File "YOLO_small_tf.py", line 129, in detect_from_cvmat
    self.show_results(img,self.result)
  File "YOLO_small_tf.py", line 225, in show_results
    cv2.imshow('YOLO_small detection',img_cp)
cv2.error: /io/opencv/modules/highgui/src/window.cpp:545: error: (-2) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function cvShowImage
@skvark
Copy link
Member

skvark commented Oct 26, 2016

On which OS you get this error? The error appears because OpenCV provided by this repo has not been built with GTK support (it can be enabled, but it requires work at least on Linux due to the Cent OS 5 containers).

@esc
Copy link
Author

esc commented Oct 26, 2016

Ubuntu 16.04

@cachitas
Copy link

cachitas commented Nov 2, 2016

Just to be more specific, I've encountered this problem when using cv2.imshow() and cv2.waitKey().

@skvark
Copy link
Member

skvark commented Nov 4, 2016

The error says: "Rebuild the library with Windows, GTK+ 2.x or Carbon support.". OpenCV needs to be compiled with GTK support (WITH_GTK=ON). Currently I'm too busy to add support for this, but I'll have a look at the issue as soon as I have more spare time. Same thing with ffmpeg on Linux. Testing the builds is very time consuming stuff.

@esc
Copy link
Author

esc commented Nov 4, 2016

it would be very convenient for us to get this working, is there anything I can do to help?

@skvark
Copy link
Member

skvark commented Nov 6, 2016

You can fork the repo and try to tune the build scripts. First you should try to install GTK+ 2.x to the CentOS container (yum install gtk2 might be enough) and after that make OpenCV build scripts to find it. After that write some test scripts which utilize for example cv2.imshow() to confirm that the build was ok.

@fmntf
Copy link

fmntf commented Apr 27, 2017

Hi. Any progress on this?

@skvark
Copy link
Member

skvark commented Apr 29, 2017

I haven't had time to look at this.

@Greendogo
Copy link

This still needs to be fixed badly. Any progress on this critical issue?

OpenCV is rather useless for computer vision if you can't use it to efficiently display output.

@skvark
Copy link
Member

skvark commented Jun 22, 2017

I have an idea how this could be implemented. However, introducing a new dependency (GTK) without breaking the library import on every system is not an easy task. After all, there are hundreds of GNU/Linux distributions which don't necessarily have GTK binaries easily available (including the Cent OS 5 containers where the packages are built). Implementing this will take time and surely you know that I'm doing this for free on my limited free time.

Additionally, I don't think that OpenCV is useless without GUI features. It was never meant to be a comprehensive GUI framework. It might be good for showing images for debugging purposes, but there are many better ways to draw the images on the screen if needed. Here are few suggestions:

  • matplotlib
  • PIL (pillow)
  • scikit-image
  • tkinter
  • kivy

And you can always build OpenCV from sources.

@huan
Copy link

huan commented Jun 25, 2017

I suggest we consider to publish an OpenCV python module with Gtk/Qt support.

Today I spent serval hours on building OpenCV from scratch in order to use cv2.imshow(), it's very painful.

If add new dependency is a problem, how about publishing a new module with Gtk/Qt support, like opencv-python-gtk and opencv-python-qt ?

@Greendogo
Copy link

I second having two additional modules for gtk and qt. I found that qt was easier to get working than gtk, but I'm on Ubuntu, so it wasn't super difficult. I don't think Cent OS 5 has either GTK+ 2.x (which is what imshow requires) or Qt by default, so that might not work for skvark.

@skvark - I've tried using those libraries for my purposes, however sometimes that requires rewriting large portions of code that already should work with OpenCV to instead work with another image display library. Another problem is performance, OpenCV displays images fast, which is definitely important for demo-ing a live feed from a tracking network (for example).

@skvark skvark changed the title Trouble using library Add GUI support (GTK+) Aug 14, 2017
@skvark
Copy link
Member

skvark commented Aug 14, 2017

I'll try to compile the packages with GTK to avoid separate packages. I hope that auditwheel / delocate can handle the dependencies automatically and embed them to the wheels. For this to work I have to fork the manylinux CentOS 5 containers and build GTK support to them manually since the default GTK provided in the EL5 repos is too old (2.10 and OpenCV needs at least 2.18). This should be easy with Docker. For macOS I'll have to go with homebrew and hope that the build times don't get too long.

@skvark skvark changed the title Add GUI support (GTK+) Add GUI support (Qt) Sep 2, 2017
@skvark
Copy link
Member

skvark commented Sep 2, 2017

I have been testing different build setups during the last two weeks. Building newer version of GTK was too complicated so instead of GTK I built Qt 4.8.7 manually on the manylinux containers. These new customized containers seem to be working fine and the Linux wheels should have GUI support in the upcoming releases.

I'll see if I can enable Qt on macOS builds too.

EDIT: Looks like I can build with Qt 4.8.7 also on macOS (Qt was preinstalled on the Travis macOS images).

@skvark
Copy link
Member

skvark commented Sep 3, 2017

The release builds for 3.3.0.10 are now in progress and the GUI supported wheels should be available to install during the next couple of hours. Please report if you have any issues with them.

@skvark skvark closed this as completed Sep 3, 2017
@owend
Copy link

owend commented Sep 7, 2017

Hi, I did run into an issue with headless (docker) versions of ubuntu. #44 I think anyone running opencv-python in a cloud environment without X11 is going to have the same issue.

@YerongLi
Copy link

Get exact a same error, any idea on the a best way to fix this?

@slhodak
Copy link

slhodak commented Oct 20, 2018

Should I be using a different IDE to avoid this error? I'm currently using Xcode 9.

@skvark
Copy link
Member

skvark commented Oct 21, 2018

Could you elabolarate a bit more what it is excatly you're trying to do? This issue has been closed over a year ago. All recent opencv-python (given that you installed opencv-python as described in the README) releases have GUI support. The IDE you use is not related to this library in any way.

@KBor-DSIC
Copy link

pip install opencv-python fixed this issue for me

@be42day
Copy link

be42day commented Jul 10, 2021

It's because of 'opencv-python-headless'. Uninstall it!
pip uninstall opencv-python-headless

@arafatx
Copy link

arafatx commented Sep 28, 2023

This one work for me on facefusion installation

pip uninstall opencv-python-headless -y 

pip install opencv-python --upgrade

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests