SlideShare a Scribd company logo
Programming
Augmented Reality:
Make your own sci-fi
Mobile App Dev
@praeclarum
Frank A. Krueger
Augmented Reality
a live direct or indirect view of a physical,
real-world environment whose elements
are augmented (or supplemented) by
computer-generated sensory input such
as sound, video, graphics or GPS data
Programming Augmented Reality - Xamarin Evolve
Programming Augmented Reality - Xamarin Evolve
Why Augmented Reality?
• Presents data in a way that we are
accustomed to
• Can present a lot of data in multiple
ways
Useful
• Remember the Terminator, he was fun
right?
• Extends our senses
• Physical games are more fun
Fun
• Takes advantage of distinguishing
platform elements
Mobile Only
Anatomy
World Simulation
Video Camera
Location & Orientation
Augmented View
Anatomy
World Simulation
Video Camera
Location & Orientation
Augmented View
This is where the magic
happens
AR library
Video Camera
Video Camera
■
Many resolutions (width and height) and
framerates
■
Image filtering controls
■
Field of View
■
High-performance code - be careful!
■
8 x 106 pixels * 30 Hz =
240,000,000 pixels / second
It all starts here
Directly Accessing the Camera (iOS)
session = new AVCaptureSession ();

session.SessionPreset = AVCaptureSession.PresetMedium;

device = AVCaptureDevice.DefaultDeviceWithMediaType (AVMediaType.Video);

device.LockForConfiguration(out error);

device.ActiveVideoMinFrameDuration = new CMTime (1, 30);

device.UnlockForConfiguration();

input = AVCaptureDeviceInput.FromDevice (device, out error);

session.AddInput (input);

Getting Images (iOS)
output = new AVCaptureVideoDataOutput ();

output.VideoSettings = new AVVideoSettings (CVPixelFormatType.CV32BGRA);

queue = new DispatchQueue ("VideoCameraQueue");

output.SetSampleBufferDelegateAndQueue (new VideoCameraDelegate { Camera = this } , queue);

session.AddOutput (output);

class VideoCameraDelegate : AVCaptureVideoDataOutputSampleBufferDelegate

{

public override void DidOutputSampleBuffer (AVCaptureOutput captureOutput,
CMSampleBuffer sampleBuffer, 

AVCaptureConnection connection)

{

try {

var frame = ImageFromSampleBuffer (sampleBuffer);

Camera.OnFrameCaptured (frame);

sampleBuffer.Dispose ();

} catch (Exception ex) {

Debug.WriteLine (ex);

}

}

}

Field of View
public float FieldOfView {

get {

return device.ActiveFormat.VideoFieldOfView;

}

}
Field of View (FOV)
is the Visible Angle
Location & Orientation
Location Sensor
■
Our friends Latitude & Longitude
■
Altitude above sea level (sometimes)
■
10m resolution, on a good day
■
“Better” with Wi-fi
■
“Not great” indoors
■
(There are alternatives such as
triangulation from known points)
Global Spherical Coordinates
Receiving Location Updates
lman = new CLLocationManager {

DesiredAccuracy = CLLocation.AccuracyBest,

};



lman.LocationsUpdated += (sender, e) => {

var loc = e.Locations [0];


Timestamp = loc.Timestamp;

Location = new Location (loc.Coordinate.Latitude, loc.Coordinate.Longitude, loc.Altitude);

HorizontalAccuracy = loc.HorizontalAccuracy;

VerticalAccuracy = loc.VerticalAccuracy;
};



lman.StartUpdatingLocation ();
Orientation Sensor
■
Pitch, Roll, Yaw (3 numbers)
■
Quaternion (4 numbers)
■
4x4 Transformation Matrix (16
numbers)
A Variety of Formats
Pitch
Yaw
Roll
■
Need a “reference orientation” or known
orientation from which to measure
It’s relative…
Receiving Orientation Updates
mman = new CMMotionManager {

ShowsDeviceMovementDisplay = true,

};



mman.StartDeviceMotionUpdates (


// CMAttitudeReferenceFrame.XArbitraryZVertical,

// CMAttitudeReferenceFrame.XArbitraryCorrectedZVertical,

// CMAttitudeReferenceFrame.XMagneticNorthZVertical,

CMAttitudeReferenceFrame.XTrueNorthZVertical,


new NSOperationQueue (),


(motion, error) => {



Orientation = ToMatrix4d (motion.Attitude.RotationMatrix);



} );



Augmented View
How do you augment th
Video Camera images?
Augmentation Techniques
Overlay 2D Annotations
• Heads Up Display
• Terminator
• Use OpenGL, SceneKit, MonoGame, …
• Mixing virtual reality with augmented
Show 3D Virtual Objects
Distort Camera Image
• Enhance recognized and correlated objects
• Hot / Cold Maps
• Pixel perfect
• No lag
Aligning the Augmented View to the Video
Camera
A Pinhole Camera Model
• Simple
• Used by 3D renderers
• Only depends on Field of View
• “Close enough” to the video camera
In a 3D Cartesian World
• Use 3D X, Y, Z coordinates instead of
Latitude, Longitude, Altitude
• Orient the camera by applying the
orientation transform
Projection
Matrix
ModelView
Matrix
Pinhole Camera Model
Projection
Matrix
ModelView
Matrix
3D
Worl
d
Point
2D
View
Point
x x =
(after a
perspective
divide)
Video Camera
Location &
Orientation
Projection Matrix
public static Matrix4d GetProjectionMatrix (VideoCamera videoCamera, UIImage frame)

{

return Matrix4d.CreatePerspectiveFieldOfView (
fovy: videoCamera.FieldOfView,
aspect: frame.Size.Width / frame.Size.Height,
zNear: 0.01,

zFar: 4700);

}
ModelView Matrix - Two Techniques
• Very easy
• Not accurate
• High latency
• Best for outdoor unpredictable
environments
Location & Orientation
Sensors
• Very difficult
• Very accurate
• No latency
• Best for indoor or controlled
environments
Image Recognition
ModelView Matrix from Location & Orientation
public static Matrix4d GetModelView (Location location, Matrix4d orientation)

{

// 1. Calculate position in 3D cartesian world
// 2. Find “up"
// 3. Orient to face the north pole
// 4. Apply the device orientation

}

ModelView Matrix: Location to 3D Cartesian
• Center of earth is at (0, 0, 0)
• Does not rotate, the universe around it does
• Physically accurate
• X, Y, Z are generally unintelligible
Earth-centered, Earth-fixed
• Flatten the earth like a map
• X axis is East/West
• Y axis is North/South
• Z axis is Altitude
North, East, Up
ModelView Matrix: Location to 3D Cartesian (ECEF)
//

// 1. Calculate position in 3D cartesian world

//

var pos = location.Position;

public Vector3d Position {

get {

var omega = ToRad * Longitude;

var phi = ToRad * Latitude;

var r = RadiusOfEarth + Altitude;



return new Vector3d (

r * Math.Cos(phi) * Math.Cos(omega),

r * Math.Cos(phi) * Math.Sin(omega),

r * Math.Sin(phi));

}

}
• (X, Y, Z)
ModelView Matrix: Up
//

// 2. Find "up"

//

var up = location.Position;
up.Normalize ();

• (0, 0, 0)
• (X, Y, Z)
Up
ModelView Matrix: Look at the North Pole
//

// 3. Orient to face the north pole

//

var northPos = Location.NorthPole.Position;

var northZAxis = (pos - northPos);

northZAxis.Normalize ();

var northYAxis = up;

var northXAxis = Vector3d.Cross (northYAxis, northZAxis);

northXAxis.Normalize ();

northZAxis = Vector3d.Cross (northXAxis, northYAxis);

northZAxis.Normalize ();

var lookNorthI = new Matrix4d (

new Vector4d(northXAxis),

new Vector4d(northYAxis),

new Vector4d(northZAxis),

Vector4d.UnitW);

Location NorthPole = new Location (90, 0, 0);
True North
• (X, Y, Z)
ModelView Matrix: Orient
//

// 4. Apply the device orientation

//

var newOrient = new Matrix4d (

-orientation.Column1,

orientation.Column2,

-orientation.Column0,

Vector4d.UnitW);

var newOrientI = newOrient;

newOrientI.Transpose ();

var modelViewI = (newOrientI * lookNorthI);

modelViewI.Row3 = new Vector4d (pos.X, pos.Y, pos.Z, 1);
var modelView = modelViewI;

modelView.Invert ();

return modelView;
Location to 2D View
Projection
Matrix
ModelView
Matrix
3D
Worl
d
Point
2D
View
Point
x x =
(after a
perspective
divide)
Location to 2D View
public PointF LocationToView (Location location)

{

// Move location to 3D earth

var pos3d = new Vector4d (location.Position, 1);



// Camera model

var m = Matrix4d.Mult (modelViewMatrix, projectionMatrix);



// Project into homogeneous 2D point

var pos2h = Vector4d.Transform (pos3d, m);



// Perform the perspective divide

var pos2 = pos2h / pos2h.W;



// Stretch into our view

return new PointF (

(float)((pos2.X + 1) * 0.5) * viewSize.Width,

(float)((-pos2.Y + 1) * 0.5) * viewSize.Height

);

}



Demo
Same Math Can be Used to Make 3D
void SetOpenGLCamera ()

{

GL.MatrixMode (All.Projection);

GL.LoadMatrix (ref projectionMatrix.Row0.X);


GL.MatrixMode (All.Modelview);

GL.LoadMatrix (ref modelViewMatrix.Row0.X);

}



Demo
World Simulation
It’s up to you
The world’s full of geo tagged
data
Applications
Games
• Massively Multiplayer
Online Live Action Role
Playing Games
(MMOLARPGs)
• Treasure Hunt
• Intercontinental Worms
• Friend locator
• Friend holograms
• Tourist attractions
Social
• Physically secure digital
goods
• Architectural projections
• Airplane & satellite
tracking
• Boat tracking
Industrial
DroidAR, ARmedia, Vuforia, ARLab, Beyond Reality Face,
D'Fusion, instantreality, Metaio SDK, Viewdle, Xloudia, ARPA,
ALVAR, AndAR, AR23D, ARToolkit, Aurasma, Awila,
BeyondAR, Catchoom, Cortexia, Google Goggles, IN2AR,
Koozyt, layar, LibreGeoSocial, mixare, NyARToolkit, Obvious
Engine, PanicAR, PointCloud, popcode, PRAugmentedReality,
PTAM, Qoncept AR, Robocortex, SLARToolkit, snaptell, SSTT,
String, Studierstube Tracker, UART, Wikitude, xpose visual
search, yvision, Zenitum Feature Tracker
45+ Mobile SDKs to Choose From
http://socialcompare.com/en/comparison/augmented-reality-sdks
Thank you
Frank A. Krueger
@praeclarum
https://github.com/praeclarum/ARDemo

More Related Content

PDF
XNA L02–Basic Matrices and Transformations
PPT
viewing3d pipeline
PDF
[shaderx7] 4.1 Practical Cascaded Shadow Maps
PPTX
Photogrammetry for Architecture and Construction
PPT
3 d viewing
PPT
Shading
PPT
Paris Master Class 2011 - 04 Shadow Maps
PPT
Build Your Own 3D Scanner: The Mathematics of 3D Triangulation
XNA L02–Basic Matrices and Transformations
viewing3d pipeline
[shaderx7] 4.1 Practical Cascaded Shadow Maps
Photogrammetry for Architecture and Construction
3 d viewing
Shading
Paris Master Class 2011 - 04 Shadow Maps
Build Your Own 3D Scanner: The Mathematics of 3D Triangulation

What's hot (20)

PPTX
Hidden surface removal
PDF
01 ray-optics-mm
PPT
PPTX
Types of stereoscope
DOC
Reflection Of Light (Assignment )by Atc,ANURAG TYAGI CLASSES
PPTX
3D transformation and viewing
PPTX
Massive Point Light Soft Shadows
PDF
Hidden Surface Removal using Z-buffer
PPTX
Stereoscopic Parallax
PPT
Shading in OpenGL
PPT
Hidden surfaces
PPT
Paris Master Class 2011 - 02 Screen Space Material System
PDF
Poster_Final
PPTX
3 d display methods
PPTX
Close range Photogrammeetry
PDF
02 principle of photography and imaging
PDF
Lecture 7 setero parllax
PPT
Build Your Own 3D Scanner: Surface Reconstruction
PPTX
Final Presentation
PPTX
Back face detection
Hidden surface removal
01 ray-optics-mm
Types of stereoscope
Reflection Of Light (Assignment )by Atc,ANURAG TYAGI CLASSES
3D transformation and viewing
Massive Point Light Soft Shadows
Hidden Surface Removal using Z-buffer
Stereoscopic Parallax
Shading in OpenGL
Hidden surfaces
Paris Master Class 2011 - 02 Screen Space Material System
Poster_Final
3 d display methods
Close range Photogrammeetry
02 principle of photography and imaging
Lecture 7 setero parllax
Build Your Own 3D Scanner: Surface Reconstruction
Final Presentation
Back face detection
Ad

Similar to Programming Augmented Reality - Xamarin Evolve (20)

PDF
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
PPT
Seven Feiner's Presentation at Emerging Communications Conference & Awards 20...
KEY
What's my geometry?
PDF
COMP 4010 Lecture10: AR Tracking
PDF
Marker-based Augmented Monuments on iPhone and iPad
PDF
"Using Inertial Sensors and Sensor Fusion to Enhance the Capabilities of Embe...
PDF
Jürgen Sturm (Google): The Computer Vision Technology Underlying ARCore
PDF
Augmented Reality: Beyond the Hype
PDF
2022 COMP4010 Lecture4: AR Interaction
PDF
Slide Pieter Jonker_Yolande Kolstee
PDF
Slide Pieter Jonker_Yolande Kolstee
PDF
Pose estimation algorithm for mobile augmented reality based on inertial sen...
PDF
2022 COMP4010 Lecture3: AR Technology
PDF
Comp4010 Lecture4 AR Tracking and Interaction
PDF
Electronic tour guide
PDF
The Wonderful-Amazing-Orientation-Motion-Sensormatic Machine
PDF
Saad alsheekh multi view
PDF
Developing AR and VR Experiences with Unity
KEY
Aesthetec at MEIC5, augmenting the world
PDF
Comp4010 Lecture5 Interaction and Prototyping
203 Is It Real or Is It Virtual? Augmented Reality on the iPhone
Seven Feiner's Presentation at Emerging Communications Conference & Awards 20...
What's my geometry?
COMP 4010 Lecture10: AR Tracking
Marker-based Augmented Monuments on iPhone and iPad
"Using Inertial Sensors and Sensor Fusion to Enhance the Capabilities of Embe...
Jürgen Sturm (Google): The Computer Vision Technology Underlying ARCore
Augmented Reality: Beyond the Hype
2022 COMP4010 Lecture4: AR Interaction
Slide Pieter Jonker_Yolande Kolstee
Slide Pieter Jonker_Yolande Kolstee
Pose estimation algorithm for mobile augmented reality based on inertial sen...
2022 COMP4010 Lecture3: AR Technology
Comp4010 Lecture4 AR Tracking and Interaction
Electronic tour guide
The Wonderful-Amazing-Orientation-Motion-Sensormatic Machine
Saad alsheekh multi view
Developing AR and VR Experiences with Unity
Aesthetec at MEIC5, augmenting the world
Comp4010 Lecture5 Interaction and Prototyping
Ad

More from Frank Krueger (9)

PDF
Open Source CLRs - Seattle Mobile .NET
PDF
Asynchronous Application Patterns in C# - MonkeySpace
PDF
3 Mobile App Dev Problems - Monospace
PPTX
Algorithms - Future Decoded 2016
PDF
How I Made Zoom In and Enhance - Seattle Mobile .NET
PDF
Overview of iOS 11 - Seattle Mobile .NET
PPTX
Functional GUIs with F#
PDF
Mocast Postmortem
PPT
Programming iOS in C#
Open Source CLRs - Seattle Mobile .NET
Asynchronous Application Patterns in C# - MonkeySpace
3 Mobile App Dev Problems - Monospace
Algorithms - Future Decoded 2016
How I Made Zoom In and Enhance - Seattle Mobile .NET
Overview of iOS 11 - Seattle Mobile .NET
Functional GUIs with F#
Mocast Postmortem
Programming iOS in C#

Recently uploaded (20)

PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
medical staffing services at VALiNTRY
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Nekopoi APK 2025 free lastest update
PDF
Designing Intelligence for the Shop Floor.pdf
PPTX
history of c programming in notes for students .pptx
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Computer Software and OS of computer science of grade 11.pptx
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
System and Network Administration Chapter 2
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
Digital Systems & Binary Numbers (comprehensive )
wealthsignaloriginal-com-DS-text-... (1).pdf
Softaken Excel to vCard Converter Software.pdf
Reimagine Home Health with the Power of Agentic AI​
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
medical staffing services at VALiNTRY
CHAPTER 2 - PM Management and IT Context
Design an Analysis of Algorithms II-SECS-1021-03
Nekopoi APK 2025 free lastest update
Designing Intelligence for the Shop Floor.pdf
history of c programming in notes for students .pptx
Design an Analysis of Algorithms I-SECS-1021-03
Computer Software and OS of computer science of grade 11.pptx
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
System and Network Administration Chapter 2
VVF-Customer-Presentation2025-Ver1.9.pptx
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
2025 Textile ERP Trends: SAP, Odoo & Oracle

Programming Augmented Reality - Xamarin Evolve

  • 1. Programming Augmented Reality: Make your own sci-fi Mobile App Dev @praeclarum Frank A. Krueger
  • 2. Augmented Reality a live direct or indirect view of a physical, real-world environment whose elements are augmented (or supplemented) by computer-generated sensory input such as sound, video, graphics or GPS data
  • 5. Why Augmented Reality? • Presents data in a way that we are accustomed to • Can present a lot of data in multiple ways Useful • Remember the Terminator, he was fun right? • Extends our senses • Physical games are more fun Fun • Takes advantage of distinguishing platform elements Mobile Only
  • 6. Anatomy World Simulation Video Camera Location & Orientation Augmented View
  • 7. Anatomy World Simulation Video Camera Location & Orientation Augmented View This is where the magic happens AR library
  • 9. Video Camera ■ Many resolutions (width and height) and framerates ■ Image filtering controls ■ Field of View ■ High-performance code - be careful! ■ 8 x 106 pixels * 30 Hz = 240,000,000 pixels / second It all starts here
  • 10. Directly Accessing the Camera (iOS) session = new AVCaptureSession ();
 session.SessionPreset = AVCaptureSession.PresetMedium;
 device = AVCaptureDevice.DefaultDeviceWithMediaType (AVMediaType.Video);
 device.LockForConfiguration(out error);
 device.ActiveVideoMinFrameDuration = new CMTime (1, 30);
 device.UnlockForConfiguration();
 input = AVCaptureDeviceInput.FromDevice (device, out error);
 session.AddInput (input);

  • 11. Getting Images (iOS) output = new AVCaptureVideoDataOutput ();
 output.VideoSettings = new AVVideoSettings (CVPixelFormatType.CV32BGRA);
 queue = new DispatchQueue ("VideoCameraQueue");
 output.SetSampleBufferDelegateAndQueue (new VideoCameraDelegate { Camera = this } , queue);
 session.AddOutput (output);
 class VideoCameraDelegate : AVCaptureVideoDataOutputSampleBufferDelegate
 {
 public override void DidOutputSampleBuffer (AVCaptureOutput captureOutput, CMSampleBuffer sampleBuffer, 
 AVCaptureConnection connection)
 {
 try {
 var frame = ImageFromSampleBuffer (sampleBuffer);
 Camera.OnFrameCaptured (frame);
 sampleBuffer.Dispose ();
 } catch (Exception ex) {
 Debug.WriteLine (ex);
 }
 }
 }

  • 12. Field of View public float FieldOfView {
 get {
 return device.ActiveFormat.VideoFieldOfView;
 }
 } Field of View (FOV) is the Visible Angle
  • 14. Location Sensor ■ Our friends Latitude & Longitude ■ Altitude above sea level (sometimes) ■ 10m resolution, on a good day ■ “Better” with Wi-fi ■ “Not great” indoors ■ (There are alternatives such as triangulation from known points) Global Spherical Coordinates
  • 15. Receiving Location Updates lman = new CLLocationManager {
 DesiredAccuracy = CLLocation.AccuracyBest,
 };
 
 lman.LocationsUpdated += (sender, e) => {
 var loc = e.Locations [0]; 
 Timestamp = loc.Timestamp;
 Location = new Location (loc.Coordinate.Latitude, loc.Coordinate.Longitude, loc.Altitude);
 HorizontalAccuracy = loc.HorizontalAccuracy;
 VerticalAccuracy = loc.VerticalAccuracy; };
 
 lman.StartUpdatingLocation ();
  • 16. Orientation Sensor ■ Pitch, Roll, Yaw (3 numbers) ■ Quaternion (4 numbers) ■ 4x4 Transformation Matrix (16 numbers) A Variety of Formats Pitch Yaw Roll ■ Need a “reference orientation” or known orientation from which to measure It’s relative…
  • 17. Receiving Orientation Updates mman = new CMMotionManager {
 ShowsDeviceMovementDisplay = true,
 };
 
 mman.StartDeviceMotionUpdates ( 
 // CMAttitudeReferenceFrame.XArbitraryZVertical,
 // CMAttitudeReferenceFrame.XArbitraryCorrectedZVertical,
 // CMAttitudeReferenceFrame.XMagneticNorthZVertical,
 CMAttitudeReferenceFrame.XTrueNorthZVertical, 
 new NSOperationQueue (), 
 (motion, error) => {
 
 Orientation = ToMatrix4d (motion.Attitude.RotationMatrix);
 
 } );
 

  • 19. How do you augment th Video Camera images?
  • 20. Augmentation Techniques Overlay 2D Annotations • Heads Up Display • Terminator • Use OpenGL, SceneKit, MonoGame, … • Mixing virtual reality with augmented Show 3D Virtual Objects Distort Camera Image • Enhance recognized and correlated objects • Hot / Cold Maps • Pixel perfect • No lag
  • 21. Aligning the Augmented View to the Video Camera A Pinhole Camera Model • Simple • Used by 3D renderers • Only depends on Field of View • “Close enough” to the video camera In a 3D Cartesian World • Use 3D X, Y, Z coordinates instead of Latitude, Longitude, Altitude • Orient the camera by applying the orientation transform Projection Matrix ModelView Matrix
  • 22. Pinhole Camera Model Projection Matrix ModelView Matrix 3D Worl d Point 2D View Point x x = (after a perspective divide) Video Camera Location & Orientation
  • 23. Projection Matrix public static Matrix4d GetProjectionMatrix (VideoCamera videoCamera, UIImage frame)
 {
 return Matrix4d.CreatePerspectiveFieldOfView ( fovy: videoCamera.FieldOfView, aspect: frame.Size.Width / frame.Size.Height, zNear: 0.01,
 zFar: 4700);
 }
  • 24. ModelView Matrix - Two Techniques • Very easy • Not accurate • High latency • Best for outdoor unpredictable environments Location & Orientation Sensors • Very difficult • Very accurate • No latency • Best for indoor or controlled environments Image Recognition
  • 25. ModelView Matrix from Location & Orientation public static Matrix4d GetModelView (Location location, Matrix4d orientation)
 {
 // 1. Calculate position in 3D cartesian world // 2. Find “up" // 3. Orient to face the north pole // 4. Apply the device orientation
 }

  • 26. ModelView Matrix: Location to 3D Cartesian • Center of earth is at (0, 0, 0) • Does not rotate, the universe around it does • Physically accurate • X, Y, Z are generally unintelligible Earth-centered, Earth-fixed • Flatten the earth like a map • X axis is East/West • Y axis is North/South • Z axis is Altitude North, East, Up
  • 27. ModelView Matrix: Location to 3D Cartesian (ECEF) //
 // 1. Calculate position in 3D cartesian world
 //
 var pos = location.Position;
 public Vector3d Position {
 get {
 var omega = ToRad * Longitude;
 var phi = ToRad * Latitude;
 var r = RadiusOfEarth + Altitude;
 
 return new Vector3d (
 r * Math.Cos(phi) * Math.Cos(omega),
 r * Math.Cos(phi) * Math.Sin(omega),
 r * Math.Sin(phi));
 }
 } • (X, Y, Z)
  • 28. ModelView Matrix: Up //
 // 2. Find "up"
 //
 var up = location.Position; up.Normalize ();
 • (0, 0, 0) • (X, Y, Z) Up
  • 29. ModelView Matrix: Look at the North Pole //
 // 3. Orient to face the north pole
 //
 var northPos = Location.NorthPole.Position;
 var northZAxis = (pos - northPos);
 northZAxis.Normalize ();
 var northYAxis = up;
 var northXAxis = Vector3d.Cross (northYAxis, northZAxis);
 northXAxis.Normalize ();
 northZAxis = Vector3d.Cross (northXAxis, northYAxis);
 northZAxis.Normalize ();
 var lookNorthI = new Matrix4d (
 new Vector4d(northXAxis),
 new Vector4d(northYAxis),
 new Vector4d(northZAxis),
 Vector4d.UnitW);
 Location NorthPole = new Location (90, 0, 0); True North • (X, Y, Z)
  • 30. ModelView Matrix: Orient //
 // 4. Apply the device orientation
 //
 var newOrient = new Matrix4d (
 -orientation.Column1,
 orientation.Column2,
 -orientation.Column0,
 Vector4d.UnitW);
 var newOrientI = newOrient;
 newOrientI.Transpose ();
 var modelViewI = (newOrientI * lookNorthI);
 modelViewI.Row3 = new Vector4d (pos.X, pos.Y, pos.Z, 1); var modelView = modelViewI;
 modelView.Invert ();
 return modelView;
  • 31. Location to 2D View Projection Matrix ModelView Matrix 3D Worl d Point 2D View Point x x = (after a perspective divide)
  • 32. Location to 2D View public PointF LocationToView (Location location)
 {
 // Move location to 3D earth
 var pos3d = new Vector4d (location.Position, 1);
 
 // Camera model
 var m = Matrix4d.Mult (modelViewMatrix, projectionMatrix);
 
 // Project into homogeneous 2D point
 var pos2h = Vector4d.Transform (pos3d, m);
 
 // Perform the perspective divide
 var pos2 = pos2h / pos2h.W;
 
 // Stretch into our view
 return new PointF (
 (float)((pos2.X + 1) * 0.5) * viewSize.Width,
 (float)((-pos2.Y + 1) * 0.5) * viewSize.Height
 );
 }
 

  • 33. Demo
  • 34. Same Math Can be Used to Make 3D void SetOpenGLCamera ()
 {
 GL.MatrixMode (All.Projection);
 GL.LoadMatrix (ref projectionMatrix.Row0.X); 
 GL.MatrixMode (All.Modelview);
 GL.LoadMatrix (ref modelViewMatrix.Row0.X);
 }
 

  • 35. Demo
  • 37. It’s up to you The world’s full of geo tagged data
  • 38. Applications Games • Massively Multiplayer Online Live Action Role Playing Games (MMOLARPGs) • Treasure Hunt • Intercontinental Worms • Friend locator • Friend holograms • Tourist attractions Social • Physically secure digital goods • Architectural projections • Airplane & satellite tracking • Boat tracking Industrial
  • 39. DroidAR, ARmedia, Vuforia, ARLab, Beyond Reality Face, D'Fusion, instantreality, Metaio SDK, Viewdle, Xloudia, ARPA, ALVAR, AndAR, AR23D, ARToolkit, Aurasma, Awila, BeyondAR, Catchoom, Cortexia, Google Goggles, IN2AR, Koozyt, layar, LibreGeoSocial, mixare, NyARToolkit, Obvious Engine, PanicAR, PointCloud, popcode, PRAugmentedReality, PTAM, Qoncept AR, Robocortex, SLARToolkit, snaptell, SSTT, String, Studierstube Tracker, UART, Wikitude, xpose visual search, yvision, Zenitum Feature Tracker 45+ Mobile SDKs to Choose From http://socialcompare.com/en/comparison/augmented-reality-sdks
  • 40. Thank you Frank A. Krueger @praeclarum https://github.com/praeclarum/ARDemo