特定对象/图像识别任务的最佳方法?
我正在照片中搜索某个对象:
对象:中间有 X 的矩形轮廓。它看起来像一个矩形复选框。就这样。所以,没有填充,只有线条。该矩形将具有相同的长宽比,但它可以是照片中的任何尺寸或任何旋转。
我研究了一大堆图像识别方法。但我正在尝试确定这项特定任务的最佳方案。最重要的是,该对象是由线条组成的,而不是填充的形状。此外,不存在透视变形,因此矩形物体在照片中始终具有直角。
有什么想法吗?我希望有一些我可以相当轻松地实现的东西。
谢谢大家。
I'm searching for an certain object in my photograph:
Object: Outline of a rectangle with an X in the middle. It looks like a rectangular checkbox. That's all. So, no fill, just lines. The rectangle will have the same ratios of length to width but it could be any size or any rotation in the photograph.
I've looked a whole bunch of image recognition approaches. But I'm trying to determine the best for this specific task. Most importantly, the object is made of lines and is not a filled shape. Also, there is no perspective distortion, so the rectangular object will always have right angles in the photograph.
Any ideas? I'm hoping for something that I can implement fairly easily.
Thanks all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以尝试使用角点检测器(例如 Harris)来查找框的角点、端点和 X 的交点。这简化了在正确配置中查找点的问题。
编辑(回复评论):
我假设您可以找到图像中的角点、矩形的 4 个角、X 的 4 条线末端和 X 的中心,以及图像中的其他一些角由于背景中的噪音或物体。这将问题简化为从给定的点集中找到一组正确配置的 9 个点。
我的第一次尝试是查看每个角点 A。然后我会迭代靠近 A 的点 B。现在,如果我假设(例如)A 是矩形的左上角,B 是右下角,我可以轻松计算出我期望其他角点在图像中的位置。我会使用一些最近邻搜索(或像 FLANN 这样的库)来查看是否有我期望的角落。如果我能找到一组与这些预期位置相匹配的点,我就知道符号会在哪里(如果它出现在图像中)。
您必须尝试一下这是否足以满足您的应用程序。如果您有太多误报(意外形成矩形+ X 的其他对象的角集),您可以检查是否存在您期望的线条(即正确方向的高对比度)。您可以检查图案中没有线条的地方是否存在低对比度。一旦您知道图像中与您要查找的对象中的角/线末端相对应的点,这应该相对简单。
You could try using a corner detector (e.g. Harris) to find the corners of the box, the ends and the intersection of the X. That simplifies the problem to finding points in the right configuration.
Edit (response to comment):
I'm assuming you can find the corner points in your image, the 4 corners of the rectangle, the 4 line endings of the X and the center of the X, plus a few other corners in the image due to noise or objects in the background. That simplifies the problem to finding a set of 9 points in the right configuration, out of a given set of points.
My first try would be to look at each corner point A. Then I'd iterate over the points B close to A. Now if I assume that (e.g.) A is the upper left corner of the rectangle and B is the lower right corner, I can easily calculate, where I would expect the other corner points to be in the image. I'd use some nearest-neighbor search (or a library like FLANN) to see if there are corners where I'd expect them. If I can find a set of points that matches these expected positions, I know where the symbol would be, if it is present in the image.
You have to try if that is good enough for your application. If you have too many false positives (sets of corners of other objects that accidentially form a rectangle + X), you could check if there are lines (i.e. high contrast in the right direction) where you would expect them. And you could check if there is low contrast where there are no lines in the pattern. This should be relatively straightforward once you know the points in the image that correspond to the corners/line endings in the object you're looking for.
我建议使用广义霍夫变换。看起来你的形状相当简单、固定。广义霍夫变换应该能够检测图像中任何旋转或缩放的形状。您可能需要对原始图像进行阈值处理,或者以某种方式对其进行预处理,以便此方法发挥作用。
I'd suggest the Generalized Hough Transform. It seems you have a fairly simple, fixed shape. The generalized Hough transform should be able to detect that shape at any rotation or scale in the image. You many need to threshold the original image, or pre-process it in some way for this method to be useful though.
您可以使用局部特征来识别图像中的对象。 特征检测 wiki
例如,您可以计算某些参考图像上的特征,该图像仅包含您要查找的对象并将结果保存到纯文本文件中。之后,您可以通过将新计算的特征(在包含对象的某些复杂场景的图像上)与参考特征进行比较来搜索对象。
以下是一些有关本地功能的好资源:
局部不变特征检测器:一项调查
You can use local features to identify the object in image. Feature detection wiki
For example, you can calculate features on some referent image which contains only the object you're looking for and save the results, let's say, to a plain text file. After that you can search for the object just by comparing newly calculated features (on images with some complex scenes containing the object) with the referent ones.
Here's some good resource on local features:
Local Invariant Feature Detectors: A Survey