Python OpenCV:无法使用FaceTime
我试图在mac中使用opencv和python来匹配对象 但我得到了这个错误Python OpenCV:无法使用FaceTime,python,opencv,orb,Python,Opencv,Orb,我试图在mac中使用opencv和python来匹配对象 但我得到了这个错误 OpenCV: Cannot Use FaceTime HD Kamera (Yerleşik) OpenCV: camera failed to properly initialize! Segmentation fault: 11 这也是我的代码 import numpy as np import cv2 import time ESC=27 camera = cv2.VideoCapture(0) or
OpenCV: Cannot Use FaceTime HD Kamera (Yerleşik)
OpenCV: camera failed to properly initialize!
Segmentation fault: 11
这也是我的代码
import numpy as np
import cv2
import time
ESC=27
camera = cv2.VideoCapture(0)
orb = cv2.ORB_create()
while True:
ret, imgCamColor = camera.read()
imgCamGray = cv2.cvtColor(imgCamColor, cv2.COLOR_BGR2GRAY)
kpCam = orb.detect(imgCamGray,None)
kpCam, desCam = orb.compute(imgCamGray, kpCam)
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
matches = bf.match(desCam,desTrain)
good = []
cv2.imshow('Camara', result)
key = cv2.waitKey(20)
if key == ESC:
break
cv2.destroyAllWindows()
camera.release()
我也试过一些东西。
但是它不起作用。我的OpenCV脚本也有同样的问题。我建议通过一个内置的应用程序(例如照相亭)测试相机。正如您在图像中看到的,没有检测到摄像头。解决方案非常简单,我重新启动了我的计算机或运行以下命令:
sudo killall vdcasistant
用于在重新启动计算机后测试OpenCV的脚本:
import cv2
cv2.namedWindow("preview")
vc = cv2.VideoCapture(0)
rval, frame = vc.read()
while True:
if frame is not None:
cv2.imshow("preview", frame)
rval, frame = vc.read()
if cv2.waitKey(1) & 0xFF == ord('q'):
break
杀掉VDCASSISSTANT进程强> 打开活动监视器并杀死VDCasistant
如果您使用的是MAC电脑,我实际上通过在“系统首选项”的“安全和隐私”部分授予终端访问摄像头的权限解决了这个问题。希望这能解决你Mac电脑的问题
我已经解决了这个问题。您应该授予使用相机到iTerm或terminal的权限
你弄明白了吗?在我的MacBook Pro上看到同样的东西。