寻找图像中的网格
拥有三消游戏屏幕截图(例如 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会采用以下方法进行屏幕截图:
使用了哪种霍夫变换实现?
另一种方法是使用某种方法 ?正如你的机器学习方法。在 OpenCV 中工作,您可以使用 Haar 类特征检测器。可以在此处找到使用 Haar 类特征进行人脸检测的示例:
OpenCV Haar 人脸检测器示例
另一种机器学习方法是遵循定向梯度直方图 (Hog) 方法与支持向量机 (SVM) 的结合。示例位于此处:
HOG 示例
您可以找到一般信息有关 HoG 检测的信息,请访问:
Hog 检测
I would go with the following approach for a screenshot:
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