Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -46,8 +46,7 @@ def infer(image_in):
|
|
46 |
img = cv2.imread(image_in)
|
47 |
|
48 |
contours, hierarchy = cv2.findContours(preprocess(img), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
49 |
-
|
50 |
-
print(f"hierarchy: {hierarchy}")
|
51 |
|
52 |
for cnt in contours:
|
53 |
peri = cv2.arcLength(cnt, True)
|
@@ -55,15 +54,13 @@ def infer(image_in):
|
|
55 |
hull = cv2.convexHull(approx, returnPoints=False)
|
56 |
sides = len(hull)
|
57 |
|
58 |
-
|
59 |
-
peri: {peri} | approx: {approx} | hull: {hull} | sides: {sides}
|
60 |
-
""")
|
61 |
|
62 |
-
if 6 > sides > 3 and sides + 2 == len(approx):
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
|
68 |
cv2.imwrite("Image_result.png", img)
|
69 |
|
|
|
46 |
img = cv2.imread(image_in)
|
47 |
|
48 |
contours, hierarchy = cv2.findContours(preprocess(img), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
|
49 |
+
|
|
|
50 |
|
51 |
for cnt in contours:
|
52 |
peri = cv2.arcLength(cnt, True)
|
|
|
54 |
hull = cv2.convexHull(approx, returnPoints=False)
|
55 |
sides = len(hull)
|
56 |
|
57 |
+
|
|
|
|
|
58 |
|
59 |
+
#if 6 > sides > 3 and sides + 2 == len(approx):
|
60 |
+
arrow_tip = find_tip(approx[:,0,:], hull.squeeze())
|
61 |
+
if arrow_tip:
|
62 |
+
cv2.drawContours(img, [cnt], -1, (0, 255, 0), 3)
|
63 |
+
cv2.circle(img, arrow_tip, 3, (0, 0, 255), cv2.FILLED)
|
64 |
|
65 |
cv2.imwrite("Image_result.png", img)
|
66 |
|