Computer Vision, Assignment 1 Elements of Projective Geometry

Similar documents
Computer Vision, Assignment 4 Model Fitting

Computer Vision, Laboratory session 1

Computer Vision, Laboratory session 1

1 Projective Geometry

Image Warping, Linear Algebra CIS581

Assignment 2 : Projection and Homography

Geometric transformations assign a point to a point, so it is a point valued function of points. Geometric transformation may destroy the equation

COMP 558 lecture 19 Nov. 17, 2010

Humanoid Robotics. Projective Geometry, Homogeneous Coordinates. (brief introduction) Maren Bennewitz

Lecture 1.3 Basic projective geometry. Thomas Opsahl

Lecture 6 Geometric Transformations and Image Registration. Lin ZHANG, PhD School of Software Engineering Tongji University Spring 2013

Computer Vision CSCI-GA Assignment 1.

Lecture 3: Camera Calibration, DLT, SVD

Visual Recognition: Image Formation

Pin Hole Cameras & Warp Functions

Instance-level recognition I. - Camera geometry and image alignment

calibrated coordinates Linear transformation pixel coordinates

Linear Algebra Simplified

Perspective Projection in Homogeneous Coordinates

3D Geometry and Camera Calibration

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

Overview. By end of the week:

Computer Vision I Name : CSE 252A, Fall 2012 Student ID : David Kriegman Assignment #1. (Due date: 10/23/2012) x P. = z

Basic Elements. Geometry is the study of the relationships among objects in an n-dimensional space

APPM 2360 Project 2 Due Nov. 3 at 5:00 PM in D2L

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

Projective geometry for Computer Vision

Introduction to Homogeneous coordinates

CSE 252B: Computer Vision II

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

Structure from Motion. Prof. Marco Marcon

MAT 343 Laboratory 4 Plotting and computer animation in MATLAB

Pin Hole Cameras & Warp Functions

Perspective Projection [2 pts]

Camera model and multiple view geometry

DD2429 Computational Photography :00-19:00

Computer Graphics Hands-on

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

Today. Today. Introduction. Matrices. Matrices. Computergrafik. Transformations & matrices Introduction Matrices

Outline. ETN-FPI Training School on Plenoptic Sensing

Rectification and Distortion Correction

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

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

Graphics and Interaction Transformation geometry and homogeneous coordinates

3-D D Euclidean Space - Vectors

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

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

Exercise session using MATLAB: Quasiconvex Optimixation

C / 35. C18 Computer Vision. David Murray. dwm/courses/4cv.

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

521466S Machine Vision Exercise #1 Camera models

Geometric camera models and calibration

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

Computer Vision I - Appearance-based Matching and Projective Geometry

METRIC PLANE RECTIFICATION USING SYMMETRIC VANISHING POINTS

CIS 580, Machine Perception, Spring 2014: Assignment 4 Due: Wednesday, April 10th, 10:30am (use turnin)

2D transformations: An introduction to the maths behind computer graphics

Computer Vision Projective Geometry and Calibration. Pinhole cameras

N-Views (1) Homographies and Projection

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

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

3D Modeling using multiple images Exam January 2008

CSCI 5980/8980: Assignment #4. Fundamental Matrix

Vector Algebra Transformations. Lecture 4

Vision Review: Image Formation. Course web page:

3D Reconstruction from Two Views

Overview of Projections: From a 3D world to a 2D screen.

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

Lecture 3 Sections 2.2, 4.4. Mon, Aug 31, 2009

Computer Vision I - Appearance-based Matching and Projective Geometry

Camera Calibration. COS 429 Princeton University

CS6670: Computer Vision

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

Computer Vision cmput 428/615

Early Fundamentals of Coordinate Changes and Rotation Matrices for 3D Computer Vision

Agenda. Rotations. Camera models. Camera calibration. Homographies

Lecture 5 2D Transformation

EXAMINATIONS 2017 TRIMESTER 2

WEEK 4 REVIEW. Graphing Systems of Linear Inequalities (3.1)

Math background. 2D Geometric Transformations. Implicit representations. Explicit representations. Read: CS 4620 Lecture 6

EEE161 Applied Electromagnetics Laboratory 1

EECE 478. Learning Objectives. Learning Objectives. Linear Algebra and 3D Geometry. Linear algebra in 3D. Coordinate systems

CSCI 5980: Assignment #3 Homography

Vector Calculus: Understanding the Cross Product

Projective geometry, camera models and calibration

2D Object Definition (1/3)

Mathematics 308 Geometry. Chapter 9. Drawing three dimensional objects

Multiple View Geometry in Computer Vision

Perspective projection and Transformations

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

Camera model and calibration

CV: 3D sensing and calibration

Image Manipulation in MATLAB Due Monday, July 17 at 5:00 PM

Fundamental Matrix & Structure from Motion

Multiple View Geometry in Computer Vision

Introduction to Computer Graphics and Computer Vision Assignment 3: Due 7/27/2015

CS 4204 Computer Graphics

Linear transformations Affine transformations Transformations in 3D. Graphics 2009/2010, period 1. Lecture 5: linear and affine transformations

1. Register an account on: using your Oxford address

Invariance of l and the Conic Dual to Circular Points C

Transcription:

Centre for Mathematical Sciences, February 05 Due study week Computer Vision, Assignment Elements of Projective Geometry Instructions In this assignment you will study the basics of projective geometry. You will study the representations of points lines and planes, as well as transformations and camera matrices. The data for the assignments is availible under www.maths.lth.se/vision/datorseende/assignmentdata.zip The assignment is due at the end of study week. Make sure you answer all questions and provide complete solutions to the exercises. You may hand in hand-written solutions and/or printouts in the slot marked "datorseende" on the rd floor of the mathematics building and/or as a pdf by mail to fma70@maths.lth.se. Write your name and the assignment number in the subject line. After each exercise there is a gray box with instructions on what should be included in the report. In addition, all the code should be submitted as m-files by mail. Make sure that your matlab scripts are well commented and can be executed directly (that is, without loading any data, setting parameters etc. Such things should be done in the script). You will have time to work with the assignments during the computer laboratory sessions and the exercise sessions. These sessions are intended to provide an opportunity for asking questions to the lecturer on things you have problems with or just to work with the assignment. During the laboratory sessions you should work on the exercises marked "Computer Exercise". The rest of the exercises are intended to provide hints and prepare you for the computer exercises. You are expected to have solved these before you go to the lab sessions. The report should be written individually, however you are encouraged to work together (in the lab session you might have to work in pairs). Keep in mind that everyone is responsible for their own report and should be able to explain all the solutions.

Assignment Computer Vision, Vt 05 Points in Homogeneous Coordinates. Exercise. What is the D Cartesian coordinates of the points with homogeneous coordinates x = 4, x = and x = 4λ λ, λ 0? () λ What is the interpretation of the point with homogeneous coordinates x 4 = 4? () 0 For the report: Answers are enough. Computer Exercise. Write a matlab function pflat that divides the homogeneous coordinates with their last entry for points of any dimensionality. (You may assume that none of the points have last homogeneous coordinate zero.) Apply the function to the points in xd and xd in the file compex.mat, and plot the result. x( end,:) % Extracts the last row of x repmat (a,[ m n]) % Creates a block matrix with mn copies of a. a./ b % Elementwise division. % Divides the elements of a by the corresponding element of b. plot (a(,:),a(,:),. ) % Plots a point at (a(,i),a(,i)) for each i. plot (a(,:),a(,:),a(,:),. ) % Same as above but D. axis equal % Makes sure that all axes have the same scale. For the report: Submit the m-file, and the plots. Lines Exercise. Compute the homogeneous coordinates of the intersection (in P ) of the lines l = and l =. () What is the corresponding point in R? Compute the intersection (in P ) of the lines l = and l 4 = What is the geometric interpretation in R?. (4) Compute the line that goes through the points with Cartesian coordinates ( ) ( ) x = and x =. (5)

Assignment Computer Vision, Vt 05 Hint: Re-use the calculations from the line intersections above. For the report: Submit a complete solution. Exercise. The nullspace of a m n matrix A is the set N (A) = {x R n ; Ax = 0}, (6) that is, all the x for which the multiplication Ax gives the zero vector. Explain why the intersection point (in homogeneous coordinates) of l and l (from Exercise ) is in the null space of the matrix ( ) M =. (7) Are there any other points in the null space besides the intersection point? For the report: Answer all the questions. Computer Exercise. Load and plot the image in compex.jpg (see figure ). Figure : compex.jpg In the file compex.mat there are three pairs of image points. Plot the image points in the same figure as the image. For each pair of points compute the line going through the points. Use the function rital to plot the lines in the same image. Do these lines appear to be parallel (in D)? Compute the point of intersection between the second and third line (the lines obtained from the pairs p and p). Plot this point in the same image. The distance between a D-point x = (x, x ) in Cartesian coordinates and a line l = (a, b, c) can be computed using the distance formula d = ax + bx + c a + b, (8) see your linear algebra book. Compute the distance between the first line and the the intersection point. Is it close to zero? Why/why not? imread ( compex. JPG ) % Loads the image compex. JPG imagesc ( im) % Displays the image colormap gray % changes the colormap of the current image to gray scale

Assignment Computer Vision, Vt 05 4 hold on % Prevents the plot command from clearing the figure before plotting hold off % Makes the plot command clear the figure before plotting null ( A) % computes the nullspace of A For the report: Submit the m-file, the plot, and the computed distance between the intersection point and the first line. 4 Projective Transformations Exercise 4. Let H be the projective transformation H = 0 0 (9) 0 0 Compute the transformations y Hx and y Hx if x = 0 and x = 0 Compute the lines l, l containing x,x and y,y respectively. Compute (H ) T l and compare to l.. (0) Show that projective transformations preserve lines. That is, for each line l there is a corresponding line l such that if x belongs to l then the transformation y Hx belongs to l. (Hint: If l T x = 0 then l T H Hx = 0.) For the report: Submit the answers and the proof. Computer Exercise. The file compex.mat contains the start and end points of a set of lines. Plotting the lines gives the grid in figure. Figure : Lines between start and end points. 4

Assignment Computer Vision, Vt 05 5 For each of the projective mappings given by the matrices H =, H = 0, () 0 0 0 0 H = 0 0 0 0 0 and H 4 =, () /4 / compute the transformations of the given start and endpoints and plot the lines between them. (Note that you do not need to loop over the points. One matrix multiplication for the start and end points is enough. To compute cartesian coordinates you can use your pflat function. Don t forget to use the axis equal command, otherwise the figures might look distorted.) Which of the transformations preserve lengths between points? Which preserve angles between lines? Which maps parallel lines to parallel lines? Classify the transformations into euclidean, similarity, affine and projective transformations. plot ([ startpoints (,:); endpoints (,:)],... [ startpoints (,:); endpoints (,:)], b- ); % Plots a blue line between each startpoint and endpoint For the report: Submit the plots, and the answers to all the questions. 5 The Pinhole Camera Exercise 5. Compute the projections of the D points with homogeneous coordinates X =, X = and X =, () in the camera with camera matrix P = 0 0 0 0 0 0 0 0. (4) What is the interpretation of the projection of X? Compute the camera center (position) of the camera and the principal axis (viewing direction). For the report: Answers are enough. Computer Exercise 4. Load and plot the images compex4im.jpg and compex4im.jpg (see figure ). The file compex4.mat contains the camera matrices P, P and a point model U of the statue. Compute the camera centers and principal axes of the cameras. Plot the D-points in U and the camera centers in the same D plot (make sure that the 4th coordinate of U is one before you plot by using pflat). In addition plot a vector in the direction of the principal axes (viewing direction) from the camera center. Project the points in U into the cameras P and P and plot the result in the same plots as the images. Does the result look reasonable? 5

Assignment Computer Vision, Vt 05 6 Figure : compex4im.jpg and compex4im.jpg null ( P) % computes the nullspace of P P (,:) % extracts elements P, P and P. quiver (a(),a(),a(),v(),v(),v(),s) % Plots a vector v starting from % the point a and rescales the sise by s plot (x (,:), x (,:),., Markersize,);% Same as plot but with smaller points For the report: Submit the m-file, the plots, the camera centers in Cartesian coordinates, and the principal axes normalized to length one. Exercise 6. (OPTIONAL.) Consider the calibrated camera pair P = [I 0] and P = [R t]. If x is the D projection of the D point U in P, that is x P U verify that ( ) x U, (5) s where s R. That is, for any s the point of the form U(s) = (x T, s) T projects to x. What kind of object is this collection of points? Is it possible to determine s using only information from P? Assume that U belongs to the plane where π R. Π T U(s) = 0. Π = ( π ), (6) Compute the s that makes U(s) belong to the plane, that is, find s such that Verify that if x P U, y P U and Π T U = 0 then the homography H = (R tπ T ), (7) where P = [R t], maps x to y. (Hint: What is P U(s) for the s from above?) For the report: Include whatever you want, the exercise is optional. Computer Exercise 5. (OPTIONAL.) Figure 4 shows an image (compex5.jpg) of a poster located somewhere in the Centre for Mathematical Sciences. (Here the axes units are pixels.) The file compex5.mat contains the inner parameters K, the corner points of the poster and the D plane v that contains the poster. The camera matrix for the camera that generated this image is P = K[I 0]. (8) 6

Assignment Computer Vision, Vt 05 7 Figure 4: Arnold looking mean. The goal of this exercise is to create an image of the poster taken by a camera m to the right of the poster. Start by plotting the corner points and the image in the same D-figure. (Use axis equal to get the correct aspect ratio.) Note the scale on the axis. Where is the origin of the image coordinate system located? To be able to use the formulas derived in Exercise 6 we must first ensure that we have calibrated cameras. To do this normalize the corner points by multiplying with K and plot them in a new Dfigure. (Use axis ij to make the y-axis point downwards (as for the previous image) and axis equal. Note the difference in scale compared to the previous figure. Where is the origin of the image coordinate system located? Since the inner parameters K have been removed our calibrated camera is [I 0]. Using the results from Exercise 6 compute the D points in the plane v that project onto the corner points. Compute the camera center and principal axis, and plot together with the D-points. Does it look reasonable? Next compute a new camera with camera center in (, 0, 0) ( units to the right of P ) and orientation R = 0 0 0 0 (9) (minus 0 degrees rotation around the y-axis. Note that the y-axis points down in the first image.) Compute the new camera and plot in the same figure. (Don t forget to use axis equal.) Compute the homography in Exercise 6 and transform the normalized corner points to the new (virtual) image. Plot the transformed points (don t forget to divide by the third coordinate) in a new D-figure. Does the result look like you would expect it to when moving the camera like this? Also project the D points into the same image using the camera matrix. Does this give the same result? We now have a homography that takes normalized points in the first camera and transforms them to normalized points in the second camera. To remove the need for normalization we simply include the normalization in the homography. If x = K x and ỹ = K y then for the normalized points x and 7

Assignment Computer Vision, Vt 05 8 ỹ we have ỹ H x K y HK x y KHK x (0) Therefore the total transformation is H tot = KHK. Transform the original image and the corner points using the homography H tot and plot both in a new D-figure. plot ( corners (,[: end ]), corners (,[: end ]), *- ); % Plots the cornerpoints and connects them with lines. axis ij % Makes the y- axis point down ( as in an image ) tform = maketform ( projective, Htot ); % Creates a projective transformation that can be used in imtransform % NOTE : Matlab uses the transposed version of the homografi. [ new_im, xdata, ydata ] = imtransform (im, tform, size,size (im )); % Creastes a transformed image ( using tform ) % of the same size as the original one. imagesc ( xdata, ydata, new_im ); % plots the new image with xdata and ydata on the axes For the report: Whatever you like, the exercise is optional. 8