I am trying to run a simple program that reads an image from OpenCV. However, I am getting this error:
error: ......\\modules\\highgui\\src\\window.cpp:281:
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
while(True):
# Capture frame-by-frame
ret,frame = cap.read()
cv2.rectangle(frame, (100, 100), (200, 200), [255, 0, 0], 2)
# Display the resulting frame
cv2.imshow('frame',frame)
if cv2.waitKey(25) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
**If the camera access for devices is OFF, this code gives an error ;kind of this: cv2.imshow('frame',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'
So You should turn ON it**