问题描述
我已经编写了算法来提取图像中显示的点。它们形成凸形,我知道它们的顺序。如何从这些点提取角点(顶部3和底部3)?
我使用opencv。
如果你已经有对象的凸包,并且船体包括角点,要做的是简化船体,直到它只有6点。
有很多方法来简化多边形,例如你可以使用这个简单的算法:
<$对于凸包上的每个点P,p $ p>
do
:
测量其与P之前的点A和点B之间的线AB _
的距离在P之后,
删除具有最小距离的点
重复,直到6点左
如果你不知道确切的点数,那么你可以删除点,直到最小距离超过一定阈值
你也可以来简化多边形,openCV已经实现了。
只需修改使用6点而不是4
I have written algorithm to extract the points shown in the image. They form convex shape and I know order of them. How do I extract corners (top 3 and bottom 3) from such points?I'm using opencv.
if you already have the convex hull of the object, and that hull includes the corner points, then all you need to to do is simplify the hull until it only has 6 points.
There are many ways to simplify polygons, for example you could just use this simple algorithm used in this answer: How to find corner coordinates of a rectangle in an image
do
for each point P on the convex hull:
measure its distance to the line AB _
between the point A before P and the point B after P,
remove the point with the smallest distance
repeat until 6 points left
If you do not know the exact number of points, then you could remove points until the minimum distance rises above a certain threshold
you could also do Ramer-Douglas-Peucker to simplify the polygon, openCV already has that implemented in cv::approxPolyDP.
Just modify the openCV squares sample to use 6 points instead of 4
这篇关于从凸点获得拐角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!