图像保存
图像保存1、实现原理2、实现效果3、实现代码
1、实现原理
使用cv2.imwrite()将图像保存到文件。
2、实现效果
xxxxxxxxxx cd ~/opencv xxxxxxxxxx python3 02.image_save.py
注意:选中图片按q可以退出程序!

3、实现代码
import cv2 def save_image(input_path, output_path): image = cv2.imread(input_path) if image is None: print("Error: Unable to open image file.") return if cv2.imwrite(output_path, image): print(f"Image saved to {output_path}") cv2.imshow('Image Preview', cv2.imread(output_path)) cv2.waitKey(0) cv2.destroyAllWindows() else: print("Error: Unable to save image file.") save_image('/home/jetson/opencv/images/yahboom_logo.png',\ '/home/jetson/opencv/images/yahboom_logo_copy.png')