图像转化为Jpg

import cv2 as cv
import os
dir_path = '/mnt/data-ractified/all/ground-truth/results'
file_list = os.listdir(dir_path)
for file in file_list:
    if not file.endswith('.jpg'):
        print('start changing! ' + file)
        ori_path = dir_path + '/' + file
        cv_file = cv.imread(ori_path)
        name,ext = file.split('.')
        des_path = dir_path + '/' + name + '.jpg'
        cv.imwrite(des_path,cv_file)
        print('finished! '+file)
        os.remove(ori_path)

你可能感兴趣的:(opencv,python,计算机视觉)