Search
This is a simple task that demonstrates working with homogeneous planar points and lines.
[1, 1]
[800, 600]
H = [1 0.1 0; 0.1 1 0; 0.004 0.002 1 ];
Example result of this task is shown in figure 1.
Notes: the Matlab function ginput is suitable for entering the points.
ginput
[u v] = ginput( 4 ); % or x = ginput(4)'; % note that ginput returns row vectors, hence the transpose
Develop a simulation of perspective camera projection – wire-frame model. Let the 3D object be given. The object is composed from two planar diagrams, that are connected. Coordinates of vertices of both diagrams X1 and X2 are:
X1
X2
z = 4; X1 = [-0.5 0.5 0.5 -0.5 -0.5 -0.3 -0.3 -0.2 -0.2 0 0.5; -0.5 -0.5 0.5 0.5 -0.5 -0.7 -0.9 -0.9 -0.8 -1 -0.5; z z z z z z z z z z z ]; X2 = X1; X2(3,:) = X1(3,:)+0.5;
Wire-frame model contains edges, that connects vertices in X1 and X2 in given order, and additionally it contains edges connecting vertices between X1 and X2, such that the vertex X1(:,i) is connected to the vertex X2(:,i), ∀ i.
X1(:,i)
X2(:,i)
i
The internal calibration matrix of the camera is:
K = [ 1000 0 500; 0 1000 500; 0 0 1 ];
P1
P2
[0;-1;0]
P3
[0;0.5;0]
P4
[0;-3;0.5]
P5
[0;-5;4.2]
P6
[-1.5;-3;1.5]
The example projection by the camera P1 is shown in figure 3.
Drawing: let u1 = [ u1_1, u1_2, …], v1 be the image coordinates of projected vertices X1 and u2, v2 be the coordinates of projected vertices X2. The desired picture can be drawn, e.g., like this:
u1 = [ u1_1, u1_2, …]
v1
u2
v2
plot( u1, v1, 'r-', 'linewidth', 2 ) hold on plot( u2, v2, 'b-', 'linewidth', 2 ) plot( [u1; u2], [v1; v2], 'k-', 'linewidth', 2 ); set( gca, 'ydir', 'reverse' ) axis equal
See the probabilistic model of line and model fitting.
fminsearch)
Consider a pair of images of a scene with two dominant planes, e.g. a pair of images from a triple below. Each plane generate one homography between the image pair. i.e. there are two homographies Ha and Hb.
When a set of tentative correspondences between the images is known (see 2_sparse_correspondences), these homographies can be estimated. Additionally, since these two homographies are generated by two scene planes, there is a line in both images, that is a projection of the intersecting line of the planes. The image points u1, u2 laying on that line in both images are related by both homographies, i.e., u2 ∼ Ha u1 ∼ Hb u1, which can be written as inv(Hb) Ha u1 = λ u1. Thus these two homographies must be estimated such that these constraint is enforced (two arbitrary regular 3×3 matrices generally do not ensure the existence of such a common line. Note that this constraint means that there exist a common line that is transformed same way by the two complementary line homographies inv(Ha') and inv(Hb') (this line always exists for any two regular 3×3 matrices) but additionally that this line is transformed by both homographies from the first image to the same line in the second one point-wise.
There are many methods how to estimate multiple geometric models (homographies in this case) from given data. Two simplest possibilities are:
Note that having two homographies an inlier must be decided to which it belongs to. This can be done based on minimal error or according to on which side of common line the point is laying.
Fig. 5: An example of estimated homographies. Red and green =inliers, black = outliers, magenta = common line.