Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -39,10 +39,19 @@ def find_tip(points, convex_hull):
|
|
39 |
return tuple(points[j])
|
40 |
|
41 |
def find_tail(points, tip):
|
42 |
-
#
|
43 |
-
|
|
|
44 |
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
def infer(image_in):
|
48 |
img = cv2.imread(image_in)
|
|
|
39 |
return tuple(points[j])
|
40 |
|
41 |
def find_tail(points, tip):
|
42 |
+
# Convert the tip and points to numpy arrays
|
43 |
+
tip = np.array([tip], dtype=np.float32)
|
44 |
+
points = np.array(points, dtype=np.int32)
|
45 |
|
46 |
+
# Find the index of the farthest point
|
47 |
+
distances = cv2.pointPolygonTest(points, tip, True)
|
48 |
+
|
49 |
+
if distances is not None:
|
50 |
+
farthest_index = np.argmax(distances)
|
51 |
+
farthest_point = tuple(points[farthest_index][0])
|
52 |
+
return farthest_point
|
53 |
+
else:
|
54 |
+
return None
|
55 |
|
56 |
def infer(image_in):
|
57 |
img = cv2.imread(image_in)
|