Computer Vision cmput 428/615

Similar documents
Computer Vision Projective Geometry and Calibration. Pinhole cameras

Computer Vision Projective Geometry and Calibration. Pinhole cameras

Remember: The equation of projection. Imaging Geometry 1. Basic Geometric Coordinate Transforms. C306 Martin Jagersand

Camera Model and Calibration

Computer Vision Projective Geometry and Calibration

Camera Projection Models We will introduce different camera projection models that relate the location of an image point to the coordinates of the

Camera Model and Calibration. Lecture-12

calibrated coordinates Linear transformation pixel coordinates

Computer Vision. Coordinates. Prof. Flávio Cardeal DECOM / CEFET- MG.

Homogeneous Coordinates. Lecture18: Camera Models. Representation of Line and Point in 2D. Cross Product. Overall scaling is NOT important.

3D Sensing and Reconstruction Readings: Ch 12: , Ch 13: ,

Epipolar Geometry Prof. D. Stricker. With slides from A. Zisserman, S. Lazebnik, Seitz

Visual Recognition: Image Formation

Interactive Computer Graphics. Hearn & Baker, chapter D transforms Hearn & Baker, chapter 5. Aliasing and Anti-Aliasing

COMP30019 Graphics and Interaction Three-dimensional transformation geometry and perspective

Camera Calibration. Schedule. Jesus J Caban. Note: You have until next Monday to let me know. ! Today:! Camera calibration

CSE 252B: Computer Vision II

N-Views (1) Homographies and Projection

Structure from motion

Augmented Reality II - Camera Calibration - Gudrun Klinker May 11, 2004

CS 664 Slides #9 Multi-Camera Geometry. Prof. Dan Huttenlocher Fall 2003

Image Formation. Antonino Furnari. Image Processing Lab Dipartimento di Matematica e Informatica Università degli Studi di Catania

CHAPTER 3. Single-view Geometry. 1. Consequences of Projection

Machine vision. Summary # 11: Stereo vision and epipolar geometry. u l = λx. v l = λy

Structure from Motion. Prof. Marco Marcon

1 Projective Geometry

Graphics and Interaction Transformation geometry and homogeneous coordinates

Prof. Feng Liu. Fall /19/2016

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

Multiple Views Geometry

Computer Vision I - Algorithms and Applications: Multi-View 3D reconstruction

Camera models and calibration

2D Image Transforms Computer Vision (Kris Kitani) Carnegie Mellon University

Rectification and Disparity

Image formation. Thanks to Peter Corke and Chuck Dyer for the use of some slides

Discriminant Functions for the Normal Density

CS201 Computer Vision Camera Geometry

Chapter 2 - Basic Mathematics for 3D Computer Graphics

Introduction to Computer Vision

Structure from motion

3D Sensing. 3D Shape from X. Perspective Geometry. Camera Model. Camera Calibration. General Stereo Triangulation.

Lecture 9: Epipolar Geometry

MAN-522: COMPUTER VISION SET-2 Projections and Camera Calibration

Specifying Complex Scenes

COSC579: Scene Geometry. Jeremy Bolton, PhD Assistant Teaching Professor

2D/3D Geometric Transformations and Scene Graphs

Camera Calibration. COS 429 Princeton University

Unit 3 Multiple View Geometry

Cameras and Radiometry. Last lecture in a nutshell. Conversion Euclidean -> Homogenous -> Euclidean. Affine Camera Model. Simplified Camera Models

Introduction to Homogeneous coordinates

Projective Geometry and Camera Models

MAPI Computer Vision. Multiple View Geometry

DD2423 Image Analysis and Computer Vision IMAGE FORMATION. Computational Vision and Active Perception School of Computer Science and Communication

Stereo Vision. MAN-522 Computer Vision

CS6670: Computer Vision

Agenda. Perspective projection. Rotations. Camera models

Computer Graphics with OpenGL ES (J. Han) Chapter IV Spaces and Transforms

UNIT 2 2D TRANSFORMATIONS

BIL Computer Vision Apr 16, 2014

3D Modeling using multiple images Exam January 2008

Today. Stereo (two view) reconstruction. Multiview geometry. Today. Multiview geometry. Computational Photography

3D Mathematics. Co-ordinate systems, 3D primitives and affine transformations

Fundamentals of Stereo Vision Michael Bleyer LVA Stereo Vision

521466S Machine Vision Exercise #1 Camera models

EXAM SOLUTIONS. Image Processing and Computer Vision Course 2D1421 Monday, 13 th of March 2006,

Image warping , , Computational Photography Fall 2017, Lecture 10

Projective geometry, camera models and calibration

3D Geometry and Camera Calibration

Structure from Motion. Introduction to Computer Vision CSE 152 Lecture 10

CS4670: Computer Vision

CS231A Midterm Review. Friday 5/6/2016

COS429: COMPUTER VISON CAMERAS AND PROJECTIONS (2 lectures)

Agenda. Rotations. Camera models. Camera calibration. Homographies

CSE152a Computer Vision Assignment 1 WI14 Instructor: Prof. David Kriegman. Revision 0

Multiple View Geometry

Camera Geometry II. COS 429 Princeton University

Epipolar Geometry and the Essential Matrix

CS 4204 Computer Graphics

Single View Geometry. Camera model & Orientation + Position estimation. What am I?

521493S Computer Graphics Exercise 2 Solution (Chapters 4-5)

More Mosaic Madness. CS194: Image Manipulation & Computational Photography. Steve Seitz and Rick Szeliski. Jeffrey Martin (jeffrey-martin.

Pinhole Camera Model 10/05/17. Computational Photography Derek Hoiem, University of Illinois

2D and 3D Transformations AUI Course Denbigh Starkey

Assignment 2 : Projection and Homography

Geometric camera models and calibration

Stereo CSE 576. Ali Farhadi. Several slides from Larry Zitnick and Steve Seitz

Camera Models and Image Formation. Srikumar Ramalingam School of Computing University of Utah

3D reconstruction class 11

CIS 580, Machine Perception, Spring 2016 Homework 2 Due: :59AM

Camera Models and Image Formation. Srikumar Ramalingam School of Computing University of Utah

Agenda. Rotations. Camera calibration. Homography. Ransac

CSC 305 The Graphics Pipeline-1

CSE328 Fundamentals of Computer Graphics

Camera Pose Measurement from 2D-3D Correspondences of Three Z Shaped Lines

All human beings desire to know. [...] sight, more than any other senses, gives us knowledge of things and clarifies many differences among them.

55:148 Digital Image Processing Chapter 11 3D Vision, Geometry

Robotics - Projective Geometry and Camera model. Marcello Restelli

arxiv: v1 [cs.cv] 28 Sep 2018

CS6670: Computer Vision

Pin Hole Cameras & Warp Functions

Transcription:

Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand

The equation of projection Intuitively: How do we develop a consistent mathematical framework for projection calculations? Mathematically: Cartesian coordinates: (x, y, z) ( f x z, f y z ) Projectively: x = PX

Challenges in Computer Vision: What images don t provide lengths depth

Distant objects are smaller

Visual ambiguity Will the scissors cut the paper in the middle?

Ambiguity Will the scissors cut the paper in the middle? NO!

Visual ambiguity Is the probe contacting the wire?

Ambiguity Is the probe contacting the wire? NO!

Visual ambiguity Is the probe contacting the wire?

Ambiguity Is the probe contacting the wire? NO!

History of Perspective Prehistoric: Roman

Perspective: Da Vinci

Visualizing perspective: Dürer Perspectograph 1500 s

Parallel lines meet Image plane common to draw image plane in front of the focal point Centre of projection 3D world

Perspective Imaging Properties Challenges with measurements in multiple images: Distances/angles change Ratios of dist/angles change Parallel lines intersect 90

What is preserved? Invariants: Points map to points Intersections are preserved Lines map to lines Collinearity preserved Ratios of ratios (cross ratio) Horizon horizon What is a good way to represent imaged geometry?

Vanishing points each set of parallel lines (=direction) meets at a different point The vanishing point for this direction How would you show this? Sets of parallel lines on the same plane lead to collinear vanishing points. The line is called the horizon for that plane

Geometric properties of projection Points go to points Lines go to lines Planes go to whole image Polygons go to polygons Degenerate cases line through focal point to point plane through focal point to line

Polyhedra project to polygons (because lines project to lines)

Junctions are constrained This leads to a process called line labelling one looks for consistent sets of labels, bounding polyhedra disadv - can t get the lines and junctions to label from real images

Back to projection Cartesian coordinates: (x, y, z) ( f x z, f y z ) We will develop a framework to express projection as x=px, where x is 2D image projection, P a projection matrix and X is 3D world point.

Basic geometric transformations: Translation A translation is a straight line movement of an object from one postion to another. A point (x,y) is transformed to the point (x,y ) by adding the translation distances T x and T y : x = x + T x y = y + T y z = z + T z

Coordinate rotation Example: Around y-axis p = [ x ] y z = cos 0 sin 0 1 0 sin 0 cos [ x ] y z = R y p Z P X X

Euler angles Note: Successive rotations. Order matters. = [ cosϕ sinϕ ] 0 sinϕ cos ϕ 0 0 0 1 R=R z R y R x cos 0 sin 0 1 0 sin 0 cos 1 0 0 0 cosψ sinψ 0 sinψ cos ψ

Rotation and translation Translation t in new o coordinates Z P p = cos 0 sin 0 1 0 p + t sin 0 cos X X

Basic transformations Scaling A scaling transformation alters the scale of an object. Suppose a point (x,y) is transformed to the point (x',y') by a scaling with scaling factors S x and S y, then: x' = x S x y' = y S y z' = z S z A uniform scaling is produced if S x = S y = S z.

Basic transformations Scaling The previous scaling transformation leaves the origin unaltered. If the point (x f,y f ) is to be the fixed point, the transformation is: x' = x f + (x - x f ) S x y' = y f + (y - y f ) S y This can be rearranged to give: x' = x S x + (1 - S x ) x f y' = y S y + (1 - S y ) y f

Affine Geometric Transforms In general, a point in n-d space transforms by P = rotate(point) + translate(point) In 2-D space, this can be written as a matrix equation: x' y' = Cos( θ ) Sin( θ ) Sin( θ ) Cos( θ ) x y + tx ty In 3-D space (or n-d), this can generalized as a matrix equation: p = R p + T or p = R t (p T)

A Simple 2-D Example p = (0,1) p = (1,0) x' y' x' y' Cos( π / 4) = Sin( π / 4) Cos( π / 4) = Sin( π / 4) Sin( π / 4) 1 Cos( π / 4) 0 Suppose we rotate the coordinate system through 45 degrees (note that this is measured relative to the rotated system! x' y' x' y' Cos( π / 4) = Sin( π / 4) = Sin Cos ( π / 4) ( π / 4) Sin( π / 4) 0 Cos( π / 4) 1

Matrix representation and Homogeneous coordinates Often need to combine several transformations to build the total transformation. So far using affine transforms need both add and multiply Good if all transformations could be represented as matrix multiplications then the combination of transformations simply involves the multiplication of the respective matrices As translations do not have a 2 x 2 matrix representation, we introduce homogeneous coordinates to allow a 3 x 3 matrix representation.

How to translate a 2D point: Old way: New way:

Relationship between 3D homogeneous and inhomogeneous The Homogeneous coordinate corresponding to the point (x,y,z) is the triple (x h, y h, z h, w) where: x h = wx y h = wy z h = wz We can (initially) set w = 1. Suppose a point P = (x,y,z,1) in the homogeneous coordinate system is mapped to a point P' = (x',y',z,1) by a transformations, then the transformation can be expressed in matrix form.

Matrix representation and Homogeneous coordinates For the basic transformations we have: Translation Scaling P = P = x y z w x y z w = = 1 0 0 T x 0 1 0 T y 0 0 1 T z 0 0 0 1 s x 0 0 0 0 s y 0 0 0 0 s z 0 0 0 0 1 x y z w x y z w

Geometric Transforms Using the idea of homogeneous transforms, we can write: p' = 0 R 0 0 T R and T both require 3 parameters. 1 p R = [ cosϕ sinϕ ] 0 sinϕ cosϕ 0 0 0 1 cos 0 sin 0 1 0 sin 0 cos 1 0 0 0 cosψ sinψ 0 sinψ cosψ

Geometric Transforms If we compute the matrix inverse, we find that ' 1 0 0 0 ' ' p R T R p = R and T both require 3 parameters. These correspond to the 6 extrinsic parameters needed for camera calibration

Rotation about a Specified Axis It is useful to be able to rotate about any axis in 3D space This is achieved by composing 7 elementary transformations (next slide)

Rotation through θ about Specified Axis y P2 y y z y P1 x initial position z y x translate P1 to origin z x rotate so that P2 lies on z-axis (2 rotations) y P2 z x rotate through requ d angle, θ z x rotate axis z to orig orientation P1 x translate back

Comparison: Homogeneous coordinates Rotations and translations are represented in a uniform way Successive transforms are composed using matrix products: y = Pn*..*P2*P1*x Affine coordinates Non-uniform representations: y = Ax + b Difficult to keep track of separate elements

Camera models and projections Geometry part 2. x Using geometry and homogeneous transforms to describe: Perspective projection Weak perspective projection Orthographic projection y z y x

The equation of projection Cartesian coordinates: We have, by similar triangles, that (x, y, z) -> (f x/z, f y/z, -f) Ignore the third coordinate, and get (x, y, z) ( f x z, f y z )

The camera matrix Homogenous coordinates for 3D four coordinates for 3D point equivalence relation (X,Y,Z,T) is the same as (k X, k Y, k Z,k T) Turn previous expression into HC s HC s for 3D point are (X,Y,Z,T) HC s for point in image are (U,V,W) U V W = 1 0 0 0 0 1 0 0 0 0 1 f 0 X Y Z T ), ( ), ( ),, ( v u W V W U W V U =

Camera parameters Issue camera may not be at the origin, looking down the z-axis extrinsic parameters one unit in camera coordinates may not be the same as one unit in world coordinates intrinsic parameters - focal length, principal point, aspect ratio, angle between axes, etc. U V W = Transforma tion representi ng intrinsic parameters Transforma tion Transforma tion representi ng representi ng projection model extrinsic parameters Note: f moved from proj to intrinsics! X Y Z T

Intrinsic Parameters Intrinsic Parameters describe the conversion from metric to pixel coordinates (and the reverse) x mm = - (x pix o x ) s x y mm = - (y pix o y ) s y p M w y x o s f o s f w y x mm y y x x pix int 1 0 0 / 0 0 / = = or Note: Focal length is a property of the camera and can be incorporated as above

Example: A real camera Laser range finder Camera

Relative location Camera-Laser Camera Laser R=10deg T=(16,6,-9)

In homogeneous coordinates Rotation: Translation R = cos 10 0 sin 10 0 1 0 sin 10 0 cos 10 T = 1 0 0 16 0 1 0 6 0 0 1 9 0 0 0 1

Full projection model Camera internal parameters Camera projection p camera = ( 1278.6657 0 )( 256 1 0 0 ) 0 0 1659.5688 240 0 1 0 0 0 0 1 0 0 1 0 0.985 0 0.174 0 0 1 0 0 0.174 0 0.985 0 0 0 0 1 Extrinsic rot and translation 1 0 0 16 0 1 0 6 0 0 1 9 0 0 0 1 0.6612 10.55 108.0 1 = ( ) 22262 16755 97.47

Camera parameters Issue camera may not be at the origin, looking down the z-axis extrinsic parameters one unit in camera coordinates may not be the same as one unit in world coordinates intrinsic parameters - focal length, principal point, aspect ratio, angle between axes, etc. U V W = Transforma tion representi ng intrinsic parameters Transforma tion Transforma tion representi ng representi ng projection model extrinsic parameters Note: f moved from proj to intrinsics! X Y Z T

Result Camera image Laser measured 3D structure

Hierarchy of different camera models x orth x wp x parap x persp Image plane Object plane X 0 (origin) Camera center Perspective: non-linear Weak perspective: linear approx Orthographic: lin, no scaling Para-perspective: lin

Orthographic projection u v = = x y

The fundamental model for orthographic projection U V W = 1 0 0 0 0 1 0 0 0 0 0 1 X Y Z T

Perspective and Orthographic Projection perspective Orthographic (parallel)

Weak perspective Issue perspective effects, but not over the scale of individual objects u v T = = Tx Ty = f / Z collect points into a group at about the same depth, then divide each point by the depth of its group Adv: easy Disadv: wrong

The fundamental model for weak perspective projection = T Z Y X Z f W V U * / 0 0 0 0 0 1 0 0 0 0 1 Note Z* is a fixed value, usually mean distance to scene

Weak perspective projection = k t t y x 1/ 0 r r 1 α α P 2 2T 1 1T (7dof) Weak perspective projection for an arbitrary camera pose R,t

Full Affine linear camera Affine camera (8dof) 1T α x s r t1 m11 2T PA = α y r t 2 A = m21 1 0 1/ k 0 1 0 0 0 P A = 3 3 affine 0 1 0 0 4 4 affine 0 0 0 1 [ ] [ ] 1. Affine camera=camera with principal plane coinciding with Π 2. Affine camera maps parallel lines to parallel lines 3. No center of projection, but direction of projection P A D=0 (point on Π ) m m 0 m m 0 t1 t 1 12 13 P 22 23 2

Hierarchy of camera models Camera center Image plane Object plane X 0 (origin) x persp Perspective: x parap Para-perspective: First order approximation of perspective = z y x persp t t t f f P k j i 1 x orth Orthographic: = 1 T y x orth t t P 0 j i Weak perspective: x wp = 1 1 T y x wp t t k k P 0 j i

Camera Models Internal calibration: Weak calibration: Affine calibration: Stratification of stereo vision: - characterizes the reconstructive certainty of weakly, affinely, and internally calibrated stereo rigs C sim up to a similarity (scaled Euclidean transformation) C aff up to an affine transformation of task space C proj up to a projective transformation of task space C inj reconstruction up to a bijection of task space

Visual Invariance sim aff aff proj proj proj inj inj inj inj

Perspective Camera Model Structure Assume R and T express camera in world coordinates, then p R T R p w c = 1 0 0 0 ' ' Combining with a perspective model (and neglecting internal parameters) yields p f R T T R T R f R R R p M u w z y x z y x w c = = ' ' ' ' Note the M is defined only up to a scale factor at this point! If M is viewed as a 3x4 matrix defined up to scale, it is called the projection matrix.

Perspective Camera Model Structure Assume R and T express camera in world coordinates, then p R T R p w c = 1 0 0 0 ' ' Combining with a weak perspective model (and neglecting internal parameters) yields p f T P R T R T R R R p M u w z y x y x w c = = ) ( ' ' 0 ' ' Where is the nominal distance to the viewed object P

Other Models The affine camera is a generalization of weak perspective. The projective camera is a generalization of the perspective camera. Both have the advantage of being linear models on real and projective spaces, respectively. But in general will recover structure up to an affine or projective transform only. (ie distorted structure)

Camera Internal Calibration Recall: Intrinsic Parameters Intrinsic Parameters describe the conversion from metric to pixel coordinates (and the reverse) x mm = - (x pix o x ) s x y mm = - (y pix o y ) s y p M w y x o s o s w y x mm y y x x pix int 1 0 0 1/ 0 0 1/ = = or

CAMERA INTERNAL CALIBRATION Compute Sx Known distance d Focal length = 1/ Sx rki = ( x d r ( x d = i i+ 1 o x x i ) s ) s x x known regular offset r A simple way to get scale parameters; we can compute the optical center as the numerical center and therefore have the intrinsic parameters

Camera calibration Issues: what are intrinsic parameters of the camera? what is the camera matrix? (intrinsic+extrinsic) General strategy: view calibration object identify image points obtain camera matrix by minimizing error obtain intrinsic parameters from camera matrix Error minimization: Linear least squares easy problem numerically solution can be rather bad Minimize image distance more difficult numerical problem solution usually rather good, but can be hard to find start with linear least squares Numerical scaling is an issue

GOAL: Passive 2- camera system for triangulating 3D position of points in space to generate a depth map of a world scene. Humans use stereo vision to obtain depth Stereo Vision

Stereo depth calculation: Simple case, aligned cameras DISPARITY= (XL - XR) Similar triangles: Z = (f/xl) X Z= (f/xr) (X-d) Z Solve for X: (f/xl) X = (f/xr) (X-d) X = (XL d) / (XL - XR) Solve for Z: f XL XR Z = d*f (XL - XR) (0,0) (d,0) X

Epipolar constraint Special case: parallel cameras epipolar lines are parallel and aligned with rows

Stereo measurement example: Left image Resolution = 1280 x 1024 pixels f = 1360 pixels Right image Baseline d = 1.2m Q: How wide is the hallway

How wide is the hallway? General strategy Similar triangles: W = Z Need depth Z v f Then solve for W W Z v f

How wide is the hallway? Steps in solution: 1. Compute focal length f in meters from pixels 2. Compute depth Z using stereo formula (aligned camera planes) Z = d*f (XL - XR) 3. Compute width: W = Z v f

Focal length: Here screen projection is metric image plane. f = 1360 pixels f = 1360 1280 *0.224 = 0.238m 0.224m is 1280 pixels

How wide Depth calculation XL = 0.144m XR = 0.074m Disparity: XL XR = 0.07m (Note in the disparity calculation the choice of reference (here the edge) doesn t matter. But in the case of say X-coordinate calculation it should be w.r.t. the center of the image as in the stereo formula derivation Depth 1.2*0.238 Z = = 4. 1m 0.07

Similar triangles: How wide? Answer: W = Z The width of the hallway is: v f 0.135 W = 4.1* = 2. 3m 0.238 V = 0.135m W Z v f