Loading rpc/methods.py +8 −1 Original line number Diff line number Diff line Loading @@ -50,9 +50,16 @@ class ServiceException(Exception): self.message = args[0] def _deskew(image_path: str, max_skew: int = 10) -> float: def _deskew(image_path: str, max_skew: int = 10, fast: bool = True) -> float: im = cv2.imread(image_path) height, width, _ = im.shape if fast: scale_factor = 1000 / max(height, width) im = cv2.resize( im, (int(width * scale_factor), int(height * scale_factor)), interpolation=cv2.INTER_LINEAR, ) im_gs = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY) im_gs = cv2.fastNlMeansDenoising(im_gs, h=3) im_bw = cv2.threshold(im_gs, 0, 255, cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU)[1] Loading Loading
rpc/methods.py +8 −1 Original line number Diff line number Diff line Loading @@ -50,9 +50,16 @@ class ServiceException(Exception): self.message = args[0] def _deskew(image_path: str, max_skew: int = 10) -> float: def _deskew(image_path: str, max_skew: int = 10, fast: bool = True) -> float: im = cv2.imread(image_path) height, width, _ = im.shape if fast: scale_factor = 1000 / max(height, width) im = cv2.resize( im, (int(width * scale_factor), int(height * scale_factor)), interpolation=cv2.INTER_LINEAR, ) im_gs = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY) im_gs = cv2.fastNlMeansDenoising(im_gs, h=3) im_bw = cv2.threshold(im_gs, 0, 255, cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU)[1] Loading