From bc1cd9ee7c2a98fdb5ed8663952c706e03fce350 Mon Sep 17 00:00:00 2001 From: anetla Date: Fri, 29 Dec 2023 13:29:00 +0100 Subject: [PATCH] change for proper rotation --- tomAIto_web_app/object_detector.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tomAIto_web_app/object_detector.py b/tomAIto_web_app/object_detector.py index b71f8c2..a187cad 100644 --- a/tomAIto_web_app/object_detector.py +++ b/tomAIto_web_app/object_detector.py @@ -46,6 +46,7 @@ def detect(): buf = request.files["image_file"] boxes, orientation = detect_objects_on_image(buf.stream) print(boxes) + print(orientation) return jsonify(boxes) def detect_objects_on_image(buf): @@ -139,9 +140,9 @@ def adjust_boxes_for_orientation(boxes, orientation, img_width, img_height): if orientation == 3: # 180 degrees x1, y1, x2, y2 = img_width - x2, img_height - y2, img_width - x1, img_height - y1 elif orientation == 6: # 270 degrees (or -90 degrees) - x1, y1, x2, y2 = y1, img_width - x2, y2, img_width - x1 - elif orientation == 8: # 90 degrees x1, y1, x2, y2 = img_height - y2, x1, img_height - y1, x2 + elif orientation == 8: # 90 degrees + x1, y1, x2, y2 = y1, img_width - x2, y2, img_width - x1 adjusted_boxes.append([x1, y1, x2, y2, label, prob])