Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

Capture Video from Camera using cv2.VideoCapture(0) not working

$
0
0
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): ret, frame = cap.read() gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) cv2.imshow('frame',gray) if cv2.waitKey(1) & 0xFF == ord('q'): break 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 reads mp4 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.

Viewing all articles
Browse latest Browse all 41027

Trending Articles