fffiloni commited on
Commit
cc41846
1 Parent(s): c914fa0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
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(tail[1] - tip[1], tail[0] - tip[0]))
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
- text = f"""
80
- Length: {length:.2f},
81
- Angle: {angle:.2f}
82
- """
83
- cv2.putText(img_result, text, (tip[0] + 10, tip[1] - 10), 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)
 
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)