问题
I purchased a M1 Mac. Is anyone having issues with imshow with opencv. I did pip install opencv-python and brew install opencv and brew install opencv as well.
import cv2
import urllib
import numpy as np
import requests
url = 'https://www.visitcalifornia.com/sites/visitcalifornia.com/files/styles/welcome_image/public/vc_crtr_borntobewild_module_mendocino_st_rf_623667652_1280x640.jpg'
from skimage import io
img = io.imread(url)
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
cv2.imshow('URL Image', img)
cv2.waitKey()
and also
import cv2
cv2.namedWindow("preview")
vc = cv2.VideoCapture(0)
if vc.isOpened(): # try to get the first frame
rval, frame = vc.read()
else:
rval = False
while rval:
cv2.imshow("preview", frame)
rval, frame = vc.read()
key = cv2.waitKey(20)
if key == 27: # exit on ESC
break
cv2.destroyWindow("preview")
vc.release()
does not work for me
回答1:
It was solved by
pip install opencv-python opencv-python-headless
回答2:
I was able to solve this by building from the source code of OpenCV 4.5, use this link to get the source code
回答3:
Try to install Miniconda from https://docs.conda.io/en/latest/miniconda.html
then activate it and try to install cv2 pip install opencv-python
getting 80-90 FPS for just reading image & showing
from my side, all are working in M1 using Miniconda
来源:https://stackoverflow.com/questions/65278632/opencv-issues-with-m1-mac-opencv-imshow-doesnot-work