I'm trying to use opencv in my mac with python for matching objects .
But I'm getting this error.
OpenCV: Cannot Use FaceTime HD Kamera (Yerleşik)
OpenCV: camera failed to properly initialize!
Segmentation fault: 11
Also this is my code.
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()
I tried a few things too.
But its not worked.
XXD :
If You are Using MAC, I Actually Solved this Issue By Granting Permission for Terminal To Access Camera in Security and Privacy Section in System Preferences. Hope This Solves Issue In Your Mac\nClick Here To View Steps",
2019-04-16T08:38:42
Keith :
I had this same problem with my OpenCV script. I recommend testing the camera via a built in app (Ex. Photo Booth). As you see with the image, the camera wasn't being detected. The solution was pretty simple, I restarted my computer or run the following command: sudo killall VDCAssistant.\n\n\n\nMy script used for testing the OpenCV after restarting my computer:\n\nimport cv2\ncv2.namedWindow(\"preview\")\nvc = cv2.VideoCapture(0)\n\nrval, frame = vc.read()\n\nwhile True:\n\n if frame is not None:\n cv2.imshow(\"preview\", frame)\n rval, frame = vc.read()\n\n if cv2.waitKey(1) & 0xFF == ord('q'):\n break\n",
2017-03-08T18:02:52
Ritesh Gaur :
Kill VDCAssistant process!\n\nOpen Activity Monitor and kill VDCAssistant\n\n",
2019-03-19T07:02:12