[英]How to find Edges and Vertices of a hand drawn polygon
I would like to make a shape recognition program that would trace a mouse and record it's location at each 1/2 second.我想制作一个形状识别程序,可以跟踪鼠标并每 1/2 秒记录一次鼠标的位置。 How could I use these points to find a rough polygon?
我如何使用这些点来找到一个粗糙的多边形? In other words, if you just draw a shape resembling a triangle or square, it will more likely be a be a 50-100-gon, how can I simplify it to get the shape I were trying to draw?
换句话说,如果你只是画一个类似三角形或正方形的形状,它很可能是 50-100 边形,我怎样才能简化它以获得我想要绘制的形状? I know that you could do a genetic algorithm, but do not know exactly how that would work, and I would like to know any alternatives.
我知道你可以做一个遗传算法,但不知道它是如何工作的,我想知道任何替代方案。
edit: convex hulls will not work, concavity is needed to be preserved.编辑:凸包不起作用,需要保留凹面。
i'll give this a shot.我会试一试。
you might be able to determine the shape simply by counting sides.您也许可以通过计算边数来确定形状。
For each point along the 100-agon, find the area of the tiny triangle formed by that point and the points on either side.对于沿 100 边形的每个点,找到由该点和两侧的点形成的小三角形的面积。 Remove the point that created the smallest triangle.
删除创建最小三角形的点。 Repeat until the smallest triangle is larger than some threshold.
重复直到最小的三角形大于某个阈值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.