寻找图像中的网格

发布于 2024-12-06 08:03:08 字数 559 浏览 0 评论 0原文

拥有三消游戏屏幕截图(例如 http://www .gameplay3.com/images/games/jewel-quest-ii-01S.jpg),找到网格(带有图块的表格)的边界框的正确方法是什么?棋盘不必是完美的矩形(如屏幕截图所示),但每个单元格都是完全正方形的。

我尝试过几个游戏,发现可以对每个游戏进行一些图像转换来增强网格内的图块(例如,在这个游戏中,将 V 通道从 HSV 颜色空间中取出就足够了)。然后我可以放大图块,使它们重叠,找到图像的最大轮廓并从中获取边界框。

上述方法的问题在于,每个游戏(甚至同一游戏中的关卡)可能需要不同的转换才能获得图块。所以问题是 - 是否有一种标准方法来增强网格内的图块或网格线(我尝试使用霍夫变换查找线,但是,尽管网格看起来非常明显,但霍夫没有找到它) ?

另外,如果使用手机摄像头而不是桌面截图呢?根据我的经验,捕获的图像具有不太明确的颜色(这取决于照明),并且也可能会有点扭曲,因为无法将手机精确地保持在屏幕前面。

Having a match-3 game screenshot (for example http://www.gameplay3.com/images/games/jewel-quest-ii-01S.jpg), what would be the correct way to find the bound box for the grid (table with tiles)? The board doesn't have to be a perfect rectangle (as can be seen in the screenshot), but each cell is completely square.

I've tried several games, and found that there are some per-game image transformations that can be done to enhance the tiles inside the grid (for example in this game it's enough to take the V channel out of HSV color space). Then I can enlarge the tiles so that they overlap, find the largest contour of the image and get the bound box from it.

The problem with above approach is that every game (or even level inside the same game) may need a different transformation to get hold of the tiles. So the question is - is there a standard way to enhance either tiles inside the grid or grid's lines (I've tried finding lines with Hough transform, but, although the grid seems pretty visible to the eye, Hough doesn't find it)?

Also, what if the screenshot is obtained using the phone camera instead of taking a screenshot of a desktop? From my experience, captured images have less defined colors (which depends on lighting), and also can be distorted a little, as there is no way to hold the phone exactly in front of the screen.

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

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

发布评论

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

评论(1

辞取 2024-12-13 08:03:08

我会采用以下方法进行屏幕截图:

  1. 使用例如精明的边缘检测器来查找图像中的角点。
  2. 执行霍夫线变换。这在边缘图像上应该效果很好。
  3. 如果您有关于图块大小的一些信息,您可以使用某种网格空间模型消除误报线(例如,与图像的 x/y 轴和/或图块的距离/角度仅具有小角度的线) 您
  4. 通过查找线下/旁边的线来识别找到的霍夫线下的平铺边界。

使用了哪种霍夫变换实现?

另一种方法是使用某种方法 ?正如你的机器学习方法。在 OpenCV 中工作,您可以使用 Haar 类特征检测器。可以在此处找到使用 Haar 类特征进行人脸检测的示例:

OpenCV Haar 人脸检测器示例

另一种机器学习方法是遵循定向梯度直方图 (Hog) 方法与支持向量机 (SVM) 的结合。示例位于此处:

HOG 示例

您可以找到一般信息有关 HoG 检测的信息,请访问:

Hog 检测

I would go with the following approach for a screenshot:

  1. Find corners in the image using for example a canny like edge detector.
  2. Perform a hough line transform. This should work quite nicely on the edge image.
  3. If you have some information about size of the tiles you could eliminate false positive lines using some sort of spatial model of the grid (eg. lines only having a small angle to x/y axis of the image and/or distance/angle of tile borders.
  4. Identifiy tile borders under the found hough lines by looking for edges found by canny under/next to the lines.

Which implementation of the hough transform did you use? How did you preprocess the image?

Another approach would be to use some sort of machine learning approach. As you are working in OpenCV you could use either a Haar like feature detector. An example for face detection using Haar like features can be found here:

OpenCV Haar Face Detector example

Another machine learning approach would be to follow a Histogram of Oriented Gradients (Hog) approach in combination with a Support Vector Machine (SVM). An example is located here:

HOG example

You can find general information about HoG detection at:

Hog detection

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