Update auto_pack_img.py

This commit is contained in:
autumn-2-net 2024-10-09 17:52:19 +08:00 committed by GitHub
parent 6e0bdfc5ef
commit 2641507b34
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -114,6 +114,16 @@ def load_images_from_folder(folder,max_height=768,max_width=768):
# img = cv2.resize(img, (min(img.shape[1], max_width), min(img.shape[0], max_height))) # img = cv2.resize(img, (min(img.shape[1], max_width), min(img.shape[0], max_height)))
images.append(img) images.append(img)
random.shuffle(images) random.shuffle(images)
scc=[]
for i in images:
w=i.shape[1]
h=i.shape[0]
sizezz=w*h
scc.append((sizezz,i))
scc.sort(key=lambda x: x[0], reverse=True)
images=[]
for i in scc:
images.append(i[1])
return images return images
@ -124,7 +134,7 @@ images = load_images_from_folder(folder)
stitched_image = stitch_images_bin_packing(images) stitched_image = stitch_images_bin_packing(images)
cv2.imwrite('images/auto_img_zh_cn.png', stitched_image) cv2.imwrite('auto_img_zh_cn.png', stitched_image)
folder = 'en' folder = 'en'
@ -133,4 +143,4 @@ images = load_images_from_folder(folder)
stitched_image = stitch_images_bin_packing(images) stitched_image = stitch_images_bin_packing(images)
cv2.imwrite('images/auto_img_en.png', stitched_image) cv2.imwrite('auto_img_en.png', stitched_image)