資源簡(jiǎn)介
機(jī)器視覺中利用單幅圖像進(jìn)行求解單應(yīng)性矩陣從而測(cè)量圖像中長(zhǎng)度,基于MATLAB編寫

代碼片段和文件信息
function?[HHnorminv_Hnorm]?=?compute_homography(mM)
?
%compute_homography?
%?
%[HHnorminv_Hnorm]?=?compute_homography(mM)?
%?
%Computes?the?planar?homography?between?the?point?coordinates?on?the?plane?(M)?and?the?image?
%point?coordinates?(m).?
%?
%INPUT:?m:?homogeneous?coordinates?in?the?image?plane?(3xN?matrix)?
%???????M:?homogeneous?coordinates?in?the?plane?in?3D?(3xN?matrix)?
%?
%OUTPUT:?H:?Homography?matrix?(3x3?homogeneous?matrix)?
%????????Hnorm:?Normalization?matrix?used?on?the?points?before?homography?computation?
%???????????????(useful?for?numerical?stability?is?points?in?pixel?coordinates)?
%????????inv_Hnorm:?The?inverse?of?Hnorm?
%?
%Definition:?m?~?H*M?where?“~“?means?equal?up?to?a?non?zero?scalar?factor.?
%?
%Method:?First?computes?an?initial?guess?for?the?homography?through?quasi-linear?method.?
%????????Then?if?the?total?number?of?points?is?larger?than?4?optimize?the?solution?by?minimizing?
%????????the?reprojection?error?(in?the?least?squares?sense).?
%?
%?
%Important?functions?called?within?that?program:?
%?
%comp_distortion_oulu:?Undistorts?pixel?coordinates.?
%?
%compute_homography.m:?Computes?the?planar?homography?between?points?on?the?grid?in?3D?and?the?image?plane.?
%?
%project_points.m:?Computes?the?2D?image?projections?of?a?set?of?3D?points?and?also?returns?te?Jacobian?
%??????????????????matrix?(derivative?with?respect?to?the?intrinsic?and?extrinsic?parameters).?
%??????????????????This?function?is?called?within?the?minimization?loop.?
Np?=?size(m2);?
?
if?size(m1)<3?
???m?=?[m;ones(1Np)];?
end;?
?
if?size(M1)<3?
???M?=?[M;ones(1Np)];?
end;?
?
?
m?=?m?./?(ones(31)*m(3:));?
M?=?M?./?(ones(31)*M(3:));?
?
%?Prenormalization?of?point?coordinates?(very?important):?
%?(Affine?normalization)?
?
ax?=?m(1:);?
ay?=?m(2:);?
?
mxx?=?mean(ax);?
myy?=?mean(ay);?
ax?=?ax?-?mxx;?
ay?=?ay?-?myy;?
?
scxx?=?mean(abs(ax));?
scyy?=?mean(abs(ay));?
?
?
Hnorm?=?[1/scxx?0?-mxx/scxx;0?1/scyy?-myy/scyy;0?0?1];?
inv_Hnorm?=?[scxx?0?mxx?;?0?scyy?myy;?0?0?1];?
?
mn?=?Hnorm*m;?
?
%?Compute?the?homography?between?m?and?mn:?
?
%?Build?the?matrix:?
?
L?=?zeros(2*Np9);?
?
L(1:2:2*Np1:3)?=?M‘;?
L(2:2:2*Np4:6)?=?M‘;?
L(1:2:2*Np7:9)?=?-((ones(31)*mn(1:)).*?M)‘;?
L(2:2:2*Np7:9)?=?-((ones(31)*mn(2:)).*?M)‘;?
?
if?Np?>?4?
L?=?L‘*L;?
end;?
?
[USV]?=?svd(L);?
?
hh?=?V(:9);?
hh?=?hh/hh(9);?
?
Hrem?=?reshape(hh33)‘;?
%?Final?homography:??
H?=?inv_Hnorm*Hrem;?
?
if?0?
???m2?=?H*M;?
???m2?=?[m2(1:)./m2(3:)?;?m2(2:)./m2(3:)];?
???merr?=?m(1:2:)?-?m2;?
end;?
?
%keyboard;?
??
%%%?Homography?refinement?if?there?are?more?than?4?points:?
?
if?Np?>?4?
????
???%?Final?refinement:?
???hhv?=?reshape(H‘91);?
???hhv?=?hhv(1:8);?
????
???for?iter=1:10?
??????? mrep?=?H?*?M;??
J?=?zeros(2*Np8);??
MMM?=?(M?./?(ones(31)*mrep(3:)));?
?
J(1:2:2*Np1:3)?=?-MMM‘;?
J(2:2:2*Np4:6)?=?-MMM‘;?
?
mrep?=?mrep?./?
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-10-18?22:52??單目測(cè)量\
?????文件?????2560685??2018-10-18?20:58??單目測(cè)量\1.jpg
?????文件?????2914215??2018-10-18?22:34??單目測(cè)量\2.jpg
?????文件????????3818??2018-10-18?22:50??單目測(cè)量\compute_homography.m
?????文件?????????793??2007-10-03?16:34??單目測(cè)量\homography.m
?????文件????????1114??2018-10-23?21:45??單目測(cè)量\zuoye1.m
評(píng)論
共有 條評(píng)論