Ask Your Question

Revision history [back]

OpenCV cannot read from my VGA Webcam

Ok I will crack down on the issue fast, as I don't want waste anyone's time:

I have a laptop MODEL: ACER ASPIRE 3(A315-42) with a VGA Camera built into it. Here is the simple code I'm trying to run(in python)

import cv2
cap = cv2.VideoCapture(0)
ret, frame = cap.read()
print(ret)

it seems to only return False.

Now if you want a little more detail I ran another program.

import cv2
import numpy as np

cap = cv2.VideoCapture(0)
while(True):
    ret, frame = cap.read()
    cv2.imshow('frame',frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()

I receive this error cv2.error: C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:281: error: (-215) size.width>0 && size.height>0 in function cv::imshow

Unfortunately I'm not too great with OpenCV just begun today, so if anyone can help me out I would be so happy as this is required for a project I'm working on.

Thank you to whom who answers to this in advance.