Hi,
I am trying to execute the following code regarding video capture from webcam on my laptop. I am using python3 with opencv4 on windows 7.
import numpy as np import cv2
cap = cv2.VideoCapture(0)
while(True): # Capture frame-by-frame ret, frame = cap.read() # Our operations on the frame come here gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Display the resulting frame
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
When everything done, release the capture
cap.release() cv2.destroyAllWindows()
While executing the code the camera opens but the camera display windows shows a still blurred multiple gray image instead of the live video. I am using IDLE python IDE for execution of the code. It says some VideoCodec_RGB24 error. For crosscheck whether I have installed the python and OpenCv properly or not, I used a code that readsmp4 file using the command cap = cv2.VideoCapture('video1.mp4'). The program is able to read from the mp4 file and it displays the videos too. Please advise to fix the problem.