将 3D 矩形映射到 2D 屏幕
我已经搜索过了,但我就是无法弄清楚这一点。其他问题没有帮助或者我不明白它们。
问题是,我的 3D 图像中有很多点。这些点针对的是矩形,由于透视原因,从 3D 相机的角度来看,该矩形看起来不像矩形。任务是将矩形中的点映射到屏幕上。我见过一些被称为“四边形到四边形变换”的方法,但大多数都是用于将二维四边形映射到另一个四边形。但我已经获得了现实世界中矩形的 X、Y 和 Z 坐标,因此我正在寻找一些更简单的方法。有谁知道任何实用的算法或方法吗?
如果有帮助的话,我的 3D 相机实际上是带有 OpenNI 和 NITE 中间件的 Kinect 设备,并且我正在使用 WPF。
提前致谢。
编辑: 我还在维基百科上找到了使用角度和余弦的 3d 投影页面,但这似乎是一种困难的方法(在 3d 图像中查找角度),我不确定这是否是真正的解决方案。
I've searched SO but I just can't figure this out. The other questions didn't help or I didn't understand them.
The problem is, I have a bunch of points in a 3D image. The points are for a rectangle, which doesn't look like a rectangle from the 3d camera's view because of perspective. The task is to map the points from that rectangle to the screen. I've seen some ways which some call "quad to quad transformations" but most of them are for mapping a 2d quadrilateral to another one. But I've got the X, Y and Z coordinates of the rectangle in the real world so I'm looking for some easier ways. Does anyone know any practical algorithm or method of doing this?
If it helps, my 3d camera is actually a Kinect device with OpenNI and NITE middlewares, and I'm using WPF.
Thanks in advance.
edit:
I also found the 3d-projection page on Wikipedia that used angles and cosines but that seems to be a difficult way (finding angles in the 3d image) and I'm not sure if it's the real solution or not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可能想查看投影矩阵
这就是任何 3D 光栅器“展平”3D 体积的方式2D 屏幕。
You might want to check out projection matrices
That's how any 3D rasterizer "flattens" 3D volumes on a 2D screen.
查看此代码 获取给定 WPF 相机的投影矩阵:
See this code to get the projection matrix for a given WPF camera:
您可以进行基本的正交投影(我正在考虑光线追踪,因此这可能不适用于您正在做的事情):
代码非常直观:
您只需将方向为
(0, 1, 0)
的向量直接射入太空并记录击中的向量即可。You could do a basic orthographic projection (I'm thinking in terms of raytracing, so this might not apply to what you're doing):
The code is quite intuitive:
You just shoot vectors with a direction of
(0, 1, 0)
directly out into space and record which ones hit.我找到了这个。使用直接的数学而不是矩阵。
这称为透视投影,将 3D 顶点转换为 2D 屏幕顶点。我用它来帮助我制作 3D 程序。
希望这能有所帮助。我想这就是你在寻找的东西。抱歉格式问题(这里是新的)
I found this. Uses straight forward mathematics instead of matricies.
This is called perspective projection to convert from a 3D vertex to a 2D screen vertex. I used this to help me with my 3D program I have made.
Hope this could help. I think its what you where looking for. Sorry about the formatting (new here)
将 3D 世界中的点映射到 2D 屏幕是 OpenGL 和 Direct3d 等框架工作的一部分。正如 Heandel 所说,这称为光栅化。也许你可以使用 Direct3d?
Mapping points in a 3d world to a 2d screen is part of the job of frameworks like OpenGL and Direct3d. It's called Rasterisation like Heandel said. Perhaps you could use Direct3d?