Changeset 1000 for trunk/src/toolbox_calib/compute_homography.m
 Timestamp:
 Feb 17, 2017, 2:51:46 PM (7 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/src/toolbox_calib/compute_homography.m
r926 r1000 34 34 35 35 36 37 38 36 Np = size(m,2); 39 37 40 38 if size(m,1)<3, 41 m = [m;ones(1,Np)];39 m = [m;ones(1,Np)]; 42 40 end; 43 41 44 42 if size(M,1)<3, 45 M = [M;ones(1,Np)];43 M = [M;ones(1,Np)]; 46 44 end; 47 45 … … 82 80 83 81 if Np > 4, 84 82 L = L'*L; 85 83 end; 86 84 … … 99 97 100 98 if 0, 101 m2 = H*M;102 m2 = [m2(1,:)./m2(3,:) ; m2(2,:)./m2(3,:)];103 merr = m(1:2,:)  m2;99 m2 = H*M; 100 m2 = [m2(1,:)./m2(3,:) ; m2(2,:)./m2(3,:)]; 101 merr = m(1:2,:)  m2; 104 102 end; 105 103 106 104 %keyboard; 107 105 108 106 %%% Homography refinement if there are more than 4 points: 109 107 110 108 if Np > 4, 111 112 % Final refinement:113 hhv = reshape(H',9,1);114 hhv = hhv(1:8);115 116 for iter=1:10,117 118 109 119 120 mrep = H * M; 110 % Final refinement: 111 hhv = reshape(H',9,1); 112 hhv = hhv(1:8); 121 113 122 J = zeros(2*Np,8); 114 for iter=1:10, 123 115 124 MMM = (M ./ (ones(3,1)*mrep(3,:)));116 mrep = H * M; 125 117 126 J(1:2:2*Np,1:3) = MMM'; 127 J(2:2:2*Np,4:6) = MMM'; 128 129 mrep = mrep ./ (ones(3,1)*mrep(3,:)); 118 J = zeros(2*Np,8); 130 119 131 m_err = m(1:2,:)  mrep(1:2,:); 132 m_err = m_err(:); 120 MMM = (M ./ (ones(3,1)*mrep(3,:))); 133 121 134 MMM2 = (ones(3,1)*mrep(1,:)) .* MMM;135 MMM3 = (ones(3,1)*mrep(2,:)) .* MMM;122 J(1:2:2*Np,1:3) = MMM'; 123 J(2:2:2*Np,4:6) = MMM'; 136 124 137 J(1:2:2*Np,7:8) = MMM2(1:2,:)'; 138 J(2:2:2*Np,7:8) = MMM3(1:2,:)'; 125 mrep = mrep ./ (ones(3,1)*mrep(3,:)); 139 126 140 MMM = (M ./ (ones(3,1)*mrep(3,:)))'; 127 m_err = m(1:2,:)  mrep(1:2,:); 128 m_err = m_err(:); 141 129 142 hh_innov = inv(J'*J)*J'*m_err; 130 MMM2 = (ones(3,1)*mrep(1,:)) .* MMM; 131 MMM3 = (ones(3,1)*mrep(2,:)) .* MMM; 143 132 144 hhv_up = hhv  hh_innov; 133 J(1:2:2*Np,7:8) = MMM2(1:2,:)'; 134 J(2:2:2*Np,7:8) = MMM3(1:2,:)'; 145 135 146 H_up = reshape([hhv_up;1],3,3)';136 MMM = (M ./ (ones(3,1)*mrep(3,:)))'; 147 137 148 %norm(m_err) 149 %norm(hh_innov) 138 hh_innov = inv(J'*J)*J'*m_err; 150 139 151 hhv = hhv_up; 152 H = H_up; 153 154 end; 155 140 hhv_up = hhv  hh_innov; 156 141 142 H_up = reshape([hhv_up;1],3,3)'; 143 144 %norm(m_err) 145 %norm(hh_innov) 146 147 hhv = hhv_up; 148 H = H_up; 149 150 end; 157 151 end; 158 152 159 153 if 0, 160 m2 = H*M;161 m2 = [m2(1,:)./m2(3,:) ; m2(2,:)./m2(3,:)];162 merr = m(1:2,:)  m2;154 m2 = H*M; 155 m2 = [m2(1,:)./m2(3,:) ; m2(2,:)./m2(3,:)]; 156 merr = m(1:2,:)  m2; 163 157 end; 164 158
Note: See TracChangeset
for help on using the changeset viewer.