I recently installed opencv ans tried to run a simple process some of the commands won't read such as cv2.imshow() or cv2.imread () along with the waitkey() everything else works fine but a few necessary likes of code. Is it that i dont have have depencies for them or is it something else?
My code
import numpy as np
Import cv2
cap = cv2.VideoCapture(0)
while(True)
#Capture frame-by-frame
ret, frame = cap.read()
out.write(frame)
#Display the resulting frame
cv2.imshow('frame', frame)
if cv2.waitkey(20) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
out.write()
cv2.destroyAllWindows()```
Errors i get
Traceback (most recent call last):
File "/home/pi/test.py", line 9 in <module>
out.write(frame)
NameError: 'out' is not defined
Cv2.imshow()
Cv2.error: OpenCV(3.4.4) /home/pi/packaging/opencv-python/opencv/modules/highgui/src/window.cpp:356: error: (-215: assertion failed) size.width>0 && size.height>0 in function 'imshow'```
some of the commands won't readWhat exactly do you mean by that? Do you get an error message? Please add this information to your question. – Dirk Apr 02 '19 at 16:40out.read()and it sais that is isn't definined and forcv2.imread()it sais something about dimensions or coordinates i dont know but i cant really check to be sure because im in school and about to change classes – Entity Apr 02 '19 at 17:07it sais something about dimensions or coordinates. Add some problem code and full error messages to your question – Dirk Apr 02 '19 at 18:04NameError: 'out' is not definedError says it: 'out' needs to be defined first. No idea what it's supposed to do. Did you copy this code from somewhere? Or adapted from an example? If so then please provide a link – Dirk Apr 04 '19 at 07:52'out' is not defined. If you look at this example from another question you'll see thatoutis defined before being used. Something like this:out = cv2.VideoWriter('test_output.avi',fourcc, 20.0, (640,480),0)– David Apr 05 '19 at 00:59cv2.imshow('frame',frame)about assertion failure – Entity Apr 05 '19 at 15:34