-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmax_log_vp.m
More file actions
executable file
·28 lines (23 loc) · 1013 Bytes
/
Copy pathmax_log_vp.m
File metadata and controls
executable file
·28 lines (23 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
%
% Copyright 2014 by Kitware, Inc. All Rights Reserved. Please refer to
% LICENSE.TXT for licensing information, or contact General Counsel,
% Kitware, Inc., 28 Corporate Drive, Clifton Park, NY 12065.
%
function vp = max_log_vp(vp,args,pp,focal)
stdev=args.stdev;
%% if vp.vp is empty, then use least square to estimate it.
if isempty(vp.vp)
vp.vp = least_square_vp(vp.lsegs);
end
sorted_lsegs = sort_lsegs(vp.lsegs, vp.vp(1:2));
[x,fval] = fminsearch(@(x) vpCostFun(x,sorted_lsegs), vp.vp(1:2));
v = [x,1];
vp.vp=v;
vp.consistency_measure = p_of_lseg_given_v_probability(vp.lsegs,vp.vp,stdev); % not most efficient
% remove = find(vp.consistency_measure < args.min_consistency);
% vp.lsegs(remove,:)=[];
% vp.consistency_measure(remove)=[];
vp.gauss_error = -log(vp.consistency_measure * sqrt(2*pi)*stdev) / (2*stdev^2); % not most efficient
vp.mean_gauss_error = mean(vp.gauss_error);
vp.pan_tilt = img2pt(vp.vp,pp,focal);
vp.gauss_point = img2gaussPoint(vp.vp,pp,focal);