Python OpenCV Writing to Image

In this Python OpenCV lesson we are going to learn about Python OpenCV Writing to Image,  we will learn that how you can write to an image in OpenCV, how you can work with keyboard events and also how you can convert a tif image to jpg image.

 

 

This is the complete code for this lesson.

 

 

First of we are going to read or load our image.

 

 

After that we are going to create our wait key.

 

 

In here we are checking if the user press escape key, we are going to close the window.

 

 

And if the user press s key we are going to save the image, for this we are going to use cv2.imwrite() function.

 

 

You can run the complete code and after that press s key you will see that we have a new image with jpg format in our working directory.

Python OpenCV Writing Image
Python OpenCV Writing Image

 

Thank you for visiting my website! If you enjoyed the free courses, please consider supporting my works on Patreon.