资源简介
机器视觉中利用单幅图像进行求解单应性矩阵从而测量图像中长度,基于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画法
- 基于BP神经网络对几种字体0-9的数字识
- p文件,MATLAB的
- matlab读取SP3文件
- 内弹道计算
- SRC的程序,matlab的,很有用处
- 基于sift特征的人民币识别matlab版
- 线性拟合仿真-最小二乘法、正交回归
- 单机器人的多任务路径规划GUI
- 强化学习代码,2016版,matlab
- 冲击电压发生器MATLAB仿真,主要是单
- 条纹投影轮廓术中的快速光栅预校准
- pso解决单目标优化问题
- 单连杆系统独立PD控制和PD+重力补偿控
- 最优化算法规划-单纯形法MATLAB程序
- 基本粒子群算法,MATLAB文件的M文件编
- PLC编程简单程序
- 小波滤波,可用于心电信号、脉搏波
- 通信原理matlab最全仿真,曹丽娜,樊
- matlab实现单纯形法
- MATLAB调用摄像头实现单次拍照多次连
- matlab数字图像处理之几何变换将图像
- matlab数字图像处理之图像几何变换
- 车牌识别带有设计报告,图片,Matl
- 数字图像课程设计MATLAB实现简单找茬
- 机器视觉论文基于matlab的间单图像处
- 用matlab求解单摆模型
- MATLAB计算两个图片的单应性矩阵
- 遥感数字图像处理-matlab-主成份及穗帽
- 几乎包含IEEE所有节点的牛拉潮流计算
评论
共有 条评论