基于像素模式识别的自动化Java框架

发布于 2024-12-05 14:29:32 字数 165 浏览 3 评论 0原文

我必须使用 Java 开发某种用于测试背景的机器人。我们将 Selenium 用于所有网络内容,以及浏览器之外:像素识别;也就是说,截取屏幕截图,然后将其与我已有的图像进行比较,并获取该图案在屏幕截图上的坐标。

有什么框架或免费的 Java 库可以让这项工作变得更容易吗?

提前致谢!

I have to develop some kind of bot for a testing background with Java. We used Selenium for all the web stuff, and outside the browser: Pixel recognition; that is, taking a screenshot, then compare it with a image I have already, and get the coordinates of where that pattern is on the screenshot.

Any Framework or free Java libraries that could make this job easier?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

绿光 2024-12-12 14:29:32

您可能可以使用以下方法:

  • 使用 java .awt.Robot 将屏幕捕获作为 BufferedImage
  • 将 BufferedImage 转换为字节数组
  • 执行标准字符串匹配搜索以在字节数组中找到模式。即使是简单的字符串搜索(即在每个可能的位置检查模式)也可能足够快。
  • 将字节数组中的位置转换回图像坐标

You could probably get the following to work:

  • Use java.awt.Robot to take a screen capture as a BufferedImage
  • Convert the BufferedImage to a byte array
  • Do a standard string matching search to locate the pattern in the byte array. Even a naive string search (i.e. checking for the pattern at every possible location) could well be fast enough.
  • Convert the position in the byte array back to image co-ordinates
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文