Tuesday, December 18, 2012

On map Augmented Reality with Vuforia + Unity

I have been doing some more development with Android, using a different (and easier) renderer this time than the still nascent OpenSceneGraph port, with a bit of Augmented Reality thrown in via Vuforia.Which basically functions as an OpenCV port with image orientation recognition thrown in optimized for Qualcomm's Snapdragon SoC. The feature detection and texture packing is annoyingly performed at the Qualcomm site, I guess they want to keep track of images over which features are detected and prevent inappropriate use by script kiddies. From the looks of FastCV, the features are either MSER or Harris corners.
I already have Android dev kits going so the fun bit was in importing our nice models into Unity and sending the package over to the device. Textured models seem to import best into Unity via Blender, after a bit of copying around of textures and forcing association with the right materials.
Setting up the scene in Unity is fairly straight forward, the Vuforia SDK delegated to Unity for rendering and simply attaches a handler to the Camera. The visible object is automatically centred in the scene so the camera to target geometry is irrelevant in this case. However lighting is not, so a bit of tweaking in lights is necessary for a nice model render. Switch all the materials to diffuse/mobile to load the appropriate shaders in GLES2. Add an LODGroup node if the model is getting too big, though I was able to render some 100,000 triangle models.
When all is set the tracking can begin. I lined up the model to our orthoimagery, the screenshot does not do it justice. It is really cool watching a 3D object stick out of your screen. Everybody at work is very used to viewing things in stereo, but multi-perspective 3D still has a wow-factor.

No comments: