0

我尝试使用 Tasker 和 AutoTools 插件在 Android 中为我的游戏编写自动化程序。此时还可以,但我需要捕获屏幕截图并需要根据我的需要对其进行解释。

这正是我所需要的;

有些文字在游戏中很重要,我想在屏幕上的任何地方点击它。所以我认为我需要 OCR 来完成这项任务。我遵循一些解决方案,但每次都失败或卡住。让我解释一下我尝试了哪些解决方案。

遵循解决方案 1:

  • 我尝试了 AutoInput (Tasker plugin) UIQuery 方法但失败了。因为我认为 AutoInput 的 UIQuery 只适用于 android UI。无法从 3D 应用程序(如游戏)中获取任何信息。

遵循解决方案 2:

  • 我搜索 OCR 解决方案并找到 AutoTools(Tasker 插件)

  • 创建任务并截取屏幕截图并使用 AutoTools OCR 方法对其进行解释。没关系。AutoTools OCR 成功读取图像文件中的文本。

  • 但我又卡住了。因为我成功地从图像文件中读取了文本,但我不知道重要文本的 xy 坐标。

此时有什么建议?

我应该学习android并编写自己的应用程序吗?

4

2 回答 2

2

您应该查看ocr-reader Google 示例。它运行速度很快,而且得到你想要的东西并不难。您需要做的是修改OcrDetectorProcess样本附带的,将文本分解为单个单词,然后您可以轻松计算每个单词的边界和中心点。这里有一些代码可以帮助您入门:

@Override
public void receiveDetections(Detector.Detections<TextBlock> detections) {
    mGraphicOverlay.clear();

    // Get all detected items.
    SparseArray<TextBlock> items = detections.getDetectedItems();
    for (int i = 0; i < items.size(); ++i) {
        TextBlock item = items.valueAt(i);

        // Get individual lines in each item.
        List<Line> lines = (List<Line>) item.getComponents();
        for (Line line : lines) {

            // Get individual "words" in each line.
            List<Element> elements = (List<Element>) line.getComponents();
            for (Element e : elements) {

                // Now get the position of each element.
                Rect rect = e.getBoundingBox();
                Point[] points = e.getCornerPoints();
                int centerX = (points[0].x + points[2].x) / 2;
                int centerY = (points[0].y + points[2].y) / 2;

                // DO STUFF

            }
        }
    }
}
于 2018-12-20T19:21:39.663 回答
1

我与编写“AutoTools”Tasker 插件的开发人员联系。

他/她为插件添加了一些功能并解决了它。

插件,使用 OCR 授予的图像进行解释,现在返回单词和每个单词的 xy 位置的中心。

如果有人在 Android 和 Tasker App 上搜索此功能,请访问此论坛主题链接。它非常有用。

于 2018-12-21T20:30:01.153 回答