fffiloni commited on
Commit
870f731
1 Parent(s): b6c46c4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
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
- img_thresh = cv2.adaptiveThreshold(img_gray, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 11, 2)
8
- img_dilate = cv2.dilate(img_thresh, np.ones((3, 3)), iterations=2)
9
- img_erode = cv2.erode(img_dilate, np.ones((3, 3)), iterations=1)
 
 
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