0

I am using opencv-python by installing with pip install opencv-python, without building from sources.

Earlier I used to build opencv from sources, but the installation process was quite painful. The pip installation was so easy, and I could use most of its functions. One problem is that I cannot use cv2.imshow anymore (may because it requires OS GUIs?).

cv2.imshow("test",xx)

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 583

There are two questions:

  • Are there alternatives for cv2.imshow, which is light, simple, and proper to show image frames like a video?

  • In addition to imshow, are there more critical functions that I cannot use anymore if I only use the pip version?

YW P Kwon
  • 2,138
  • 5
  • 23
  • 39
  • 2
    You won't have the UI related stuff in [highgui](http://docs.opencv.org/2.4/modules/highgui/doc/highgui.html). You can just write your own display functionality, say with [tkinter](https://stackoverflow.com/questions/32342935/using-opencv-with-tkinter). – Dan Mašek Jun 20 '17 at 18:27
  • 1
    I have noticed some having success with installing opencv via Anaconda using `conda install -c menpo opencv` or `conda install -c conda-forge opencv`. You might need ffmpeg in your PATH as well. – Shawn Mathew Jun 20 '17 at 19:23

1 Answers1

3

The opencv-python package does not install the contrib modules and it is not compiled with ffmpeg, so things like imshow will not work on Linux or Mac, along with many other GUI features. See the official package index docs for opencv-python.

You'll get a much cleaner install compiling OpenCV from source. It's a little bit of a pain but it is worth it IMO; and you get better at it after a few installs. Learning cmake is valuable as well. I'm sure you've seen the oft-linked pyImageSearch tutorials for macOS and Ubuntu.

As an alternative that I've never seen on Stack before, Udacity has a self-driving car nanodegree course and they have an open repository on their GitHub for the starter kit. You simply install with conda (and also create a conda virtual environment in the process) and it comes with many additional libraries that are relevant to the course (e.g. TensorFlow, Matplotlib, Jupyter, ...). It installs with Python 3.5 and OpenCV 3.1.0. It works well cross-platform (incl. Windows) and is a breeze to set up. The instructions are on the repository's README.md file.

Lastly, there are many libraries for image processing or at least GUI interfaces that work far better than OpenCV's limited feature set, which was never meant to be exhaustive. A few you might try are matplotlib, PIL, scikit-image, and lastly really lightweight, nicely object oriented, plus comes preinstalled in Python tkinter. Even with the working normal interface, you'll probably find yourself wanting more functionality, which all of these provide to different degrees.

alkasm
  • 22,094
  • 5
  • 78
  • 94