Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

opencv-python imshow giving errors in mac

I installed opencv-python using pip install, in mac os. Now the cv2.imshow function giving following error

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

How can I solve this issue? Why doesn't the pip check opencv dependencies?

like image 916
Ras Avatar asked Dec 10 '16 11:12

Ras


People also ask

Does OpenCV work on Mac?

Follow the below steps to install the Opencv 4 package on macOS using the setup.py file: Step 1: Download the latest source package of Opencv 4 for python3 from here. Step 2: Extract the downloaded package using the following command. Step 3: Go inside the folder and Enter the following command to install the package.

Does OpenCV work on Mac M1?

Installation of OpenCV on the M1The first step is to install Homebrew if you don't have it. Homebrew is a dependency manager for MacOS, and we will use it to install miniforge. Then we install miniforge using Homebrew. Next we can set up a new virtual environment called cv with python 3.8.

What is cv2 Imshow in Python?

cv2. imshow() method is used to display an image in a window. The window automatically fits to the image size.


1 Answers

Seems launching imshow windows doesn't work when installing opencv-python from pypi. Instead remove that and follow the great instructions at http://www.pyimagesearch.com/2016/12/19/install-opencv-3-on-macos-with-homebrew-the-easy-way/

(Note that no longer need to use --HEAD tag, as of 3.2.0)

In short:

  • Ensure Xcode installed
  • brew tap homebrew/science
  • brew install opencv3 --with-contrib
  • echo /usr/local/opt/opencv3/lib/python2.7/site-packages >> (YOUR PYTHONPATH)/lib/python2.7/site-packages/opencv3.pth
like image 154
Brad M Avatar answered Oct 02 '22 09:10

Brad M