Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 检测特定文本的x-y坐标_Android_Ocr_Tasker - Fatal编程技术网

Android 检测特定文本的x-y坐标

Android 检测特定文本的x-y坐标,android,ocr,tasker,Android,Ocr,Tasker,我试着用Tasker和AutoTools插件为我的Android游戏编写一个自动化程序。有些事情在这一点上还可以,但我需要捕获屏幕截图并根据我的需要进行解释 这正是我需要的 有些文字在游戏中很重要,我想在屏幕上的任何地方点击它们。所以我想我需要OCR来完成这个任务。我遵循一些解决方案,但每次都失败或卡住。让我解释一下我尝试了哪些解决方案 以下解决方案1: 我尝试了自动输入(Tasker插件)UIQuery方法,但失败了。因为我认为自动输入的UIQuery只适用于android用户界面。无法从3

我试着用Tasker和AutoTools插件为我的Android游戏编写一个自动化程序。有些事情在这一点上还可以,但我需要捕获屏幕截图并根据我的需要进行解释

这正是我需要的

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

以下解决方案1:

  • 我尝试了自动输入(Tasker插件)UIQuery方法,但失败了。因为我认为自动输入的UIQuery只适用于android用户界面。无法从3D应用程序(如游戏)中获取任何信息
以下解决方案2:

  • 我搜索OCR解决方案并找到自动工具(Tasker插件)

  • 创建一个任务,截图并用AutoTools OCR方法解释。没关系。自动工具OCR成功地从图像文件中读取文本

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

在这一点上你有什么建议


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

你应该查看谷歌的示例。它跑起来很快,而且不难得到你想要的东西。您需要做的是修改示例附带的
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

            }
        }
    }
}
@覆盖
公共空隙接收检测(检测器。检测){
mGraphicOverlay.clear();
//获取所有检测到的项目。
SparseArray items=detections.getDetectedItems();
对于(int i=0;i
您应该签出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

            }
        }
    }
}
@覆盖
公共空隙接收检测(检测器。检测){
mGraphicOverlay.clear();
//获取所有检测到的项目。
SparseArray items=detections.getDetectedItems();
对于(int i=0;i
我与编写“自动工具”Tasker插件的开发人员联系

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

插件,用OCR授权的图像解释,并返回单词和每个单词的xy位置中心


如果有人搜索Android和Tasker应用程序的类似功能,请访问链接。它非常有用。

我与编写“自动工具”Tasker插件的开发人员联系

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

插件,用OCR授权的图像解释,并返回单词和每个单词的xy位置中心


如果有人搜索Android和Tasker应用程序的类似功能,请访问链接。非常有用。

首先感谢您的关注。看起来像Java代码。您是否建议学习Android基础知识并编写自己的应用程序?首先感谢您的兴趣。看起来像Java代码。你是否建议学习Android基础知识并编写自己的应用程序?这些不是你想要的自动工具。([autotools]标记指GNU构建系统的一些关键组件。据我所知,任何使用该名称的OCR包都没有标记。标记已编辑。)这些不是您要查找的autotools。(自动工具标签是指GNU构建系统的一些关键组件。据我所知,任何使用该名称的OCR包都没有标签。标签已编辑。)