0

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'```
  • 2
    some of the commands won't read What exactly do you mean by that? Do you get an error message? Please add this information to your question. – Dirk Apr 2 at 16:40
  • Theres out.read() and it sais that is isn't definined and for cv2.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 2 at 17:07
  • 1
    You don't have to do it now, but you really have to give more detailed information than just it sais something about dimensions or coordinates. Add some problem code and full error messages to your question – Dirk Apr 2 at 18:04
  • NameError: 'out' is not defined Error 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 4 at 7:52
  • youtu.be/QjKmgdrNCP0 it was a test code – Entity Apr 4 at 12:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.