Reputation: 1
I am using A kinect V2 instead of a webcam for a opencv project and wanted to test some code using it. I used the laptop webcam and it worked perfectly. But with the kinect it turns on and then crashes the program and gives a error message.
This is the snippet of code.
import cv2
print(cv2.__version__)
cap = cv2.VideoCapture(0)
if not (cap.isOpened()):
print("Could not open video device")
while(True):
ret, frame = cap.read()
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
The error I got was this:-
[ WARN:1] global D:\a\opencv-python\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (1022) CvCapture_MSMF::grabFrame videoio(MSMF): can't grab frame. Error: -2147024809
Traceback (most recent call last):
File "c:\Users\haze\Documents\GitHub\Haz3-jolt\handtrackingmodule.py", line 21, in <module>
cv2.imshow('frame', frame)
cv2.error: OpenCV(4.5.4-dev) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'
[ WARN:1] global D:\a\opencv-python\opencv-python\opencv\modules\videoio\src\cap_msmf.cpp (438) `anonymous-namespace'::SourceReaderCB::~SourceReaderCB terminating async callback
Upvotes: 0
Views: 661