Closed rudrarajurahul closed 3 years ago
Could you try this: cap = cv2.VideoCapture(cv2.CAP_DSHOW)
cap = cv2.VideoCapture(cv2.CAP_DSHOW) avoided the error. But I was just seeing a noisy flutter screen. Looks like its an issue with the systems webcam. When I tried to run a simple script to see if the code was able to access the webcam using
import cv2
cap = cv2.VideoCapture(0)
if not cap.isOpened(): raise IOError("Cannot open webcam")
while True: ret, frame = cap.read() frame = cv2.resize(frame, None, fx=0.5, fy=0.5, interpolation=cv2.INTER_AREA) cv2.imshow('Input', frame)
c = cv2.waitKey(1)
if c == 27:
break
cap.release() cv2.destroyAllWindows()
[ WARN:0] global C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-kh7iq4w7\opencv\modules\videoio\src\cap_msmf.cpp (912) CvCapture_MSMF::grabFrame videoio(MSMF): can't grab frame. Error: -2147483638
Traceback (most recent call last):
File "D:/Projects/exam_proctoring_model/Proctoring-AI-master/webcam_testing.py", line 12, in
[ WARN:1] global C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-kh7iq4w7\opencv\modules\videoio\src\cap_msmf.cpp (434) `anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback
Is there a specific opencv version that needs to be installed ?
The problem seems to be with the webcam itself. Can you try and use a saved video file? Just replace the 0 in cv2.VideoCapture with the file name in quotes.
The problem shouldn't be with the OpenCv vesion but if you want to have a shot in the dark you can try with Opencv 4.4
Ya the problem is with the system. I have kaspersky antivirus installed with is blocking the webcam to be accessed.
Right!
Appreciate your quick response. Thank You.
Hey. I am having trouble running eye_tracker.py file. It is unable to grab the frame.
[ WARN:0] global C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-kh7iq4w7\opencv\modules\videoio\src\cap_msmf.cpp (912) CvCapture_MSMF::grabFrame videoio(MSMF): can't grab frame. Error: -2147483638 Traceback (most recent call last): File "D:/Projects/exam_proctoring_model/Proctoring-AI-master/eye_tracker.py", line 160, in
thresh = img.copy()
AttributeError: 'NoneType' object has no attribute 'copy'