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()
多进程 读取图片shape
最新推荐文章于 2025-11-26 15:40:52 发布
1696

被折叠的 条评论
为什么被折叠?



