Update app.py
Browse files
app.py
CHANGED
@@ -43,7 +43,7 @@ def get_length(p1, p2):
|
|
43 |
return line_length
|
44 |
|
45 |
def get_angle(tip, tail):
|
46 |
-
return np.degrees(np.arctan2(
|
47 |
|
48 |
def get_max_distance_point(cnt, tip):
|
49 |
max_distance = 0
|
@@ -76,11 +76,11 @@ def draw_arrow(img_result, tip, tail, length, angle):
|
|
76 |
cv2.arrowedLine(img_result, tuple(tail), tuple(tip), (0, 255, 0), 3)
|
77 |
|
78 |
# Add length and angle as text next to the tip point
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
cv2.putText(img_result,
|
84 |
|
85 |
def infer(image_in):
|
86 |
img = cv2.imread(image_in)
|
|
|
43 |
return line_length
|
44 |
|
45 |
def get_angle(tip, tail):
|
46 |
+
return np.degrees(np.arctan2(tip[1] - tail[1], tip[0] - tail[0]))
|
47 |
|
48 |
def get_max_distance_point(cnt, tip):
|
49 |
max_distance = 0
|
|
|
76 |
cv2.arrowedLine(img_result, tuple(tail), tuple(tip), (0, 255, 0), 3)
|
77 |
|
78 |
# Add length and angle as text next to the tip point
|
79 |
+
text_length = f"Length: {length:.2f}"
|
80 |
+
text_angle = f"Angle: {angle:.2f}"
|
81 |
+
|
82 |
+
cv2.putText(img_result, text_length, (tip[0] + 10, tip[1] - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1, cv2.LINE_AA)
|
83 |
+
cv2.putText(img_result, text_angle, (tip[0] + 10, tip[1] - 30), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1, cv2.LINE_AA)
|
84 |
|
85 |
def infer(image_in):
|
86 |
img = cv2.imread(image_in)
|