SlideShare ist ein Scribd-Unternehmen logo
1 von 40
Downloaden Sie, um offline zu lesen
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
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

Weitere ähnliche Inhalte

Was ist angesagt?

Hidden surfaces
Hidden surfacesHidden surfaces
Hidden surfaces
Mohd Arif
 
Close range Photogrammeetry
Close range PhotogrammeetryClose range Photogrammeetry
Close range Photogrammeetry
chinmay khadke
 

Was ist angesagt? (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
 

Ähnlich wie Programming Augmented Reality - Xamarin Evolve

XNA L04–Primitives, IndexBuffer and VertexBuffer
XNA L04–Primitives, IndexBuffer and VertexBufferXNA L04–Primitives, IndexBuffer and VertexBuffer
XNA L04–Primitives, IndexBuffer and VertexBuffer
Mohammad Shaker
 

Ähnlich wie 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
 

Mehr von Frank Krueger

Mehr von 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#
 

Kürzlich hochgeladen

AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Kürzlich hochgeladen (20)

Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 

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
  • 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 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