计算正方形的方向并显示具有相同方向的对象

发布于 2024-10-10 15:07:52 字数 426 浏览 8 评论 0原文

我编写了一个检测图像中的正方形的应用程序。为了让您更好地理解包含这样一个正方形的图像(在本例中是一个标记)可能看起来像:

检测后我得到的是标记四个角的坐标。现在我不知道如何在标记上显示对象。该对象应具有与标记相同的旋转/角度/方向。

是否有任何关于如何实现这一目标的论文,以及我可以使用的任何被证明非常可靠/有效的算法?

它不需要是一个可行的解决方案,它可以是关于如何实现该解决方案或类似内容的简单描述。如果你向我指出一个库或其他东西,它应该在 Linux 下工作,不需要 Windows,但如果我需要在某个时候移植应用程序,那就太好了。 我已经查看了 ARToolkit,但它们提供了相机参数文件和更复杂的矩阵,而我只获得了四个角点和单个图像,而不是整个视频/相机流。

I wrote an application which detects a square within an image. To give you a good understanding of how such an image containing such a square, in this case a marker, could look like:

What I get, after the detection, are the coordinates of the four corners of my marker. Now I don't know how to display an object on my marker. The object should have the same rotation/angle/direction as the marker.

Are there any papers on how to achieve that, any algorithms that I can use that proofed to be pretty solid/working?

It doesn't need to be a working solution, it could be a simple description on how to achieve that or something similar. If you point me at a library or something, it should work under linux, windows is not needed but would be great in case I need to port the application at some point.
I already looked at the ARToolkit but they you camera parameter files and more complex matrices while I only got the four corner points and a single image instead of a whole video / camera stream.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟雨扶苏 2024-10-17 15:07:52

我相信您可以使用 OpenCV 的 cvGetPerspectiveTransform 找到可以将正方形扭曲到标记角的变换,然后使用 cvWarpPerspective 扭曲图像。

I believe you can use OpenCV's cvGetPerspectiveTransform to find the transform that can warp a square to the marker's corners, and then cvWarpPerspective to warp the image.

岁月蹉跎了容颜 2024-10-17 15:07:52

这是一个正方形。它应该位于一个具有法线的平面上,我们需要找到它,因为这是我们放置物体的方式。我们可以假设所有 y 坐标均为 0,现在我们正在处理方面问题。也许我们可以从将其映射到 0-1 范围开始。最左边的点在 x 上得到 0,最右边的点得到 1,在 z 上也是如此 - 最近的得到 0,最远的得到 1。
我们可以通过检查对角线的长度来确定这一点。较短的一个连接前点和后点,接下来是另一个 2 点。
所以我们得到了像

       x z
left:  0 ?
right: 1 ?
front: ? 0
back:  ? 1

我认为的这些?可以通过边的方面来计算。使用平方可以简化问题。如果连接右前和左前的两条线相同,则左和右的 z 值为 0.5 。好吧,这样你就可以获得所有 3 个维度并使用向量叉积计算法线。然后,您可以将 y 轴作为高度的模型,计算用于将 0,1,0 向量旋转到您得到的法线的矩阵,然后绘制位置 2D 图像并正确缩放它。好吧,我不知道我是否对你有帮助,也许这不是它的工作方式,但我希望我写了一些有用的东西。

It's a square. It's supposed to lye in a plane that has normal and we need to find it because it's the way we should place our object. We can suppose that all y cooridnates are 0 and now we are dealing with aspect problem. Maybe we could start by mapping it into 0-1 range. Most left point gets 0 on x, most right 1, same will be on z - nearest get's 0 and farest 1.
we can determine this by checking length of diagonals. shorter one connects front and back point and next the other 2.
so we get something like

       x z
left:  0 ?
right: 1 ?
front: ? 0
back:  ? 1

I think these ? could be computed by aspect of sides. Using square simplifies problem. If 2 lines connecting front-right and front-left are same, z values of left and right are 0.5 . Well and this way you could get all 3 dimensions and using vector cross product compute normal. You could then take your models having y axis as height, compute matrix used to rotate 0,1,0 vector into normal you get, then draw position 2D image and scale it properly. Well I don't know if I helped you maybe it's not the way it even works but I hope I wrote something that can be useful.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文