Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Augmented Reality - Mapping GPS to OpenGL

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.

like image 237
Snowwire Avatar asked Feb 02 '10 22:02

Snowwire


1 Answers

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.

like image 155
genpfault Avatar answered Oct 06 '22 15:10

genpfault