Two parameters of imwrite:
- Name: File name to be saved
- Img: Specify who to save to the file here, which is Mat type
import cv2 from cv2 import IMREAD_COLOR cv2.namedWindow('img',cv2.WINDOW_NORMAL) img=cv2.imread('20220627214919.jpg',IMREAD_COLOR) cv2.imshow('img',img) key=cv2.waitKey(0) if key==ord('q'): # 设置按q键退出 exit() elif key==ord('s'): # 设置按s键保存图片 cv2.imwrite('图片路径和文件名加图片后缀(使用英文和数字)',img) # 保存图片 cv2.destroyAllWindows()