From b66e7fe9cfcc503fc9d78b9109bf2ccd74808147 Mon Sep 17 00:00:00 2001 From: autumn <109412646+autumn-2-net@users.noreply.github.com> Date: Wed, 9 Oct 2024 12:08:30 +0800 Subject: [PATCH] fix bug --- auto_pack_img.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/auto_pack_img.py b/auto_pack_img.py index 380d8c3..768ff4e 100644 --- a/auto_pack_img.py +++ b/auto_pack_img.py @@ -96,11 +96,14 @@ def stitch_images_bin_packing(images): -def load_images_from_folder(folder): +def load_images_from_folder(folder,max_height=384,max_width=284): images = [] for filename in os.listdir(folder): img = cv2.imread(os.path.join(folder, filename)) if img is not None: + if max_height is not None and max_width is not None: + if img.shape[0] > max_height or img.shape[1] > max_width: + img = cv2.resize(img, (min(img.shape[1], max_width), min(img.shape[0], max_height))) images.append(img) return images