From a5194a790c607e78b14d124fb6398fa387c6a055 Mon Sep 17 00:00:00 2001
From: "dan.rustia" <dan.rustia@wur.nl>
Date: Tue, 7 May 2024 11:35:02 +0200
Subject: [PATCH] fix ops

---
 image_operations.py | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/image_operations.py b/image_operations.py
index 943f925..c92aff2 100755
--- a/image_operations.py
+++ b/image_operations.py
@@ -534,21 +534,23 @@ def embed_output(img_output, a, cfg, custom_label=""):
 
         if cfg.cfg["display"]["show_contour"] and cfg.operation != "object_detection":
 
-            try:
-                polygon_lengths = [len(px) for px in pp]
 
-                if cfg.cfg["display"]["contour_style"] == "simple":        
+            polygon_lengths = [len(px) for px in pp]
+
+            if cfg.cfg["display"]["contour_style"] == "simple":     
+                try:   
                     max_polygon = pp[polygon_lengths.index(max(polygon_lengths))]
                     px = [max_polygon.astype(np.int64).reshape(-1, 2)]
                     cv2.drawContours(img_output, px, 0, color, cfg.cfg["display"]["thickness"]*2)
+                except:
+                    pass
+
+            if cfg.cfg["display"]["contour_style"] == "complex":
+                for polygon in pp:
+                    px = np.asarray(polygon).astype(np.int64).reshape(-1, 2)
+                    cv2.drawContours(img_output, [px], -1, color, cfg.cfg["display"]["thickness"])
 
-                if cfg.cfg["display"]["contour_style"] == "complex":
-                    for polygon in pp:
-                        px = np.asarray(polygon).astype(np.int64).reshape(-1, 2)
-                        cv2.drawContours(img_output, [px], -1, color, cfg.cfg["display"]["thickness"])
 
-            except Exception as e:
-                print(e)
 
             if cfg.cfg["display"]["show_contour_alpha"]:
                 colored_mask = np.expand_dims(m, 0).repeat(3, axis=0)
-- 
GitLab