简体   繁体   English

使用Java和BoofCV检测图像文件中的形状

[英]Using Java & BoofCV to detect shapes in an image file

I've not found anything here or on google. 我在这里或谷歌上找不到任何东西。 I'm looking for a way to identify shapes (circle, square, triangle and various other shapes) from a image file. 我正在寻找一种从图像文件中识别形状(圆形,方形,三角形和各种其他形状)的方法。 Some examples: 一些例子:

填充圆圈未填充的三角形十字架象限填充方块多种形状多种形状pac

You get the general idea. 你得到了一般的想法。 Not sure if BoofCV is the best choice here but it looks like it should be straightforward enough to use, but again I know nothing about it. 不确定BoofCV是否是这里的最佳选择,但它看起来应该是直截了当的,但我再也不知道它。 I've looked at some of the examples and I though before I get in over my head (which is not hard to do some days), I thought I would ask if there is any info out there. 我看了一些例子,但是在我进入头脑之前(这几天不难做),我想我会问是否有任何信息。

I'm taking a class on Knowledge Based AI solving Ravens Progressive Matrix problems and the final assignment will use strictly visual based images instead of the text files with attributes. 我正在上一节基于知识的AI解决乌鸦渐进矩阵问题,最终作业将使用严格的基于视觉的图像而不是带有属性的文本文件。 We are not being graded on the visual since we only have a few weeks to work on this section of the project and we are encouraged to share this information. 我们没有在视觉上评分,因为我们只有几个星期的时间来处理项目的这一部分,我们鼓励我们分享这些信息。 SOF has always been my go to source for information and I'm hoping someone out there might have some ideas on where to start with this... SOF一直是我的信息来源,我希望有人可能会有一些关于从哪里开始的想法......

Essentially what I want to do is detect the shapes (?? convert them into 2D geometry) and then make some assumptions about attributes such as size, fill, placement etc, create a text file with these attributes and then using that, send it through my existing code based that I wrote for my other projects to solve the problems. 基本上我想做的是检测形状(将它们转换成2D几何体),然后对大小,填充,放置等属性做一些假设,创建一个包含这些属性的文本文件,然后使用它,发送它我为其他项目编写的现有代码,用于解决问题。

Any suggestions???? 有什么建议么????

There are a lot of ways you can do it. 有很多方法可以做到。 One way is to find the contour of the shape then fit a polygon to it or a oval. 一种方法是找到形状的轮廓然后将多边形拟合到它或椭圆形。 If you git a polygon to it and there are 4 sides with almost equal length then its a square. 如果你给它一个多边形,并且有4个边的长度几乎相等,那么它就是一个正方形。 The contour can be found with binary blobs (my recommendation for the above images) or canny edge. 可以使用二进制blob(我对上述图像的建议)或canny edge找到轮廓。

http://boofcv.org/index.php?title=Example_Fit_Polygon http://boofcv.org/index.php?title=Example_Fit_Ellipse http://boofcv.org/index.php?title=Example_Fit_Polygon http://boofcv.org/index.php?title=Example_Fit_Ellipse

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM