OS: Win7 Python version: updated (3.8.1) So the thing is, by using OpenCV module , I'm trying to access the inbuilt webcam of my laptop to capture the video & process the frames, but the window displating the real-time video is not showing up despite the indicator light of the webcam turning on implying the webcam is working, and the following error is being encountered:
Traceback (most recent call last): File:............. line 8, in gray = cv2.cvtColor(diff, cv2.COLOR_RGB2GRAY) cv2.error: OpenCV(4.5.5) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'> Blockquote
Here's the code snippet:
import cv2
import winsound
cam = cv2.VideoCapture(0)
while cam.isOpened():
ret, frame1 = cam.read()
ret, frame2 = cam.read()
diff = cv2.absdiff(frame1, frame2)
gray = cv2.cvtColor(diff, cv2.COLOR_RGB2GRAY)