OpenGL ES-从摄影机位置获取2D像素坐标 [英] OpenGL ES - get 2D pixel coordinate from camera position

查看:370
本文介绍了OpenGL ES-从摄影机位置获取2D像素坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用OpenGL ES(IOS)和OpenCV.我想知道是否有一种方法可以从GLKMatrix4相机位置获取2D像素坐标吗?

I'm working with OpenGL ES (IOS) and OpenCV. I would like to know if there is a way to get 2D pixel coordinate from a GLKMatrix4 camera position ?

实际上,我使用OpenGL显示了一个特定的3D对象,该对象只有它的大小和它的相机姿势,我想将其转换为OpenCV参考坐标,即2D像素.

Indeed, I have a specific 3D object displayed with OpenGL which has only its size and its camera pose and I would like to convert it into the OpenCV reference Coordinate i.e 2D pixel.

更准确地说,我有一个IOS应用程序,并且可以传输相机颜色.此流与OpenGL一起显示在我的Ipad上.在此显示器上,我有一个特定的叠加层,它是一个3D对象.同时,我对OpenCV进行了一些检测.现在,我要通过3D对象将帧中的OpenCV(这是一个矩形绘制)与我的检测结果联系起来,但是对于这个对象,我只有其摄像机位置和大小.

More precisely, I have an IOS app and I stream the camera color. This stream is displayed with OpenGL on my Ipad. On this display, I have a specific overlay which is a 3D object. At the same time, I do some some detection with OpenCV. Now, I would like to link the result of my detection thank to OpenCV in my frame (It's a rectangle draw) with the 3D object but for this one, I have only its camera position and its size.

我知道4x4摄像头姿势的内容,但是没有找到有关如何将其转换为2D坐标的任何信息.

I know the content of a 4x4 camera pose but I did not find any information about how I could convert it (if it is possible) to a 2D coordinate.

因此简要地: 输入:2D矩形(仅获取2D坐标)和3D对象(仅获取其相机位置)

So briefly : Input : A 2D rectangle (get only 2D coordinate) and an 3D object (get only its camera position)

有办法吗?你能帮我吗?

Is there a way ? Could you please help me ?

谢谢

推荐答案

由于您已经在使用GLKit类型和数学,请尝试使用函数 GLKMathUnproject (如果您还需要其他方法).您将需要(假定)传递给着色器的(相同)模型视图和投影矩阵,以绘制场景.

Since you're already using GLKit types and math, try the function GLKMathProject to convert from 3D model space to viewport (window/pixel 2D) space, and GLKMathUnproject if you also need the other way around. You'll need the (same) modelview and projection matrices that you're (presumably) passing to a shader for drawing your scene.

这篇关于OpenGL ES-从摄影机位置获取2D像素坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆