本帖最后由 wihn 于 2022-4-28 14:18 编辑
代码如下,想要把文件夹里面所有图片从rgb转成bgr
[Python] 纯文本查看 复制代码 import cv2
import os
import multiprocessing
def convert_this_list(list):
count = 0
for file in list:
absfile = os.path.abspath(file)
cv2.imwrite(absfile, cv2.cvtColor(cv2.imread(absfile), cv2.COLOR_RGB2BGR))
count += 1
print(count)
def multi_process_convert():
epoch = 100
processes = []
files = []
for f in os.walk('./'):
for file in f[2]:
if file.endswith('.jpg'):
files.append(file)
for i in range(0, len(files), epoch):
t = multiprocessing.Process(target=convert_this_list, args=(files[i:min(i+epoch,len(files))],))
processes.append(t)
t.start()
for p in processes:
p.join()
multi_process_convert()
但是后来发现这段代码对图片没有起到作用,请问是为什么,哪里错了呢? |