import cv2
capture = cv2.VideoCapture(0) capture.set(cv2.CAP_PROP_FRAME_WIDTH, 640) capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
while True: ret, frame = capture.read() cv2.imshow("VideoFrame", frame) if cv2.waitKey(10) > 0: break
capture.release() cv2.destroyAllWindows()
I'm working on a code to film a video using a laptop cam repeatedly C:\Users\dntjd\PycharmProjects\practice\venv\Scripts\python.exe C:/Users/dntjd/PycharmProjects/practice/practice1.py Traceback (most recent call last): File "C:/Users/dntjd/PycharmProjects/practice/practice1.py", line 9, in cv2.imshow("VideoFrame", frame) cv2.error: OpenCV(4.0.0) C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:350: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'
Process finished with exit code 1
I see this errorㅜ I'm posting a question because there's no clear solution no matter how much I look for it.
opencv
Just looking at the error log, I think it's because the width and height of the image size are less than or equal to zero.
You may not have been able to capture the image properly.
Frame variable appears to contain a null value I don't think the camera is connected properly.
© 2024 OneMinuteCode. All rights reserved.