-
Notifications
You must be signed in to change notification settings - Fork 1
/
planeNormalFromImageLine.m
51 lines (47 loc) · 1.52 KB
/
planeNormalFromImageLine.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function [u] = planeNormalFromImageLine(P, image_line)
%planeNormalFromImageLine Find the normal to a world plane given its line in the image
%
% ## Syntax
% u = planeNormalFromImageLine(image_line, P)
%
% ## Description
% u = planeNormalFromImageLine(image_line, P)
% Determines the normal vector to the plane projected as the given line
% in the image from the given camera.
%
% ## Input Arguments
%
% P -- Camera projection matrix
% The camera matrix (intrinsic and extrinsic parameters)
%
% image_line -- Projection of plane
% A 3-vector containing the homogenous coordinates of a line in the image
% corresponding to the world plane.
%
% ## Output Arguments
%
% u -- Plane normal vector
% A 3 x 1 unit vector perpendicular to the plane formed by the image line
% and the camera centre, pointing towards the bottom of the image.
%
% ## References
% - R. Hartley and A. Zisserman. Multiple View Geometry in Computer Vision,
% 2nd Edition. Cambridge, UK: Cambridge University Press, 2003.
% Bernard Llanos
% Supervised by Dr. Y.H. Yang
% University of Alberta, Department of Computing Science
% File created March 27, 2017
nargoutchk(1, 1);
narginchk(2, 2);
% The plane back-projected through the image line: Result 8.2 from Multiple
% View Geometry in Computer Vision, 2nd Edition
plane = image_line * P;
% Normal vector to the plane
u = plane(1:3);
u = u ./ repmat(norm(u), 1, 3); % Normalize
% Make sure the vector points to the bottom of the image
[~, camera_yAxis] = cameraAxes( P );
if dot(u, camera_yAxis) < 0
u = -u;
end
end