From 33f6a231bc5065731b4b92744e95c67c3b13d6e4 Mon Sep 17 00:00:00 2001 From: vahidrezanezhad Date: Mon, 26 Jan 2026 17:30:26 +0100 Subject: [PATCH] fix: prevent crash when printspace is missing in xmls used for label generation --- src/eynollah/training/gt_gen_utils.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/eynollah/training/gt_gen_utils.py b/src/eynollah/training/gt_gen_utils.py index 62a094a..0f29f9e 100644 --- a/src/eynollah/training/gt_gen_utils.py +++ b/src/eynollah/training/gt_gen_utils.py @@ -734,12 +734,15 @@ def get_images_of_ground_truth(gt_list, dir_in, output_dir, output_type, config_ _, thresh = cv2.threshold(imgray, 0, 255, 0) contours, _ = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) - + cnt_size = np.array([cv2.contourArea(contours[j]) for j in range(len(contours))]) - - cnt = contours[np.argmax(cnt_size)] - - x, y, w, h = cv2.boundingRect(cnt) + + try: + cnt = contours[np.argmax(cnt_size)] + x, y, w, h = cv2.boundingRect(cnt) + except: + x, y , w, h = 0, 0, x_len, y_len + bb_xywh = [x, y, w, h]