增强现实 - 将 GPS 映射到 OpenGL
我正在编写一个 Android AR 应用程序,并且我的引擎正在工作,但它包含一个我似乎无法修复的奇怪行为。我将 OpenGL 表面覆盖在相机图像上,并相应地将 3D 对象放置在视图中。如果我使用虚拟数据作为 AR 对象的位置,即 LAT 10 LON 10 在 OpenGL 表面上变为 x=10 y=10,则叠加效果完美。但是,如果我对 LAT 和 LON 使用直接 GPS 坐标(例如 LAT 12.34567890 LON 100.23456789),那么我的所有对象要么在其位置周围移动,要么根本不出现。我知道使用浮点和 OpenGL 框架存在问题,但我一直在阅读周围的内容,但仍然无法阻止这种行为。还有其他人遇到过这个问题吗?我应该在 GPS 和 openGL 表面之间使用比例因子吗?如果是的话,什么值比较好?我尝试将 LAT 和 LON 缩放 1000000 以消除浮点,但这没有帮助,而且性能很糟糕。
我即将完成这项工作,任何帮助将不胜感激。
I am writing an Android AR application and have my engine working but it contains a strange behaviour that I can't seem to get fix. I am overlaying an OpenGL surface on the camera image and am placing 3D objects in the view accordingly. If I use dummy data for the location of my AR objects, i.e. LAT 10 LON 10 become x=10 y=10 on the OpenGL surface, then the overlay works perfectly. However, if I use direct GPS coordinates for my LAT and LON (e.g. LAT 12.34567890 LON 100.23456789) then all my objects either move around their location or don't appear at all. I know there are issues around using floating points and the OpenGL framework, but I've been reading around and am still having trouble stopping this behaviour. Has anyone else had this problem? Should I be using a scaling factor between my GPS and openGL surface, if so what values are good? I tried scaling my LAT and LON by 1000000 to eliminate the floating point, but it didn't help and the performance was terrible.
I'm so close to getting this working, that any help would be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找出您的原始坐标位于哪个 1x1 或 0.5x0.5 度“盒子”中,然后减去该盒子,这样您的坐标现在是相对于“盒子”而不是整个世界的。
因此 LAT 12.34567890 LON 100.23456789 位于框 (12,100) 中,坐标为 (0.34567890, 0.23456789)。您需要将 (0.34567890, 0.23456789) 传递给 OpenGL。
从 +/-180.0 度范围的浮点中获得约 1m 的精度充其量也有点粗略,一旦你开始执行所有 OpenGL 的矩阵运算,事情就会开始变得非常糟糕。
Figure out which 1x1 or 0.5x0.5 degree 'box' your raw coordinates are in and then subtract out that box, so your coordinates are now relative to the 'box' instead of the whole world.
So LAT 12.34567890 LON 100.23456789 is in box (12,100), with coordinates (0.34567890, 0.23456789). You'll want to pass in the (0.34567890, 0.23456789) to OpenGL.
Getting ~1m accuracy from a float with +/-180.0 degree range is kinda sketchy at best, and once you start doing all of OpenGL's matrix operations things start jittering around pretty bad.