Python Forum
Python openCV "img" is not defined error - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Python openCV "img" is not defined error (/thread-9674.html)



Python openCV "img" is not defined error - Arontbt - Apr-23-2018

I'm using openCV to write an image to a new file. I got the following method from an openCV textbook but I get an error that says "img" is not defined.

cv2.imwrite("myimage.png", img)


RE: Python openCV "img" is not defined error - buran - Apr-23-2018

Please, post your full code (minimal runnable script).
My guess is img is a variable, defined in the example code somewhere before that line and it is missing (i.e. it is not defined yet, or you are using different name) in your code.


RE: Python openCV "img" is not defined error - Arontbt - Apr-23-2018

(Apr-23-2018, 12:15 PM)buran Wrote: Please, post your full code (minimal runnable script).
My guess is img is a variable, defined in the example code somewhere before that line and it is missing (i.e. it is not defined yet, or you are using different name) in your code.

You're right. img represented an image file that was read before writing. Thank you!