Python Forum

Full Version: Python openCV "img" is not defined error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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)
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.
(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!