import cv2
from tqdm import tqdm
from multiprocessing import Pool
from utils import get_all_path
def process_image(img_path):
img = cv2.imread(img_path)
h, w, _ = img.shape
if h != 1080 or w != 1920:
print('shape', img_path, h, w)
if __name__ == '__main__':
# 图像路径列表
img_dir = './org_img'
img_pathway = get_all_path(img_dir, ['.jpg'])
# 创建进程池,根据需要设置进程数量
pool = Pool(processes=10) # 这里使用4个进程
# 使用进程池处理图像路径列表
with tqdm(total=len(img_pathway)) as pbar:
for _ in pool.imap_unordered(process_image, img_pathway):
pbar.update()
# 关闭进程池
pool.close()
pool.join()
05-29
463
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-09
810
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-28
5374
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-10
449
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)