Android 上的标记识别(识别魔方)

发布于 2024-08-24 10:29:17 字数 421 浏览 4 评论 0原文

我正在为 Android 开发一个增强现实应用程序,它使用手机的摄像头来识别魔方每个面上彩色方块的排列。

我不确定的一件事是我将如何准确地检测和识别立方体每个面上的彩色方块。如果您观察魔方,您会发现每个方块都是六种可能颜色中的一种,并带有细黑色边框。这让我认为检测正方形应该相对简单,可能使用现有的标记检测 API。

魔方

我的问题真的,这里有人有图像识别和 Android 方面的经验吗?理想情况下,我希望能够实现现有的 API,但如果有人能为我指明正确的入门方向,那么从头开始这将是一个有趣的项目。

非常感谢。

I'm developing an augmented reality application for Android that uses the phone's camera to recognise the arrangement of the coloured squares on each face of a Rubik's Cube.

One thing that I am unsure about is how exactly I would go about detecting and recognising the coloured squares on each face of the cube. If you look at a Rubik's Cube then you can see that each square is one of six possible colours with a thin black border. This lead me to think that it should be relativly simply to detect a square, possibly using an existing marker detection API.

Rubik's Cube

My question is really, has anybody here had any experience with image recognition and Android? Ideally I'd like to be able to implement and existing API, but it would be an interesting project to do from scratch if somebody could point me in the right direction to get started.

Many thanks in advance.

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

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

发布评论

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

评论(5

静赏你的温柔 2024-08-31 10:29:17

您想将相机对准立方体并让它了解配置吗?

识别照片中的物体是一个开放的人工智能问题。因此,您需要对问题进行相当多的限制才能获得任何牵引力。我建议从以下内容开始:

  1. 将从正好 12 英寸的距离拍摄立方体,并在相机正后方使用 100W 光源。立方体将按对角线放置,因此它恰好呈现 3 个面,其中一个角位于中心。相机的位置将直接聚焦在中心的立方体角上。

  2. 将拍摄一张照片。然后立方体将垂直和水平旋转 180 度,以便其他三个面可见。将拍摄第二张照片。由于您确切地知道每个面的预期位置,因此可以从每个区域中抓取一些像素,并假设这是该正方形的颜色。请记住,立方体通常会是混乱的,而不是如图所示的均匀的。因此,您始终必须查看 9*6 = 54 个小方块才能获得每个小方块的颜色。

  3. 这两张图片中的信息定义了立方体配置。生成相同配置的立方体图像,并允许用户确认或更正它。

拍摄 6 张照片(每张脸一张)可能会更简单,然后按照明确的顺序在这些脸周围移动。请记住,每个面的中心方块不会移动,并定义该面的正确颜色。

一旦完成配置,您就可以使用 OpenGL 操作来旋转立方体切片。这将是一个包含数百行代码的程序,用于定义和旋转立方体,以及您为图像识别所做的任何操作。

Do you want to point the camera at a cube, and have it understand the configuration?

Recognizing objects in photographs is an open AI problem. So you'll need to constrain the problem quite a bit to get any traction on it. I suggest starting with something like:

  1. The cube will be photographed from a distance of exactly 12 inches, with a 100W light source directly behind the camera. The cube will be set diagonally so it presents exactly 3 faces, with a corner in the center. The camera will be positioned so that it focuses directly on the cube corner in the center.

  2. A picture will taken. Then the cube will be turned 180 degrees vertically and horizontally, so that the other three faces are visible. A second picture will be taken. Since you know exactly where each face is expected to be, grab a few pixels from each region, and assume that is the color of that square. Remember that the cube will usually be scrambled, not uniform as shown in the picture here. So you always have to look at 9*6 = 54 little squares to get the color of each one.

  3. The information in those two pictures defines the cube configuration. Generate an image of the cube in the same configuration, and allow the user to confirm or correct it.

It might be simpler to take 6 pictures - one of each face, and travel around the faces in well-defined order. Remember that the center square of each face does not move, and defines the correct color for that face.

Once you have the configuration, you can use OpenGL operations to rotate the cube slices. This will be a program with hundreds of lines of code to define and rotate the cube, plus whatever you do for image recognition.

柠栀 2024-08-31 10:29:17

除了彼得所说的之外,当用户拍照时,最好在立方体的图片上叠加引导线。然后,用户将立方体排列在引导线内,无论是单边(方形引导线)还是三边(透视中的三个正方形)。您可能还希望用户指定每行中彩色框的数量。在代码中,在每个彩色框的中心位置对颜色进行采样,并将其与其他彩色框(在某个容差级别内)进行比较以识别颜色。除了向用户提供识别的结果之外,最好允许用户对识别的颜色进行更改。看起来并不需要花哨的图像识别。

In addition to what Peter said, it is probably best to overlay guide lines on the picture of the cube as the user takes the pictures. The user then lines up the cube within the guide lines, whether its a single side (a square guide line) or three sides (three squares in perspective). You also might want to have the user specify the number of colored boxes in each row. In your code, sample the color in what should be the center of each colored box and compare it to the other colored boxes (within some tolerance level) to identify the colors. In addition to providing the recognized results to the user, it would be nice to allow the user to make changes to the recognized colors. It does not seem like fancy image recognition is needed.

深爱成瘾 2024-08-31 10:29:17

好主意,我也计划使用计算机视觉和标记检测器,但用于另一个项目。我仍在寻找网络上是否有任何可用信息,例如:将 openCV 或 ARtoolkit 链接到 Android SDK。如果您有任何有关如何链接计算机视觉 API 的其他信息,请告诉我。

很快再见,祝你好运!

Nice idea, I'm planing to use computer vision and marker detectors too, but for another project. I am still looking if there is any available information on the web, ex: linking openCV or ARtoolkit to the Android SDK. If you have any additional information, about how to link a computer vision API, please let me know.

See you soon and goodluck!

丶情人眼里出诗心の 2024-08-31 10:29:17

NYARToolkit 使用标记检测并用 JAVA 制作(以及用于 Windows 设备的托管 C#)。我不知道它在android平台上的表现如何,但我见过它在windows移动设备上使用,而且做得非常好。

祝你好运,编程愉快!

NYARToolkit uses marker detection and is made in JAVA (as well as managed C# for windows devices). I don't know how well it works on the android platform, but I have seen it used on windows mobile devices, and its very well done.

Good luck, and happy programming!

谈场末日恋爱 2024-08-31 10:29:17

我建议查看 Andoid OpenCV 库。您可能想检查斑点检测算法。您可能还需要考虑霍夫线或计数来检测四边形。

I'd suggest looking at the Andoid OpenCV library. You probably want to examine the blob detection algorithms. You may also want to consider Hough lines or Countours to detect quads.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文