opencv save picture

Using OpenCV can use cv2.imwrite()the function to save the picture. This function requires two parameters: filename and image data. If the picture to be saved already exists, the original picture will be overwritten.

For example, to save an image, you can use the following code:

import cv2

# 读取图片
img = cv2.imread("image.png")

# 保存图片
cv2.imwrite("image_save.png", img)

Here, "image.png" is the file name of the image to read, and "image_save.png" is the file name of the image to save.

Note: When using cv2.imwrite()the function to save a picture, the file name may need to include the file format of the picture, such as ".png" or ".jpg". It depends on the format you wish to save the picture in.

Guess you like

Origin blog.csdn.net/weixin_35757531/article/details/128872862