×
Namespaces

Variants
Actions
(Difference between revisions)

QAugmentedReality - Local based augmented reality component

From Nokia Developer Wiki
Jump to: navigation, search
galazzo (Talk | contribs)
(Galazzo -)
galazzo (Talk | contribs)
(Galazzo -)
Line 28: Line 28:
 
== Summary ==
 
== Summary ==
 
The component built entirely from scratch, inherits all camera features adding [http://doc.qt.nokia.com/qtmobility/location-overview.html GPS], [http://doc.qt.nokia.com/qtmobility-1.2/qml-accelerometer.html Accelerometer] and [http://doc.qt.nokia.com/qtmobility/qml-compass.html Compass] support.<br />
 
The component built entirely from scratch, inherits all camera features adding [http://doc.qt.nokia.com/qtmobility/location-overview.html GPS], [http://doc.qt.nokia.com/qtmobility-1.2/qml-accelerometer.html Accelerometer] and [http://doc.qt.nokia.com/qtmobility/qml-compass.html Compass] support.<br />
Anyway the component's strenght 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 {{{Icode|QAugmentedRealityCameraItem}}} element to {{{Icode|QAugmentedRealityCameraModel}}} to obtain a result like below:<br />
+
Anyway the component's strenght 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 {{Icode|QAugmentedRealityCameraItem}} element to {{Icode|QAugmentedRealityCameraModel}} to obtain a result like below:<br />
 
{{#ev:youtube|WFez-3_xp64}}
 
{{#ev:youtube|WFez-3_xp64}}
  
Line 172: Line 172:
 
== QAugmentedRealityCamera ==
 
== QAugmentedRealityCamera ==
 
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 wacthing direction.<br />
 
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 wacthing direction.<br />
To add a pin you need setup a {{{Icode|QAugmentedRealityCameraModel}}} for the component.
+
To add a pin you need setup a {{Icode|QAugmentedRealityCameraModel}} for the component.
  
 
== QAugmentedRealityCameraModel ==
 
== QAugmentedRealityCameraModel ==
QAugmentedRealityCameraModel has a {{{Icode|pins}}} property that have to be filled with {{{Icode|QAugmentedRealityCameraItem}}} element. <br />
+
QAugmentedRealityCameraModel has a {{Icode|pins}} property that have to be filled with {{Icode|QAugmentedRealityCameraItem}} element. <br />
You can add {{{Icode|QAugmentedRealityCameraItem}}} both in a static a dynamic way.
+
You can add {{Icode|QAugmentedRealityCameraItem}} both in a static a dynamic way.
  
 
=== Adding a Pin statically ===
 
=== Adding a Pin statically ===
Line 204: Line 204:
 
}
 
}
 
</code>
 
</code>
 +
 +
== QAugmentedRealityCameraItem ==
 +
QAugmentedRealityCameraItem has the following properties:<br />
 +
* {{Icode|latitude}}
 +
* {{Icode|longitude}}
 +
* {{Icode|message}} - Is the description text displayed inside the pin
 +
* {{Icode|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
 +
* {{Icode|source}} - As for {{Icode|infoBox}} this features will allow you to set an image for your pin. Transparent images are allowed. The {{Icode|infoBox}} background color will be displayed on transparent areas.

Revision as of 02:28, 13 June 2012

Article Metadata
Tested with
Devices(s): Nokia N8, Nokia C7-00
Compatibility
Platform(s):
Symbian
Platform Security
Capabilities: Location, NetworkServices,UserEnvironment,ReadUserData
Article
Keywords: Augmented Reality, Camera, GPS, Compass
Created: galazzo (13 Jun 2012)
Last edited: galazzo (13 Jun 2012)

Contents

Introduction

QAugmentedReality is a camera component 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.

Summary

The component built entirely from scratch, inherits all camera features adding GPS, Accelerometer and Compass support.
Anyway the component's strenght 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 [projects.developer.nokia.com/QAugmentedReality here]
  • Include QAugmentedReality directory into your project

.pro

include(QAugmentedReality/AugmentedRealityLibrary.pri)

main.cpp

#include <QtGui/QApplication>
#include "qmlapplicationviewer.h"
 
#include <QtDeclarative>
#include "qaugmentedrealitycamera.h"
 
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QScopedPointer<QApplication> app(createApplication(argc, argv));
 
QmlApplicationViewer viewer;
 
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
viewer.setResizeMode(QDeclarativeView::SizeRootObjectToView);
 
// Performance optimization flags
viewer.setAttribute(Qt::WA_OpaquePaintEvent);
viewer.setAttribute(Qt::WA_NoSystemBackground);
viewer.viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
viewer.viewport()->setAttribute(Qt::WA_NoSystemBackground);
viewer.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
 
 
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationLockLandscape);
viewer.setMainQmlFile(QLatin1String("qml/QAugmentedRealitySample/main.qml"));
viewer.showExpanded();
 
return app->exec();
}


QML

import QtQuick 1.1
import QAugmentedRealityCamera 1.0
 
Rectangle {
id:home
width: 640
height: 360
color:"white"
 
QAugmentedRealityCameraModel {
id:pinsModel
pins: [
QAugmentedRealityCameraItem {
latitude: 41.891033
longitude:12.492599
message:"Rome"
source: ":/images/colosseo.jpg"
},
QAugmentedRealityCameraItem {
latitude: 45.463502
longitude:9.187946
message:"Milan"
source: ":/images/milan.jpg"
},
QAugmentedRealityCameraItem {
latitude: 48.856358
longitude:2.352047
message:"Paris"
infoBox: "#FFAA23"
source: ":/images/paris.jpg"
},
QAugmentedRealityCameraItem {
latitude: 51.50746
longitude:-0.127831
message:"London"
},
QAugmentedRealityCameraItem {
latitude: 52.518728
longitude:13.404465
message:"Berlin"
source: ":/images/berlin.jpg"
},
QAugmentedRealityCameraItem {
latitude: 40.714997
longitude:-74.006767
message:"New York"
source: ":/images/new-york.jpg"
},
QAugmentedRealityCameraItem {
latitude: 35.689649
longitude:139.691048
message:"Tokyo"
},
QAugmentedRealityCameraItem {
latitude: -37.813717
longitude:144.962955
message:"Melbourne"
infoBox: "blue"
}
]
}
 
QAugmentedRealityCamera {
id:camera
anchors.fill: parent
resolution: Qt.size(2592,1456)
model: pinsModel
}
 
Component.onCompleted:{
camera.start(camera.availableDevices[0])
 
pinsModel.append({
"latitude": 45.428094,
"longitude": 9.313946,
"message": "Peschiera Borromeo",
"source": ":/images/bino.jpg"
})
pinsModel.append({
"latitude": -34.603541,
"longitude": -58.381748,
"message": "Buenos Aires",
"infoBox" : "white"
})
 
}
}

QAugmentedRealityCamera

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 wacthing direction.
To add a pin you need setup a QAugmentedRealityCameraModel for the component.

QAugmentedRealityCameraModel

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

QAugmentedRealityCameraModel {
id:pinsModel
pins: [
QAugmentedRealityCameraItem {
latitude: 41.891033
longitude:12.492599
message:"Rome"
source: ":/images/colosseo.jpg"
}]
}

Adding a Pin dynamically

This approach is preferred when fetching data from a database.

Component.onCompleted:{
pinsModel.append({
"latitude": 45.428094,
"longitude": 9.313946,
"message": "Peschiera Borromeo",
"source": ":/images/bino.jpg"
})
}

QAugmentedRealityCameraItem

QAugmentedRealityCameraItem has the following properties:

  • latitude
  • longitude
  • 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 features will allow you to set an image for your pin. Transparent images are allowed. The infoBox background color will be displayed on transparent areas.
190 page views in the last 30 days.
×