我在该网站上找到了以下代码:
import os
import os.path
import cv2
import glob
import imutils
CAPTCHA_IMAGE_FOLDER = "generated_captcha_images"
OUTPUT_FOLDER = "extracted_letter_images"
# Get a list of all the captcha images we need to process
captcha_image_files = glob.glob(os.path.join(CAPTCHA_IMAGE_FOLDER, "*"))
counts = {}
# loop over the image paths
for (i, captcha_image_file) in enumerate(captcha_image_files):
print("[INFO] processing image {}/{}".format(i + 1, len(captcha_image_files)))
# Since the filename contains the captcha text (i.e. "2A2X.png" has the text "2A2X"),
# grab the base filename as the text
filename …Run Code Online (Sandbox Code Playgroud) 我找到了一些应该有用的代码,但是没有.我做错了什么/缺少了什么?
def find_table_in_boxes(boxes, cell_threshold=10, min_columns=2):
for box in boxes:
(x, y, w, h) = box
print(box)
col_key = x // cell_threshold
if __name__ == '__main__':
text_boxes = [
{
'x': 123,
'y': 512,
'w': 100,
'h': 150
},
{
'x': 500,
'y': 512,
'w': 100,
'h': 150
}
]
cells = find_table_in_boxes(text_boxes)
Run Code Online (Sandbox Code Playgroud)
# python test.py
{'x': 123, 'w': 100, 'y': 512, 'h': 150}
Traceback (most recent call last):
File "test.py", line 22, in <module>
cells = find_table_in_boxes(text_boxes) …Run Code Online (Sandbox Code Playgroud)