change for proper rotation

This commit is contained in:
anetla 2023-12-29 13:29:00 +01:00
parent ebdb008d37
commit bc1cd9ee7c

View File

@ -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])