透视投影在Android中的增强现实应用程序 [英] Perspective Projection in Android in an augmented reality application

查看:216
本文介绍了透视投影在Android中的增强现实应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在写一个增强现实应用程序,我有一些问题得到对象我的屏幕上。这是非常令人沮丧的我,我不能够将GPS点到correspending屏幕上点我的Andr​​oid设备上。我读过许多文章和许多其他职位的计算器(我已经问类似的问题),但我还需要你的帮助。

Currently I'm writing an augmented reality app and I have some problems to get the objects on my screen. It's very frustrating for me that I'm not able to transform gps-points to the correspending screen-points on my android device. I've read many articles and many other posts on stackoverflow (I've already asked similar questions) but I still need your help.

我确实是在维基百科解释透视投影。

I did the perspective projection which is explained in wikipedia.

我有什么做的透视投影的结果来获得所产生的screenpoint?

What do I have to do with the result of the perspective projection to get the resulting screenpoint?

推荐答案

维基百科的文章也搞不清楚我,当我前一段时间阅读。这是我尝试不同的解释:

The Wikipedia article also confused me when I read it some time ago. Here is my attempt to explain it differently:

让我们简化的情况。我们有:

Let's simplify the situation. We have:

  • 在我们的投影点D(X,Y,Z) - 你所说的 relativePositionX | Y | Z
  • 尺寸的 W的图像平面的*的 ^ h
  • 系统半角α
  • Our projected point D(x,y,z) - what you call relativePositionX|Y|Z
  • An image plane of size w * h
  • A half-angle of view α

...我们想要的:

  • B的图像平面坐标(我们姑且称之为 X

为X的屏幕坐标的模式:

A schema for the X-screen-coordinates:

E是在这个配置我们的眼,这是我选择了为原点,以简化的位置。

E is the position of our "eye" in this configuration, which I chose as origin to simplify.

焦距的 F 的可估计知道:

  • 棕褐色(α)=(W / 2)/ F (1)

您可以在图片上,该三角形的 ECD EBM 的是类似于看的,所以使用的Side-Splitter定理,我们得到:

You can see on the picture that the triangles ECD and EBM are similar, so using the Side-Splitter Theorem, we get:

  • MB / CD = EM / EC < => X / X = F / Z (2)
  • MB / CD = EM / EC <=> X / x = f / z (2)

通过双方的(1)(2),我们现在有:

With both (1) and (2), we now have:

  • X =(X / Z)*((W / 2)/棕褐色(α))

如果我们回到维基百科的文章中使用的符号,我们的方程是等价于:

If we go back to the notation used in the Wikipedia article, our equation is equivalent to:

  • B_X =(D_X / d_z)* r_z

您可以看到我们缺少的乘 s_x / r_x 。这是因为在我们的情况下,显示尺寸和记录面是一样的,所以 s_x / r_x = 1

You can notice we are missing the multiplication by s_x / r_x. This is because in our case, the "display size" and the "recording surface" are the same, so s_x / r_x = 1.

注:同样的道理对于

一些备注:

  • 在一般情况下,的α= 90度的被使用,这意味着棕褐色(α)= 1 。这就是为什么这个词没有出现在许多实现。
  • 如果你想preserve您显示元素的比例,不断的 F 的恒定为 X 是,

  • Usually, α = 90deg is used, which means tan(α) = 1. That's why this term doesn't appear in many implementations.
  • If you want to preserve the ratio of the elements you display, keep f constant for both X and Y, ie instead of calculating:

  • X =(X / Z)*((W / 2)/棕褐色(α)) Y =(Y / Z) *((H / 2)/棕褐色(α))

...做的:

  • X =(X / Z)*((分(W,H)/ 2)/棕褐色(α)) Y = (Y / Z)*((分(W,H)/ 2)/棕褐色(α))

注:当我说的显示尺寸和记录   面是一样的的,这是不完全正确的,在   操作是在这里,以弥补这种近似,适应   方面的研究应用于潜在的矩形表面的取值的。

Note: when I said that "the "display size" and the "recording surface" are the same", that wasn't quite true, and the min operation is here to compensate this approximation, adapting the square surface r to the potentially-rectangular surface s.

注2:而不是使用的分(W,H)/ 2 的,Appunta使用 screenRatio =   (的getWidth()+的getHeight())/ 2 ,你注意到了。这两种解决方案preserve元素   比。的焦点,并认为这样的角度,将只是有点不同,   根据屏幕上的自己比。实际上,你可以使用任何你想要的功能   定义的 F

Note 2: Instead of using min(w,h) / 2, Appunta uses screenRatio= (getWidth()+getHeight())/2 as you noticed. Both solutions preserve the elements ratio. The focal, and thus the angle of view, will simply be a bit different, depending on the screen's own ratio. You can actually use any function you want to define f.

正如你可能已经注意到上述情况的图片,屏幕坐标之间的这里定义的 [ - W / 2; W / 2] 的X和 [ - H / 2; H / 2] 的Y的,但你可能想的 [0; W] [0; H] 的替代。 X + = W / 2 Y + = H / 2 - 问题解决了

  • As you may have noticed on the picture above, the screen coordinates are here defined between [-w/2 ; w/2] for X and [-h/2 ; h/2] for Y, but you probably want [0 ; w] and [0 ; h] instead. X += w/2 and Y += h/2 - Problem solved.

    我希望这会回答你的问题。我会在不久的如果需要的版本。

    I hope this will answer your questions. I'll stay near if it needs editions.

    再见!

    &LT;自推广警报> 的我居然取得了前一段时间的文章   关于3D投影和渲染。实施是在   JavaScript的,但它应该是很容易转化

    < Self-promotion Alert > I actually made some time ago an article about 3D projection and rendering. The implementation is in Javascript, but it should be quite easy to translate.

    这篇关于透视投影在Android中的增强现实应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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