import cv2
from numpy import ndarray

if __name__ == '__main__':
    # 读取图像(图片地址,读取模式)
    img: ndarray = cv2.imread('2.jpg', cv2.IMREAD_COLOR)
    # 显示图像(窗口名称,图像数据)
    cv2.imshow('image', img)
    # 图像显示的持续时间;并监听键盘输入。0代表一直显示和监听。(此方法必须调用,否则图像不会显示)
    cv2.waitKey(0)
    # 销毁窗口
    cv2.destroyAllWindows()
    # 保存图像
    cv2.imwrite('3.png', img, [int(cv2.IMWRITE_JPEG_QUALITY), 100])