ml-debi commited on
Commit
616da57
1 Parent(s): 969f821

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -49,8 +49,11 @@ def ocr_image_process(img, sigma, block_size, constant):
49
  img = np.array(img)
50
 
51
  gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
52
- thresh_inv = cv2.adaptiveThreshold(gray,255,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY_INV, int(block_size), int(constant)) #41, 1
53
- edges = auto_canny(thresh_inv, sigma)
 
 
 
54
  ctrs, _ = cv2.findContours(edges.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
55
  sorted_ctrs = sorted(ctrs, key=lambda ctr: cv2.boundingRect(ctr)[0])
56
  img_area = img.shape[0]*img.shape[1]
 
49
  img = np.array(img)
50
 
51
  gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
52
+ thresh_inv = cv2.adaptiveThreshold(
53
+ gray, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY_INV,
54
+ int(block_size) if block_size is not None else 41,
55
+ int(constant) if constant is not None else 1)
56
+ edges = auto_canny(thresh_inv, float(sigma) if sigma is not None else 0.33)
57
  ctrs, _ = cv2.findContours(edges.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
58
  sorted_ctrs = sorted(ctrs, key=lambda ctr: cv2.boundingRect(ctr)[0])
59
  img_area = img.shape[0]*img.shape[1]