From d26d75081363a92d17ad0deedb84e122c92a2027 Mon Sep 17 00:00:00 2001 From: Isabela Estabile <162067260+Isabela-Estabilee@users.noreply.github.com> Date: Sun, 31 Mar 2024 21:57:16 -0300 Subject: [PATCH] Update etl_captcha.py --- etl_captcha.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/etl_captcha.py b/etl_captcha.py index c1beec7..858bd28 100644 --- a/etl_captcha.py +++ b/etl_captcha.py @@ -6,8 +6,8 @@ def remove_border(img, border_size): return img[border_size:-border_size, border_size:-border_size] -def etl_images(origin:str, destination:str): - methods = methods = [ +# def etl_images(origin:str, destination:str): +# methods = methods = [ # cv2.THRESH_BINARY, # cv2.THRESH_BINARY_INV, # cv2.THRESH_TRUNC, @@ -23,8 +23,13 @@ def etl_images(origin:str, destination:str): gray_image = cv2.cvtColor(image_without_border, cv2.COLOR_BGR2GRAY) - for j, method in enumerate(methods): - _, image_resolved = cv2.threshold(gray_image, 127, 255, method or cv2.THRESH_OTSU) + block_size = 57 + + c = 20 + +# for j, method in enumerate(methods): +# _, image_resolved = cv2.threshold(gray_image, 127, 255, method or cv2.THRESH_OTSU) + img_adaptive = cv2.adaptiveThreshold(gray_image, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY_INV, block_size, c) cv2.imwrite(f'{destination}/captcha{i}_method{j}.png', image_resolved)