认识矩形
我有一个笔画点列表,我想检测这个笔画是否是矩形。 所以4个角大约是90度。然后我需要矩形的大小、位置和方向。
我使用的是 C#,但其他语言的算法或伪代码也很有用。
谢谢
I have a list of points of a stroke and I want to detect if this stroke is rectangular.
So 4 angles of approximately 90 degrees. Afterwards I need the size, position and orientation of the rectangle.
I am using C# but algorithms in other languages or pseudocode are also usefull.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您将每个笔划收集到一个单独的列表中:
找到任何趋势线的长度(从一个交点到另一条交点的距离),以及它的相邻(相交)线的长度,这两个长度将是您的长度和宽度(或者宽度和高度,如果你喜欢)用于尺寸计算(面积,或其他任何东西)。
如果所有点都采样到同一个集合中,您首先需要将此集合分成 4 个笔画(这本身就是一项艰巨的任务...更艰巨的任务)
I'll assume that you collected each stroke into a separate list:
Find the length of any of the trend lines (distance from one intersection to the other), and the length of on of it's adjacent (intersecting) lines, these two lengths will be your length and width (or width and height if you like) for size calculation (area, or anything else).
In case all points are sampled into the same collection, you first need to break this collection into the 4 strokes (which is a though task on it's own...tougher task)
嗯,我不久前做了类似的东西。
您可以在此处下载。
http://up352.siz.co.il/up2/lhmjmdenn53m.png
这个东西可以让你检测边缘 - 正如你所看到的,它非常准确。
当你得到边缘时,你所需要的就是计算它们之间的角度 - 如果它是 ~ 90 那么它是一个矩形。
Well, I've made something like this a while ago.
You can download it here.
http://up352.siz.co.il/up2/lhmjmdenn53m.png
This thing allows you to detect edges - as you see its pretty accurate.
When you get the edges all you need is to calculate the angles between them - and if it's ~ 90 then its a rectangle.