Pose Tracking II! Gordon Wetzstein! Stanford University! EE 267 Virtual Reality! Lecture 12! stanford.edu/class/ee267/!

Similar documents
Theory of Bouguet s MatLab Camera Calibration Toolbox

Visual SLAM Tutorial: Bundle Adjustment

Robot Mapping. Least Squares. Cyrill Stachniss

Camera calibration by Zhang

Pose estimation from point and line correspondences

Linear and Nonlinear Optimization

Autonomous Mobile Robot Design

Advanced Techniques for Mobile Robotics Least Squares. Wolfram Burgard, Cyrill Stachniss, Kai Arras, Maren Bennewitz

Sparse Levenberg-Marquardt algorithm.

Augmented Reality VU Camera Registration. Prof. Vincent Lepetit

Augmented Reality VU numerical optimization algorithms. Prof. Vincent Lepetit

EE 267 Virtual Reality Course Notes: 6-DOF Pose Tracking with the VRduino

Maximum Likelihood Estimation

Homographies and Estimating Extrinsics

Tracking for VR and AR

Method 1: Geometric Error Optimization

Numerical computation II. Reprojection error Bundle adjustment Family of Newtonʼs methods Statistical background Maximum likelihood estimation

13. Nonlinear least squares

Robot Dynamics Instantaneous Kinematiccs and Jacobians

Numerical Methods for Inverse Kinematics

EE 367 / CS 448I Computational Imaging and Display Notes: Image Deconvolution (lecture 6)

Optimization 2. CS5240 Theoretical Foundations in Multimedia. Leow Wee Kheng

Camera Calibration The purpose of camera calibration is to determine the intrinsic camera parameters (c 0,r 0 ), f, s x, s y, skew parameter (s =

Content.

Least-Squares Fitting of Model Parameters to Experimental Data

Numerical solution of Least Squares Problems 1/32

Applied Mathematics 205. Unit I: Data Fitting. Lecturer: Dr. David Knezevic

Introduction to gradient descent

2 Nonlinear least squares algorithms

1 Kalman Filter Introduction

Mobile Robotics 1. A Compact Course on Linear Algebra. Giorgio Grisetti

Optimization: Nonlinear Optimization without Constraints. Nonlinear Optimization without Constraints 1 / 23

Noise, Image Reconstruction with Noise!

Kalman filtering and friends: Inference in time series models. Herke van Hoof slides mostly by Michael Rubinstein

Non-polynomial Least-squares fitting

2D Image Processing (Extended) Kalman and particle filter

Numerical Optimization

Determining absolute orientation of a phone by imaging celestial bodies

Minimal representations of orientation

Mysteries of Parameterizing Camera Motion - Part 2

Autonomous Navigation for Flying Robots

SECTION 5: POWER FLOW. ESE 470 Energy Distribution Systems

Chapter 3 Numerical Methods

Neural Network Training

Introduction to Optimization

The Jacobian. Jesse van den Kieboom


Linear Dynamical Systems

Lecture Notes: Geometric Considerations in Unconstrained Optimization

Lecture Schedule Week Date Lecture (M: 2:05p-3:50, 50-N202)

Partially Observable Markov Decision Processes (POMDPs)

Mobile Robot Localization

2 Regularized Image Reconstruction for Compressive Imaging and Beyond

(W: 12:05-1:50, 50-N202)

Lecture Note 8: Inverse Kinematics

CS 188: Artificial Intelligence Spring 2009

3D from Photographs: Camera Calibration. Dr Francesco Banterle

Motion Estimation (I)

Probabilistic Graphical Models

Robotics I Kinematics, Dynamics and Control of Robotic Manipulators. Velocity Kinematics

Introduction to Mobile Robotics Compact Course on Linear Algebra. Wolfram Burgard, Bastian Steder

Introduction to Mobile Robotics Compact Course on Linear Algebra. Wolfram Burgard, Cyrill Stachniss, Kai Arras, Maren Bennewitz

L03. PROBABILITY REVIEW II COVARIANCE PROJECTION. NA568 Mobile Robotics: Methods & Algorithms

Numerical Methods I Solving Nonlinear Equations

Motion Estimation (I) Ce Liu Microsoft Research New England

Variations on Backpropagation

Introduction to Mobile Robotics Compact Course on Linear Algebra. Wolfram Burgard, Cyrill Stachniss, Maren Bennewitz, Diego Tipaldi, Luciano Spinello

Differential Kinematics

1 Computing with constraints

Trajectory-based optimization

Math 273a: Optimization Netwon s methods

CS 5522: Artificial Intelligence II

Lecture Note 8: Inverse Kinematics

COMP 558 lecture 18 Nov. 15, 2010

Miscellaneous. Regarding reading materials. Again, ask questions (if you have) and ask them earlier

System identification and sensor fusion in dynamical systems. Thomas Schön Division of Systems and Control, Uppsala University, Sweden.

IMU-Camera Calibration: Observability Analysis

Lie Groups for 2D and 3D Transformations

Linear Regression. CSL603 - Fall 2017 Narayanan C Krishnan

Linear Regression. CSL465/603 - Fall 2016 Narayanan C Krishnan

CS 5522: Artificial Intelligence II

Multiview Geometry and Bundle Adjustment. CSE P576 David M. Rosen

Markov Models. CS 188: Artificial Intelligence Fall Example. Mini-Forward Algorithm. Stationary Distributions.

Announcements. CS 188: Artificial Intelligence Fall Markov Models. Example: Markov Chain. Mini-Forward Algorithm. Example

University of Houston, Department of Mathematics Numerical Analysis, Fall 2005

Robotics & Automation. Lecture 25. Dynamics of Constrained Systems, Dynamic Control. John T. Wen. April 26, 2007

Lecture 7 Unconstrained nonlinear programming

Lecture 4: Extended Kalman filter and Statistically Linearized Filter

EE Camera & Image Formation

1 Overview. 2 A Characterization of Convex Functions. 2.1 First-order Taylor approximation. AM 221: Advanced Optimization Spring 2016

Optimisation on Manifolds

LEARNING DYNAMIC SYSTEMS: MARKOV MODELS

CONTROL OF ROBOT CAMERA SYSTEM WITH ACTUATOR S DYNAMICS TO TRACK MOVING OBJECT

TRACKING and DETECTION in COMPUTER VISION

Systems of Linear ODEs

Announcements. CS 188: Artificial Intelligence Fall VPI Example. VPI Properties. Reasoning over Time. Markov Models. Lecture 19: HMMs 11/4/2008

Constrained optimization. Unconstrained optimization. One-dimensional. Multi-dimensional. Newton with equality constraints. Active-set method.

EKF, UKF. Pieter Abbeel UC Berkeley EECS. Many slides adapted from Thrun, Burgard and Fox, Probabilistic Robotics

EKF, UKF. Pieter Abbeel UC Berkeley EECS. Many slides adapted from Thrun, Burgard and Fox, Probabilistic Robotics

ME751 Advanced Computational Multibody Dynamics

Transcription:

Pose Tracking II! Gordon Wetzstein! Stanford University! EE 267 Virtual Reality! Lecture 12! stanford.edu/class/ee267/!!

WARNING! this class will be dense! will learn how to use nonlinear optimization (Levenberg- Marquardt algorithm) for pose estimation! why???!! more accurate than homography method! can dial in lens distortion estimation, and estimation of intrinsic parameters (beyond this lecture, see lecture notes)! LM is very common in 3D computer vision à camera-based tracking!

Pose Estimation - Overview! x i y i 0 goal: estimate pose via nonlinear least squares optimization! minimize p { } 2 b f ( g( p) ) 2 image formation minimize reprojection error! pose p is 6-element vector with 3 Euler angles and translation of VRduino w.r.t. base station! x i n y i n b = x 1 n y 1 n! x 4 n y 4 n p = θ x θ y θ z t x t y t z

Overview! review: gradients, Jacobian matrix, chain rule, iterative optimization! nonlinear optimization: Gauss-Newton, Levenberg-Marquardt! pose estimation using LM! pose estimation with VRduino using nonlinear optimization!

Review!

Review: Gradients! gradient of a function that depends on multiple variables:! x f x ( ) = f, f,, f x 1 x 2 x n f :R n R

Review: The Jacobian Matrix! gradient of a vector-valued function that depends on multiple variables:! x f x ( ) = J f = f 1! f 1 x 1 x n " # " f m! f m x 1 x n f :R n R m, J f R m n

Review: The Chain Rule! here s how you ve probably been using it so far:! x f g x ( ( )) = f g g x this rule applies when! f :R R g :R R

Review: The Chain Rule! here s how it is applied in general:! x f g x ( ( ) ) = J f J g = f 1! f 1 g 1 g o " # " f m! f m g 1 g o g 1! g 1 x 1 x n " # " g o! g o x 1 x n f :R o R m, g :R n R o, J f R m o, J g R o n

Review: Minimizing a Function! goal: find point x * that minimizes a nonlinear function f(x)! f ( x) x * x

Review: What is a Gradient?! gradient of f at some point x 0 is the slope at that point! f ( x) x 0 x

Review: What is a Gradient?! gradient of f at some point x 0 is the slope at that point! f ( x) x 0 x

Review: What is a Gradient?! extremum is where gradient is 0! (sometimes have to check 2 nd derivative to see if it s a minimum and not a maximum or saddle point)! f ( x) x * x

Review: Optimization! extremum is where gradient is 0! (sometimes have to check 2 nd derivative to see if it s a minimum and not a maximum or saddle point)! convex! non-convex! f ( x) f ( x) x x! convex optimization: there is only a single global minimum! non-convex optimization: multiple local minima!

Review: Optimization! how to find where gradient is 0?! f ( x)! x

Review: Optimization! how to find where gradient is 0?! f ( x) x 0 x 1. start with some initial guess x 0, e.g. a random value!

Review: Optimization! how to find where gradient is 0?! f ( x) x 0 x 1. start with some initial guess x 0, e.g. a random value! 2. update guess by linearizing function and minimizing that!

Review: Optimization! how to linearize a function? à using Taylor expansion!! f ( x) f ( x 0 + Δx) f ( x 0 ) + J f Δx + ε x 0 x

Review: Optimization! find minimum of linear function approximation! f ( x) f ( x 0 + Δx) f ( x 0 ) + J f Δx + ε x 0 x minimize Δx 2 b f ( x 0 + Δx) 2 2 b ( f ( x 0 ) + J f Δx) 2

Review: Optimization! find minimum of linear function approximation (gradient=0)! f ( x) f ( x 0 + Δx) f ( x 0 ) + J f Δx + ε x 0 equate gradient to zero:! 0 = J f T J f Δx J f T b f x x minimize Δx ( ( )) Δx = J T f J f 2 b f ( x 0 + Δx) 2 2 b ( f ( x 0 ) + J f Δx) 2 ( ) 1 J f T b f x normal equations! ( ( ))

Review: Optimization! take step and repeat procedure! f ( x) x 0 x 0 + Δx x ( ) 1 J f T b f x Δx = J f T J f ( ( ))

Review: Optimization! take step and repeat procedure, will get there eventually! f ( x) x 0 x 0 + Δx x ( ) 1 J f T b f x Δx = J f T J f ( ( ))

Review: Optimization Gauss-Newton! results in an iterative algorithm! f ( x) x k+1 = x k + Δx x 0 x ( ) 1 J f T b f x Δx = J f T J f ( ( ))

Review: Optimization Gauss-Newton! results in an iterative algorithm! x 0 f ( x) x 1. x = rand() // initialize x0 2. for k=1 to max_iter 3. f = eval_objective(x) 4. J = eval_jacobian(x) 5. x = x + inv(j *J)*J *(b-f) // update x ( ) 1 J f T b f x Δx = J f T J f ( ( ))

Review: Optimization Gauss-Newton! matrix J T J can be ill-conditioned (i.e. not invertible)! f ( x) x 0 x ( ) 1 J f T b f x Δx = J f T J f ( ( ))

Review: Optimization Levenberg! matrix J T J can be ill-conditioned (i.e. not invertible)! add a diagonal matrix to make invertible acts as damping! f ( x) x 0 x ( ) 1 J f T b f x Δx = J f T J f + λi ( ( ))

Review: Optimization Levenberg-Marquardt!! matrix J T J can be ill-conditioned (i.e. not invertible)! better: use J T J instead of I as damping. This is LM!! f ( x) x 0 x ( ) 1 J f T b f x Δx = J T f J f + λ diag( J T f J f ) ( ( ))

Review: Optimization Levenberg-Marquardt!! matrix J T J can be ill-conditioned (i.e. not invertible)! better: use J T J instead of I as damping. This is LM!! x 0 f ( x) x 1. x = rand() // initialize x0 2. for k=1 to max_iter 3. f = eval_objective(x) 4. J = eval_jacobian(x) 5. x = x+inv(j *J+lambda*diag(J *J))*J *(b-f) ( ) 1 J f T b f x Δx = J T f J f + λ diag( J T f J f ) ( ( ))

Pose Estimation via Levenberg-Marquardt!

Pose Estimation - Overview! x i y i 0 goal: estimate pose via nonlinear least squares optimization! minimize p { } 2 b f ( g( p) ) 2 image formation minimize reprojection error! pose p is 6-element vector with 3 Euler angles and translation of VRduino w.r.t. base station! x i n y i n b = x 1 n y 1 n! x 4 n y 4 n p = θ x θ y θ z t x t y t z

Pose Estimation - Objective Function! goal: estimate pose via nonlinear least squares optimization! minimize p { } 2 b f ( g( p) ) 2 x i y i 0 image formation objective function is sum of squares of reprojection error! x i n y i n 2 ( ) = n x1 f 2 1 ( g( p) ) b f g( p) ( ) 2 + ( y n 1 f 2 ( g( p) )) 2 + + ( x n 4 f 7 ( g( p) )) 2 + ( y n 4 f 8 ( g( p) )) 2

Image Formation! 1. transform 3D point into view space:! x i c y i c z i c = = 1 0 0 0 1 0 0 0 1 h 1 h 2 h 3 h 4 h 5 h 6 h 7 h 8 h 9 r 11 r 12 t x r 21 r 22 t y r 31 r 32 t z x i y i 1 x i y i 1 x i n y i n x i y i 0 2. perspective divide:! x i n y i n = x i c z i c y i c z i c

Image Formation: g(p) and f(h)! split up image formation into two functions! ( ) = f g( p) f h ( ) g :R 6 R 9, f :R 9 R 8

Image Formation: f(h)! f(h) uses elements of homography matrix h to compute projected 2D coordinates as! f ( h) = f 1 f 2 f 7 f 8 ( h) ( h)! h ( ) ( h) = n x 1 n y 1! n x 4 n y 4 = h 1 x 1 + h 2 y 1 + h 3 h 7 x 1 + h 8 y 1 + h 9 h 4 x 1 + h 5 y 1 + h 6 h 7 x 1 + h 8 y 1 + h 9! h 1 x 4 + h 2 y 4 + h 3 h 7 x 4 + h 8 y 4 + h 9 h 4 x 4 + h 5 y 4 + h 6 h 7 x 4 + h 8 y 4 + h 9

! f 1 Jacobian Matrix of f(h)! ( h) = h x +h y +h 1 1 2 1 3 h 7 x 1 +h 8 y 1 +h 9 J f = f 1! f 1 h 1 h 9 " # " f 8! f 8 h 1 h 9 first row of Jacobian matrix! f 1 h 1 = f 1 h 2 = f 1 h 3 = f 1 h 4 = 0, x 1 h 7 x 1 + h 8 y 1 + h 9 y 1 h 7 x 1 + h 8 y 1 + h 9 1 h 7 x 1 + h 8 y 1 + h 9 f 1 h 5 = 0, f 1 h 6 = 0 f 1 = h 7 f 1 = h 8 h 1 x 1 + h 2 y 1 + h 3 ( ) 2 h 7 x 1 + h 8 y 1 + h 9 h 1 x 1 + h 2 y 1 + h 3 ( ) 2 h 7 x 1 + h 8 y 1 + h 9 f 1 = h x + h y + h 1 1 2 1 3 h 9 h 7 x 1 + h 8 y 1 + h 9 ( ) 2 x 1 y 1

! Jacobian Matrix of f(h)! the remaining rows of the Jacobian can be derived with a similar pattern! J f = f 1! f 1 h 1 h 9 " # " f 8! f 8 h 1 h 9 see course notes for a detailed deriavtion of the elements of this Jacobian matrix!

Image Formation: g(p)! g(p) uses 6 pose parameters to compute elements of homography matrix h as! g( p) = g 1 g 9 ( p)! p ( ) = h 1! h 9 definition of homography matrix:! h 1 h 2 h 3 h 4 h 5 h 6 h 7 h 8 h 9 = 1 0 0 0 1 0 0 0 1 r 11 r 12 t x r 21 r 22 t y r 31 r 32 t z rotation matrix from Euler angles:! ( ) sin( θ z ) 0 ( ) R = R z ( θ z ) R x ( θ x ) R y θ y r 11 r 12 r 13 cos θ z 1 0 0 r 21 r 22 r 23 = sin( θ z ) cos( θ z ) 0 0 cos θ x r 31 r 32 r 33 0 0 1 0 sin θ x ( ) sin( θ x ) ( ) cos( θ x ) cos( θ y ) 0 sin( θ y ) 0 1 0 sin θ y ( ) 0 cos( θ y )

write as! Image Formation: g(p)! h 1 = g 1 ( p) = cos( θ y )cos θ z h 2 = g 2 ( p) = cos( θ x )sin θ z h 3 = g 3 ( p) = t x h 4 = g 4 ( p) = cos( θ y )sin θ z h 5 = g 5 ( p) = cos( θ x )cos θ z h 6 = g 6 ( p) = t y h 7 = g 7 ( p) = cos( θ x )sin( θ y ) h 8 = g 8 ( p) = sin( θ x ) h 9 = g 9 ( p) = t z ( ) sin θ x ( ) ( ) + sin θ x ( ) ( )sin( θ y )sin θ z ( ) ( )sin( θ y )cos θ z ( )

! Jacobian Matrix of g(p)! ( ) p = ( p 1, p 2, p 3, p 4, p 5, p 6 ) = θ x, θ y, θ z, t x, t y, t z h 1 = g 1 ( p) = cos( θ y )cos θ z h 2 = g 2 ( p) = cos( θ x )sin θ z ( ) sin θ x ( ) ( )sin( θ y )sin θ z ( ) J g = g 1! g 1 p 1 p 6 " # " g 9! g 9 p 1 p 6 h 3 = g 3 ( p) = t x h 4 = g 4 ( p) = cos( θ y )sin θ z h 5 = g 5 ( p) = cos( θ x )cos θ z ( ) + sin θ x ( ) ( )sin( θ y )cos θ z ( ) h 6 = g 6 ( p) = t y h 7 = g 7 ( p) = cos( θ x )sin θ y h 8 = g 8 ( p) = sin( θ x ) ( ) h 9 = g 9 ( p) = t z

! h 1 = g 1 ( p) = cos( θ y )cos θ z Jacobian Matrix of g(p)! p = ( p 1, p 2, p 3, p 4, p 5, p 6 ) = θ x, θ y, θ z, t x, t y, t z ( ) J g = ( ) sin θ x ( )sin( θ y )sin θ z ( ) g 1! g 1 p 1 p 6 " # " g 9! g 9 p 1 p 6 first row of Jacobian matrix! g 1 = cos( θ x )sin( θ y )sin( θ z ) p 1 g 1 = sin( θ y )cos( θ z ) sin( θ x )cos( θ y )sin( θ z ) p 2 g 1 = cos( θ y )sin( θ z ) sin( θ x )sin( θ y )cos( θ z ) p 3 g 1 p 4 = 0, g 1 p 5 = 0, g 1 p 6 = 0

! Jacobian Matrix of g(p)! the remaining rows of the Jacobian can be derived with a similar pattern! J g = g 1! g 1 p 1 p 6 " # " g 9! g 9 p 1 p 6 see course notes for a detailed deriavtion of the elements of this Jacobian matrix!

! Jacobian Matrices of f and g! to get the Jacobian of f(g(p)), compute the two Jacobian matrices and multiply them! J = J f J g = f 1! f 1 h 1 h 9 " # " f 8! f 8 h 1 h 9 g 1! g 1 p 1 p 6 " # " g 9! g 9 p 1 p 6

Pose Tracking with LM! LM then iteratively updates pose as! ( ( )) 1 J T b f p k p ( k+1) = p ( k) + J T J + λ diag J T J ( ( ( ) )) pseudo-code! 1. p =... // initialize p0 2. for k=1 to max_iter 3. f = eval_objective(p) 4. J = get_jacobian(p) 5. p = p + inv(j *J+lambda*diag(J *J))*J *(b-f)

Pose Tracking with LM! 1. value = function eval_objective(p) 2. for i=1:4 3. value(2*(i-1)) =... 4. value(2*(i-1)+1) =... h 1 x i + h 2 y i + h 3 h 7 x i + h 8 y i + h 9 h 4 x i + h 5 y i + h 6 h 7 x i + h 8 y i + h 9

Pose Tracking with LM! 1. J = function get_jacobian(p) 2. Jf = get_jacobian_f(p) 3. Jg = get_jacobian_g(p) 4. J = Jf*Jg J f = J g = f 1! f 1 h 1 h 9 " # " f 8! f 8 h 1 h 9 g 1! g 1 p 1 p 6 " # " g 9! g 9 p 1 p 6

!! Pose Tracking with LM on VRduino! some more hints for implementation:! let Arduino Matrix library compute matrix-matrix multiplications and also matrix inverses for you!! run homography method and use that to initialize p for LM! use something like 5-25 interations of LM per frame for real-time performance! user-defined parameter! λ good luck!

Pose Tracking with LM on VRduino! live demo!

Outlook: Camera Calibration! http://www.vision.caltech.edu/bouguetj/calib_doc/! camera calibration is one of the most fundamental problems in computer vision and imaging! task: estimate intrinsic (lens distortion, focal length, principle point) & extrinsic (translation, rotation) camera parameters given images of planar checkerboards! uses similar procedure as discussed today!

Outlook: Sensor Fusion with Extended Kalman Filter!! also desirable: estimate bias of each of all IMU sensors! also desirable: joint pose estimation from all IMU + photodiode measurements! can do all of that with an Extended Kalman Filter - slightly too advanced for this class, but you can find a lot of literature in the robotic vision community!

Outlook: Sensor Fusion with Extended Kalman Filter! Extended Kalman filter: can be interpreted as a Bayesian framework for sensor fusion! Hidden Markov Model (HMM)! known initial state! x x 0 1 x t 1 x unknown, evolving t states! z 1 z t 1 z t measurements!

Must read: course notes on tracking!!