Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,9 +4,11 @@ import numpy as np
|
|
4 |
|
5 |
def preprocess(img):
|
6 |
img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
10 |
return img_erode
|
11 |
|
12 |
def find_tip(points, convex_hull):
|
@@ -20,6 +22,8 @@ def find_tip(points, convex_hull):
|
|
20 |
if np.all(points[j] == points[indices[i - 1] - 2]):
|
21 |
return tuple(points[j])
|
22 |
|
|
|
|
|
23 |
def infer(image_in):
|
24 |
img = cv2.imread(image_in)
|
25 |
|
|
|
4 |
|
5 |
def preprocess(img):
|
6 |
img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
7 |
+
img_blur = cv2.GaussianBlur(img_gray, (5, 5), 1)
|
8 |
+
img_canny = cv2.Canny(img_blur, 50, 50)
|
9 |
+
kernel = np.ones((3, 3))
|
10 |
+
img_dilate = cv2.dilate(img_canny, kernel, iterations=2)
|
11 |
+
img_erode = cv2.erode(img_dilate, kernel, iterations=1)
|
12 |
return img_erode
|
13 |
|
14 |
def find_tip(points, convex_hull):
|
|
|
22 |
if np.all(points[j] == points[indices[i - 1] - 2]):
|
23 |
return tuple(points[j])
|
24 |
|
25 |
+
|
26 |
+
|
27 |
def infer(image_in):
|
28 |
img = cv2.imread(image_in)
|
29 |
|