Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -24,18 +24,22 @@ def find_tip(points, convex_hull):
|
|
24 |
|
25 |
|
26 |
|
|
|
|
|
|
|
27 |
def infer(image_in):
|
28 |
-
img = cv2.imread(
|
29 |
|
30 |
-
contours,
|
31 |
|
32 |
for cnt in contours:
|
33 |
-
|
|
|
34 |
hull = cv2.convexHull(approx, returnPoints=False)
|
35 |
sides = len(hull)
|
36 |
|
37 |
if 6 > sides > 3 and sides + 2 == len(approx):
|
38 |
-
arrow_tip = find_tip(approx[:,
|
39 |
if arrow_tip:
|
40 |
cv2.drawContours(img, [cnt], -1, (0, 255, 0), 3)
|
41 |
cv2.circle(img, arrow_tip, 3, (0, 0, 255), cv2.FILLED)
|
|
|
24 |
|
25 |
|
26 |
|
27 |
+
|
28 |
+
|
29 |
+
|
30 |
def infer(image_in):
|
31 |
+
img = cv2.imread("arrows.png")
|
32 |
|
33 |
+
contours, hierarchy = cv2.findContours(preprocess(img), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_NONE)
|
34 |
|
35 |
for cnt in contours:
|
36 |
+
peri = cv2.arcLength(cnt, True)
|
37 |
+
approx = cv2.approxPolyDP(cnt, 0.025 * peri, True)
|
38 |
hull = cv2.convexHull(approx, returnPoints=False)
|
39 |
sides = len(hull)
|
40 |
|
41 |
if 6 > sides > 3 and sides + 2 == len(approx):
|
42 |
+
arrow_tip = find_tip(approx[:,0,:], hull.squeeze())
|
43 |
if arrow_tip:
|
44 |
cv2.drawContours(img, [cnt], -1, (0, 255, 0), 3)
|
45 |
cv2.circle(img, arrow_tip, 3, (0, 0, 255), cv2.FILLED)
|