资源简介
机器视觉中利用单幅图像进行求解单应性矩阵从而测量图像中长度,基于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 ./
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-10-18 22:52 单目测量\
文件 2560685 2018-10-18 20:58 单目测量\1.jpg
文件 2914215 2018-10-18 22:34 单目测量\2.jpg
文件 3818 2018-10-18 22:50 单目测量\compute_homography.m
文件 793 2007-10-03 16:34 单目测量\homography.m
文件 1114 2018-10-23 21:45 单目测量\zuoye1.m
- 上一篇:路标识别与提取采用聚类方法C-meansK-means
- 下一篇:路标识别系统的
相关资源
- 单相整流器及其控制
- 使用Matlab完成简单的树叶识别源代码
-
单点预瞄 Carsim与simuli
nk联合仿真. - 数字图像处理使用matlab进行几何变换
- 数字图像处理之几何变换2将图片贴在
- 单张图像超分辨率matlab
- pudn-几种ADC设计的matlab源码
- 单脉冲模糊函数仿真
- 同济大学线性代数第六版教材,课件
- SRCNN,matlab实现
- 单通道盲源分离SSA-ICA算法Matlab代码
-
基于Simuli
nk的单边电台仿真 - LSD直线检测,matlab工具箱
- 数字调制的参考资料,MATLAB的数字调
- 适用于MATLAB的几个多变量时序数据集
- 基于Meanshift的单目标跟踪算法matlab及
- 几乎所有的计量经济学模型的matlab实
- stm32 matab包,matlab直接生成stm32代码
- 控制数学问题的MATLAB求解
- 一个基于Matlab的简单的ViBe运动检测的
- 卷积神经网络的matlab程序
- 光流法包括LK光流,HS光流,论文,
- MATLAB时频分析程序和演示(有几百个
- 遥感图像几何纠正matlab编程
- PCA人脸降维与单幅图像识别
- 基于模型的设计_MCU篇.pdfMATLAB,SIMUl
- 有源干扰的单脉冲雷达测角方法matl
- 手写数字识别,基于BP神经网络,ma
- 基于Matlab的几种常用边缘检测算子的
- SSB调制解调(matlab)
评论
共有 条评论