Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opencv imshow crashes python launcher on macOS 11.0.1 (Big Sur)

I'm trying to run some old code from gaussian filter when I find out that python launcher gets stuck trying to do the imshow function. I tried:

  • Used Matplotlib to display a graph to see if the python launcher was the problem but no, graph showed up fine.

  • Remove process in between just to have the image read and display in fear that something in my code was breaking the launcher but no success.

  • Reinstalled opencv-python but no success.

Also saw one question like this in the google search but OP deleted it.

Has anyone encounter this issue or has any fix for this?

Example code:

import cv2 as cv
filename = 'chessboard.png'
img = cv.imread(filename)
cv.imshow('dst',img)
cv.waitKey(0)

OS: MacOS Big Sur (11.0.1)

like image 347
carlosguso Avatar asked Nov 14 '20 20:11

carlosguso


4 Answers

I also encounter this problem when I upgraded to Big Sur.

  1. Uninstall anaconda(every package), and reinstall python.

  2. pip install opencv-python opencv-python-headless

  3. This does help me with imshow() but I can't run cv.face. This attribute is not found.

  4. This solve my problem

pip install --force-reinstall opencv-contrib-python==4.1.2.30 This downgrade gets my code working again.

like image 159
Tylerastro Avatar answered Oct 20 '22 04:10

Tylerastro


I resolved the issue with below steps:

  1. Install the anaconda.
  2. Install the libraries needed.
  3. Run the script, there is an error appeared as below:

You might be loading two sets of Qt binaries into the same process. Check that all plugins are compiled against the right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries are being loaded.

  1. then I installed two libraies:

pip install opencv-python opencv-python-headless

  1. Retry run the script, the image can be shown on the left top of the monitor.
like image 22
Sam Ho Avatar answered Oct 20 '22 03:10

Sam Ho


I was also facing the same problem. I solved it by just installing opencv-python-headless. use:

pip install opencv-python-headless
like image 30
Alvin Solomon Avatar answered Oct 20 '22 03:10

Alvin Solomon


I also ran into this problem after installing macOS Big Sur. It was not only cv2.imshow() that did not respond but also cv2.namedWindow()

cv2.imread() was working however.

Solution was to install opencv-python-headless as others have said before

like image 30
Johnny Avatar answered Oct 20 '22 03:10

Johnny