我试图在一个程序中击败一个反机器人功能,用户必须按字母数字顺序点击图像中的字母。我已经设法使用预处理从背景中提取文本,但是仍然需要使用Tesseract对每个单独的字符进行倾斜以获得最佳结果。在
使用Hough线之前的图像,只是预处理
由HoughLinesP绘制的线条的原始图像
我尝试过使用Canny边缘检测器+Hough线来查找每个字符下面的行。然而,我认为这条线本身的质量是不一致的,而且我不能根据它的底线来区分。在
以下是我尝试过的代码:# -*- coding:utf-8 -*-
import cv2, numpy as np, time
img_roi = [48, 191, 980, 656] # x1, y1, x2, y2
src_img_dir = "images/source/9.png"
bg_img = cv2.imread("images/background.png", cv2.IMREAD_COLOR)[img_roi[1]:img_roi[3], img_roi[0]:img_roi[2]]
# The background of the area is constant. So I have used a reference background image and rem