QAugmentedReality - Local based augmented reality component
This article explains how to implement Augmented Reality engine that provides all functionalities to create your own local based augmented reality application like Nokia City Lens.
Note: This is an entry in the PureView Imaging Competition 2012Q2
QAugmentedReality is a Augmented Reality engine that provides all functionalities to create your own local based augmented reality application like Nokia City Lens or social applications for example displaying your friends location or your parked car location direction.
Developer just need to setup for each item the longitude, latitude, description text, image and the engine will do the hard work to manage rendering, gps, compass.
The component built entirely from scratch, inherits all camera features adding GPS, Accelerometer and Compass support.
Anyway the component's strength is the model support that allows you to easy manage your data to display. To add a pin into your scene you just need to add a QAugmentedRealityCameraItem element to QAugmentedRealityCameraModel to obtain a result like below:
Get Started with QAugmentedReality
- Download the project from here
- Include QAugmentedReality directory into your project
Q_DECL_EXPORT int main(int argc, char *argv)
QScopedPointer<QApplication> app(createApplication(argc, argv));
qmlRegisterType<QAugmentedRealityCamera>("QAugmentedRealityCamera", 1, 0, "QAugmentedRealityCamera");
qmlRegisterType<QAugmentedRealityCameraModel>("QAugmentedRealityCamera", 1, 0, "QAugmentedRealityCameraModel");
qmlRegisterType<QAugmentedRealityCameraItem>("QAugmentedRealityCamera", 1, 0, "QAugmentedRealityCameraItem");
qmlRegisterType<QAugmentedRealityCameraDelegate>("QAugmentedRealityCamera", 1, 0, "QAugmentedRealityCameraDelegate");
// Resize the root QML element to view size
// Performance optimization flags
import QtQuick 1.1
import QAugmentedRealityCamera 1.0
"message": "Peschiera Borromeo",
"message": "Buenos Aires",
"infoBox" : "white"
QAugmentedRealityCamera is the component that provide not only the camera display feature, but includes GPS, Accelerometer, and Compass to display Pins on screen and being able to move them depending on watching direction.
To add a pin you need setup a QAugmentedRealityCameraModel for the component.
QAugmentedRealityCameraModel has a pins property that have to be filled with QAugmentedRealityCameraItem element.
You can add QAugmentedRealityCameraItem both in a static a dynamic way.
Adding a Pin statically
Adding a Pin dynamically
This approach is preferred when fetching data from a database.
"message": "Peschiera Borromeo",
QAugmentedRealityCameraItem has the following properties:
- message - Is the description text displayed inside the pin
- infoBox - Is the color of the box drawn on the left of the pin. This is because to give you the possibility to have pins of different color for your own purpose
- source - As for infoBox this feature allow you to set an image for your pin. Transparent images are allowed. The infoBox background color will be displayed on transparent areas.
The component inherits from a base camera component, the same for QHdrCamera, so is possible to capture photos as a normal camera component. The result image will include the augmented reality items into the scene.
This feature will be improved as soon as possible to be fitable with all resolutions.
Earth is not flat
Managing pins with very huge distances you can encounter in a strange effect because we are accustomed to watch maps using the Mercator projection. Let's consider the example showcased on the video above.
I loaded data with some of the most important cities in the world. Let's consider Milan, where I'm located, Berlin, Tokyo and Melbourne. Watching to Berlin direction being located in Milan you could think that Berlin is located above Milan, Tokyo on the right and Melbourne on the bottom right.
However this is an error due to Mercator projection in fact application will show Berlin, Tokyo and Melbourne almost near in watching direction. This happens because the earth has a spherical shape and points in a sphere are located using polar coordinate system.
In our example happens that the bearing between Milan, Berlin, Tokyo and Melbourne and more the very huge distances that occurs, make it the application show these point of interest very near considering the direction watching angle. From my point of view this is not a problem and reflects the real world, but you have to consider this aspect if you plan to manage very huge distances. Anyway in the most common cases you will manage point of interest very near ( few kilometer/miles ) so the effect is reduced or near to zero.
Improvements that will come as soon as possible:
- filter item based on max distance, for example to display just items far less then 150mt
- At time of writing the delegate is static. if possible to allow users to create their own delegate
- Provided a customizable delegate the next step is to provide a customizable model
- qmldir usage
Despite improvements that will come the component is easy and powerful enough to start creating your local based augmented reality applications and enjoy with them.
I'm available for any help about component and opened to suggestions for further improvements.