小编SIs*_*lam的帖子

如何遍历 OS X 中其他应用程序的窗口/视图层次结构?

我想弄清楚如何获取(只读)任何应用程序的整个窗口/视图层次结构。我使用"CGWindowListCopyWindowInfo". 它还返回窗口编号( "kCGWindowNumber")。它还通过 显示根窗口的共享状态"kCGWindowSharingState = 1;"。现在,我想检查该应用程序的层次结构中是否存在特定的窗口/视图。我得到kCGWindowNumber了应用程序的根窗口。

macos cocoa core-graphics nswindow

5
推荐指数
2
解决办法
1044
查看次数

如何将验证码图像的所有字符与python中的一行对齐?

我是图像处理新手。我需要将图像传递给 pytesseract 来获取图像的内容。在此之前,我需要以图像的所有字符与图像底部对齐的方式预处理图像,而 pytesseract 可以轻松检测到这些字符。

我使用 opencv-python,4.5.5 和 Python 3.8

我正在处理的图像看起来像-

1

更新: 我已经尝试过使用下面提到的代码:

import cv2
import numpy as np

img = cv2.imread(r"dialated.jpg", cv2.IMREAD_GRAYSCALE)
ret, img = cv2.threshold(img, 50, 255, cv2.THRESH_BINARY_INV)

Contours = cv2.findContours(img, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)[-2]
Contours = sorted(Contours, key=lambda x : cv2.boundingRect(x)[0])
#Contours.sort(key=lambda x : cv2.boundingRect(x)[0]) #throws exception so commented out and used the above line instead.

newImg = np.zeros(img.shape, dtype=np.uint8)
bb = cv2.boundingRect(Contours[0])
newY = (bb[1] + bb[3])
for Contour in Contours:
    [x, y, w, h] = cv2.boundingRect(Contour)

    newImg[newY-h+1:newY+1, …
Run Code Online (Sandbox Code Playgroud)

python captcha opencv image-processing python-tesseract

0
推荐指数
1
解决办法
644
查看次数