SlideShare a Scribd company logo
1 of 40
Download to read offline
Programming
Augmented Reality:
Make your own sci-ļ¬
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
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 ļ¬ltering 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-ļ¬
ā– 
ā€œ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 difļ¬cult
ā€¢ 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-ļ¬xed
ā€¢ 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

What's hot

Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removalPunyajoy Saha
Ā 
01 ray-optics-mm
01 ray-optics-mm01 ray-optics-mm
01 ray-optics-mmBharat Ranjan
Ā 
Types of stereoscope
Types of stereoscopeTypes of stereoscope
Types of stereoscopeMr Amol Ghogare
Ā 
Reflection Of Light (Assignment )by Atc,ANURAG TYAGI CLASSES
Reflection Of Light (Assignment )by Atc,ANURAG TYAGI CLASSESReflection Of Light (Assignment )by Atc,ANURAG TYAGI CLASSES
Reflection Of Light (Assignment )by Atc,ANURAG TYAGI CLASSESANURAG TYAGI CLASSES (ATC)
Ā 
3D transformation and viewing
3D transformation and viewing3D transformation and viewing
3D transformation and viewingabhishek1235010004
Ā 
Massive Point Light Soft Shadows
Massive Point Light Soft ShadowsMassive Point Light Soft Shadows
Massive Point Light Soft ShadowsWolfgang Engel
Ā 
Hidden Surface Removal using Z-buffer
Hidden Surface Removal using Z-bufferHidden Surface Removal using Z-buffer
Hidden Surface Removal using Z-bufferRaj Sikarwar
Ā 
Hidden surfaces
Hidden surfacesHidden surfaces
Hidden surfacesMohd Arif
Ā 
Paris Master Class 2011 - 02 Screen Space Material System
Paris Master Class 2011 - 02 Screen Space Material SystemParis Master Class 2011 - 02 Screen Space Material System
Paris Master Class 2011 - 02 Screen Space Material SystemWolfgang Engel
Ā 
3 d display methods
3 d display methods3 d display methods
3 d display methodsShami Al Rahad
Ā 
Close range Photogrammeetry
Close range PhotogrammeetryClose range Photogrammeetry
Close range Photogrammeetrychinmay khadke
Ā 
02 principle of photography and imaging
02 principle of photography and imaging02 principle of photography and imaging
02 principle of photography and imagingSarhat Adam
Ā 
Lecture 7 setero parllax
Lecture 7  setero parllaxLecture 7  setero parllax
Lecture 7 setero parllaxSarhat Adam
Ā 
Build Your Own 3D Scanner: Surface Reconstruction
Build Your Own 3D Scanner: Surface ReconstructionBuild Your Own 3D Scanner: Surface Reconstruction
Build Your Own 3D Scanner: Surface ReconstructionDouglas Lanman
Ā 
Back face detection
Back face detectionBack face detection
Back face detectionPooja Dixit
Ā 

What's hot (20)

Hidden surface removal
Hidden surface removalHidden surface removal
Hidden surface removal
Ā 
01 ray-optics-mm
01 ray-optics-mm01 ray-optics-mm
01 ray-optics-mm
Ā 
Stereoscopic vision
Stereoscopic visionStereoscopic vision
Stereoscopic vision
Ā 
Types of stereoscope
Types of stereoscopeTypes of stereoscope
Types of stereoscope
Ā 
Reflection Of Light (Assignment )by Atc,ANURAG TYAGI CLASSES
Reflection Of Light (Assignment )by Atc,ANURAG TYAGI CLASSESReflection Of Light (Assignment )by Atc,ANURAG TYAGI CLASSES
Reflection Of Light (Assignment )by Atc,ANURAG TYAGI CLASSES
Ā 
3D transformation and viewing
3D transformation and viewing3D transformation and viewing
3D transformation and viewing
Ā 
Massive Point Light Soft Shadows
Massive Point Light Soft ShadowsMassive Point Light Soft Shadows
Massive Point Light Soft Shadows
Ā 
Hidden Surface Removal using Z-buffer
Hidden Surface Removal using Z-bufferHidden Surface Removal using Z-buffer
Hidden Surface Removal using Z-buffer
Ā 
Stereoscopic Parallax
Stereoscopic ParallaxStereoscopic Parallax
Stereoscopic Parallax
Ā 
Shading in OpenGL
Shading in OpenGLShading in OpenGL
Shading in OpenGL
Ā 
Hidden surfaces
Hidden surfacesHidden surfaces
Hidden surfaces
Ā 
Paris Master Class 2011 - 02 Screen Space Material System
Paris Master Class 2011 - 02 Screen Space Material SystemParis Master Class 2011 - 02 Screen Space Material System
Paris Master Class 2011 - 02 Screen Space Material System
Ā 
Poster_Final
Poster_FinalPoster_Final
Poster_Final
Ā 
3 d display methods
3 d display methods3 d display methods
3 d display methods
Ā 
Close range Photogrammeetry
Close range PhotogrammeetryClose range Photogrammeetry
Close range Photogrammeetry
Ā 
02 principle of photography and imaging
02 principle of photography and imaging02 principle of photography and imaging
02 principle of photography and imaging
Ā 
Lecture 7 setero parllax
Lecture 7  setero parllaxLecture 7  setero parllax
Lecture 7 setero parllax
Ā 
Build Your Own 3D Scanner: Surface Reconstruction
Build Your Own 3D Scanner: Surface ReconstructionBuild Your Own 3D Scanner: Surface Reconstruction
Build Your Own 3D Scanner: Surface Reconstruction
Ā 
Final Presentation
Final PresentationFinal Presentation
Final Presentation
Ā 
Back face detection
Back face detectionBack face detection
Back face detection
Ā 

Similar to Programming Augmented Reality - Xamarin Evolve

Computer Graphics - Lecture 03 - Virtual Cameras and the Transformation Pipeline
Computer Graphics - Lecture 03 - Virtual Cameras and the Transformation PipelineComputer Graphics - Lecture 03 - Virtual Cameras and the Transformation Pipeline
Computer Graphics - Lecture 03 - Virtual Cameras and the Transformation PipelinešŸ’» Anton Gerdelan
Ā 
Core Location in iOS
Core Location in iOSCore Location in iOS
Core Location in iOSJuan C Catalan
Ā 
COMP 4010 Lecture10: AR Tracking
COMP 4010 Lecture10: AR TrackingCOMP 4010 Lecture10: AR Tracking
COMP 4010 Lecture10: AR TrackingMark Billinghurst
Ā 
Trident International Graphics Workshop 2014 2/5
Trident International Graphics Workshop 2014 2/5Trident International Graphics Workshop 2014 2/5
Trident International Graphics Workshop 2014 2/5Takao Wada
Ā 
Computer Science Presentation for various MATLAB toolboxes
Computer Science Presentation for various MATLAB toolboxesComputer Science Presentation for various MATLAB toolboxes
Computer Science Presentation for various MATLAB toolboxesThinHunh47
Ā 
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksBeginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksJinTaek Seo
Ā 
The Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math PrimerThe Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math PrimerJanie Clayton
Ā 
3D Math Primer: CocoaConf Chicago
3D Math Primer: CocoaConf Chicago3D Math Primer: CocoaConf Chicago
3D Math Primer: CocoaConf ChicagoJanie Clayton
Ā 
Entity Component System - a different approach to game and app development
Entity Component System - a different approach to game and app developmentEntity Component System - a different approach to game and app development
Entity Component System - a different approach to game and app developmentMaxim Zaks
Ā 
Oculus Rift DK2 + Leap Motion Tutorial
Oculus Rift DK2 + Leap Motion TutorialOculus Rift DK2 + Leap Motion Tutorial
Oculus Rift DK2 + Leap Motion TutorialChris Zaharia
Ā 
XNA L04ā€“Primitives, IndexBuffer and VertexBuffer
XNA L04ā€“Primitives, IndexBuffer and VertexBufferXNA L04ā€“Primitives, IndexBuffer and VertexBuffer
XNA L04ā€“Primitives, IndexBuffer and VertexBufferMohammad Shaker
Ā 
Object Size Detector - Computer Vision
Object Size Detector - Computer VisionObject Size Detector - Computer Vision
Object Size Detector - Computer VisionShyama Bhuvanendran
Ā 
4. THREE DIMENSIONAL DISPLAY METHODS
4.	THREE DIMENSIONAL DISPLAY METHODS4.	THREE DIMENSIONAL DISPLAY METHODS
4. THREE DIMENSIONAL DISPLAY METHODSSanthiNivas
Ā 
I os developers_meetup_4_sessionon_locationservices
I os developers_meetup_4_sessionon_locationservicesI os developers_meetup_4_sessionon_locationservices
I os developers_meetup_4_sessionon_locationservicesMahboob Nur
Ā 
426 Lecture5: AR Registration
426 Lecture5: AR Registration426 Lecture5: AR Registration
426 Lecture5: AR RegistrationMark Billinghurst
Ā 
Developing a Multiplayer RTS with the Unreal Engine 3
Developing a Multiplayer RTS with the Unreal Engine 3Developing a Multiplayer RTS with the Unreal Engine 3
Developing a Multiplayer RTS with the Unreal Engine 3Nick Pruehs
Ā 
affine transformation for computer graphics
affine transformation for computer graphicsaffine transformation for computer graphics
affine transformation for computer graphicsDrSUGANYADEVIK
Ā 

Similar to Programming Augmented Reality - Xamarin Evolve (20)

Computer Graphics - Lecture 03 - Virtual Cameras and the Transformation Pipeline
Computer Graphics - Lecture 03 - Virtual Cameras and the Transformation PipelineComputer Graphics - Lecture 03 - Virtual Cameras and the Transformation Pipeline
Computer Graphics - Lecture 03 - Virtual Cameras and the Transformation Pipeline
Ā 
Core Location in iOS
Core Location in iOSCore Location in iOS
Core Location in iOS
Ā 
COMP 4010 Lecture10: AR Tracking
COMP 4010 Lecture10: AR TrackingCOMP 4010 Lecture10: AR Tracking
COMP 4010 Lecture10: AR Tracking
Ā 
Trident International Graphics Workshop 2014 2/5
Trident International Graphics Workshop 2014 2/5Trident International Graphics Workshop 2014 2/5
Trident International Graphics Workshop 2014 2/5
Ā 
Indoor Navigation
Indoor NavigationIndoor Navigation
Indoor Navigation
Ā 
Maps
MapsMaps
Maps
Ā 
Computer Science Presentation for various MATLAB toolboxes
Computer Science Presentation for various MATLAB toolboxesComputer Science Presentation for various MATLAB toolboxes
Computer Science Presentation for various MATLAB toolboxes
Ā 
report
reportreport
report
Ā 
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksBeginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Ā 
The Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math PrimerThe Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math Primer
Ā 
3D Math Primer: CocoaConf Chicago
3D Math Primer: CocoaConf Chicago3D Math Primer: CocoaConf Chicago
3D Math Primer: CocoaConf Chicago
Ā 
Entity Component System - a different approach to game and app development
Entity Component System - a different approach to game and app developmentEntity Component System - a different approach to game and app development
Entity Component System - a different approach to game and app development
Ā 
Oculus Rift DK2 + Leap Motion Tutorial
Oculus Rift DK2 + Leap Motion TutorialOculus Rift DK2 + Leap Motion Tutorial
Oculus Rift DK2 + Leap Motion Tutorial
Ā 
XNA L04ā€“Primitives, IndexBuffer and VertexBuffer
XNA L04ā€“Primitives, IndexBuffer and VertexBufferXNA L04ā€“Primitives, IndexBuffer and VertexBuffer
XNA L04ā€“Primitives, IndexBuffer and VertexBuffer
Ā 
Object Size Detector - Computer Vision
Object Size Detector - Computer VisionObject Size Detector - Computer Vision
Object Size Detector - Computer Vision
Ā 
4. THREE DIMENSIONAL DISPLAY METHODS
4.	THREE DIMENSIONAL DISPLAY METHODS4.	THREE DIMENSIONAL DISPLAY METHODS
4. THREE DIMENSIONAL DISPLAY METHODS
Ā 
I os developers_meetup_4_sessionon_locationservices
I os developers_meetup_4_sessionon_locationservicesI os developers_meetup_4_sessionon_locationservices
I os developers_meetup_4_sessionon_locationservices
Ā 
426 Lecture5: AR Registration
426 Lecture5: AR Registration426 Lecture5: AR Registration
426 Lecture5: AR Registration
Ā 
Developing a Multiplayer RTS with the Unreal Engine 3
Developing a Multiplayer RTS with the Unreal Engine 3Developing a Multiplayer RTS with the Unreal Engine 3
Developing a Multiplayer RTS with the Unreal Engine 3
Ā 
affine transformation for computer graphics
affine transformation for computer graphicsaffine transformation for computer graphics
affine transformation for computer graphics
Ā 

More from Frank Krueger

Open Source CLRs - Seattle Mobile .NET
Open Source CLRs - Seattle Mobile .NETOpen Source CLRs - Seattle Mobile .NET
Open Source CLRs - Seattle Mobile .NETFrank Krueger
Ā 
Asynchronous Application Patterns in C# - MonkeySpace
Asynchronous Application Patterns in C# - MonkeySpaceAsynchronous Application Patterns in C# - MonkeySpace
Asynchronous Application Patterns in C# - MonkeySpaceFrank Krueger
Ā 
3 Mobile App Dev Problems - Monospace
3 Mobile App Dev Problems - Monospace3 Mobile App Dev Problems - Monospace
3 Mobile App Dev Problems - MonospaceFrank Krueger
Ā 
Algorithms - Future Decoded 2016
Algorithms - Future Decoded 2016Algorithms - Future Decoded 2016
Algorithms - Future Decoded 2016Frank Krueger
Ā 
How I Made Zoom In and Enhance - Seattle Mobile .NET
How I Made Zoom In and Enhance - Seattle Mobile .NETHow I Made Zoom In and Enhance - Seattle Mobile .NET
How I Made Zoom In and Enhance - Seattle Mobile .NETFrank Krueger
Ā 
Overview of iOS 11 - Seattle Mobile .NET
Overview of iOS 11 - Seattle Mobile .NETOverview of iOS 11 - Seattle Mobile .NET
Overview of iOS 11 - Seattle Mobile .NETFrank Krueger
Ā 
Functional GUIs with F#
Functional GUIs with F#Functional GUIs with F#
Functional GUIs with F#Frank Krueger
Ā 
Mocast Postmortem
Mocast PostmortemMocast Postmortem
Mocast PostmortemFrank Krueger
Ā 
Programming iOS in C#
Programming iOS in C#Programming iOS in C#
Programming iOS in C#Frank Krueger
Ā 

More from Frank Krueger (9)

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

Recently uploaded

SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
Ā 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
Ā 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
Ā 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
Ā 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
Ā 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
Ā 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
Ā 
Call UsšŸ”>ą¼’+91-9711147426ā‡›Call In girls karol bagh (Delhi)
Call UsšŸ”>ą¼’+91-9711147426ā‡›Call In girls karol bagh (Delhi)Call UsšŸ”>ą¼’+91-9711147426ā‡›Call In girls karol bagh (Delhi)
Call UsšŸ”>ą¼’+91-9711147426ā‡›Call In girls karol bagh (Delhi)jennyeacort
Ā 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
Ā 
Maximizing Efficiency and Profitability with OnePlanā€™s Professional Service A...
Maximizing Efficiency and Profitability with OnePlanā€™s Professional Service A...Maximizing Efficiency and Profitability with OnePlanā€™s Professional Service A...
Maximizing Efficiency and Profitability with OnePlanā€™s Professional Service A...OnePlan Solutions
Ā 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
Ā 
Russian Call Girls in Karol Bagh Aasnvi āž”ļø 8264348440 šŸ’‹šŸ“ž Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi āž”ļø 8264348440 šŸ’‹šŸ“ž Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi āž”ļø 8264348440 šŸ’‹šŸ“ž Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi āž”ļø 8264348440 šŸ’‹šŸ“ž Independent Escort S...soniya singh
Ā 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
Ā 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
Ā 
Dealing with Cultural Dispersion ā€” Stefano Lambiase ā€” ICSE-SEIS 2024
Dealing with Cultural Dispersion ā€” Stefano Lambiase ā€” ICSE-SEIS 2024Dealing with Cultural Dispersion ā€” Stefano Lambiase ā€” ICSE-SEIS 2024
Dealing with Cultural Dispersion ā€” Stefano Lambiase ā€” ICSE-SEIS 2024StefanoLambiase
Ā 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
Ā 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
Ā 
GOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdfGOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdfAlina Yurenko
Ā 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
Ā 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
Ā 

Recently uploaded (20)

SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
Ā 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
Ā 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
Ā 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
Ā 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Ā 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Ā 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
Ā 
Call UsšŸ”>ą¼’+91-9711147426ā‡›Call In girls karol bagh (Delhi)
Call UsšŸ”>ą¼’+91-9711147426ā‡›Call In girls karol bagh (Delhi)Call UsšŸ”>ą¼’+91-9711147426ā‡›Call In girls karol bagh (Delhi)
Call UsšŸ”>ą¼’+91-9711147426ā‡›Call In girls karol bagh (Delhi)
Ā 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
Ā 
Maximizing Efficiency and Profitability with OnePlanā€™s Professional Service A...
Maximizing Efficiency and Profitability with OnePlanā€™s Professional Service A...Maximizing Efficiency and Profitability with OnePlanā€™s Professional Service A...
Maximizing Efficiency and Profitability with OnePlanā€™s Professional Service A...
Ā 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Ā 
Russian Call Girls in Karol Bagh Aasnvi āž”ļø 8264348440 šŸ’‹šŸ“ž Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi āž”ļø 8264348440 šŸ’‹šŸ“ž Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi āž”ļø 8264348440 šŸ’‹šŸ“ž Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi āž”ļø 8264348440 šŸ’‹šŸ“ž Independent Escort S...
Ā 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
Ā 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
Ā 
Dealing with Cultural Dispersion ā€” Stefano Lambiase ā€” ICSE-SEIS 2024
Dealing with Cultural Dispersion ā€” Stefano Lambiase ā€” ICSE-SEIS 2024Dealing with Cultural Dispersion ā€” Stefano Lambiase ā€” ICSE-SEIS 2024
Dealing with Cultural Dispersion ā€” Stefano Lambiase ā€” ICSE-SEIS 2024
Ā 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
Ā 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
Ā 
GOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdfGOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM ā€“ DEVOXX GREECE.pdf
Ā 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Ā 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
Ā 

Programming Augmented Reality - Xamarin Evolve

  • 1. Programming Augmented Reality: Make your own sci-ļ¬ 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
  • 3.
  • 4.
  • 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 ļ¬ltering 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-ļ¬ ā–  ā€œ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 difļ¬cult ā€¢ 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-ļ¬xed ā€¢ 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