Sample solution of an optimization problem on the essential manifold. Solves the problem \sum_{i=1}^N ||E_i-A_i||^2, where E_i are essential matrices. Essential matrices are used in computer vision to represent the epipolar constraint between projected points in two perspective views. Note: the essentialfactory file uses a quotient R1/R2 representation to work with essential matrices. On the other hand, from a user point of view, it is convenient to use the E representation (a matrix of size 3-by-3) to give cost, gradient, and Hessian information. To this end, we provide auxiliary files essential_costE2cost, essential_egradE2egrad, and essential_ehessE2ehess that convert these ingredients to their R1/R2 counterparts. See also: essentialfactory essential_costE2cost essential_egradE2egrad essential_ehessE2ehess

- essential_costE2cost Cost evaluation at X given function handle in the Essential matrix E.
- essential_egradE2egrad Converts the gradient in essential matrix E to the gradient in X.
- essential_ehessE2ehess Converts the Hessian in essential matrix E to the Hessian in X.
- essential_hat3 Compute the matrix representation of the cross product
- essentialfactory Manifold structure to optimize over the space of essential matrices.
- randrot Generates uniformly random rotation matrices.
- trustregions Riemannian trust-regions solver for optimization on manifolds.
- multiprod Multiplying 1-D or 2-D subarrays contained in two N-D arrays.
- multisqnorm Returns the squared Frobenius norms of the slices of a 3D matrix.

0001 function essential_svd 0002 % Sample solution of an optimization problem on the essential manifold. 0003 % 0004 % Solves the problem \sum_{i=1}^N ||E_i-A_i||^2, where E_i are essential 0005 % matrices. Essential matrices are used in computer vision to represent the 0006 % epipolar constraint between projected points in two perspective views. 0007 % 0008 % Note: the essentialfactory file uses a quotient R1/R2 representation to 0009 % work with essential matrices. On the other hand, from a user point of 0010 % view, it is convenient to use the E representation (a matrix of size 0011 % 3-by-3) to give cost, gradient, and Hessian information. To this end, we 0012 % provide auxiliary files essential_costE2cost, essential_egradE2egrad, and 0013 % essential_ehessE2ehess that convert these ingredients to their R1/R2 0014 % counterparts. 0015 % 0016 % See also: essentialfactory essential_costE2cost essential_egradE2egrad 0017 % essential_ehessE2ehess 0018 0019 % This file is part of Manopt: www.manopt.org. 0020 % Original author: Roberto Tron, Aug. 8, 2014 0021 % Contributors: Bamdev Mishra, May 15, 2015. 0022 0023 0024 % Make data for the test 0025 N = 2; % Number of matrices to process in parallel. 0026 A = multiprod(multiprod(randrot(3, N), essential_hat3([0; 0; 1])), randrot(3, N)); 0027 0028 % The essential manifold 0029 M = essentialfactory(N); 0030 problem.M = M; 0031 0032 % Function handles of the essential matrix E and Euclidean gradient and Hessian 0033 costE = @(E) 0.5*sum(multisqnorm(E-A)); 0034 egradE = @(E) E - A; 0035 ehessE = @(E, U) U; 0036 0037 0038 % Manopt descriptions 0039 problem.cost = @cost; 0040 function val = cost(X) 0041 val = essential_costE2cost(X, costE); % Cost 0042 end 0043 0044 problem.egrad = @egrad; 0045 function g = egrad(X) 0046 g = essential_egradE2egrad(X, egradE); % Converts gradient in E to X. 0047 end 0048 0049 problem.ehess = @ehess; 0050 function gdot = ehess(X, S) 0051 gdot = essential_ehessE2ehess(X, egradE, ehessE, S); % Converts Hessian in E to X. 0052 end 0053 0054 0055 % Numerically check the differentials. 0056 % checkgradient(problem); pause; 0057 % checkhessian(problem); pause; 0058 0059 %Solve the problem 0060 Xsol = trustregions(problem); 0061 0062 % Distance between original matrices and decompositions 0063 val = essential_costE2cost(Xsol, costE); 0064 fprintf('Distance between original matrices and decompositions is %e \n', val); 0065 0066 end

Generated on Fri 08-Sep-2017 12:43:19 by