java 如何检测图像中的形状?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5522771/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to detect shapes in an image?
提问by Manoj
I want to detect a circle, rectangle shaped object in an image and read the information from that object. Is there any api in java which will be helpful to me?
我想检测图像中的圆形、矩形对象并从该对象读取信息。java中是否有任何对我有帮助的api?
Ex: Detect a round shaped coin in a white background and obtain information about that that coin like ( value of a coin, etc.)
例如:检测白色背景中的圆形硬币并获取有关该硬币的信息,例如(硬币的价值等)
Thanks.
谢谢。
回答by mpenkov
Here's an answerto a similar question for C++.
这是对 C++ 的类似问题的回答。
For Java, you can use the OpenCV wrappers. However, once you understand the essence of the approach you should be able to solve your problem using whichever framework is available.
对于 Java,您可以使用OpenCV 包装器。但是,一旦您理解了该方法的本质,您就应该能够使用任何可用的框架来解决您的问题。
回答by code-gijoe
Circles are perfect targets for the Hough transform. Check this out Detect circles with HT and OpenCV
圆圈是霍夫变换的完美目标。看看这个用 HT 和 OpenCV 检测圆圈
Rectangles are a bit harder since the Hough Transform is not rotation invariant. You can go into edge detection and fast fitting (Fast line and rectangle detection by clustering and grouping)
矩形有点难,因为霍夫变换不是旋转不变的。您可以进入边缘检测和快速拟合(通过聚类和分组进行快速线和矩形检测)