public double Cost(Image <Arthmetic, double> F, double fx, double fy, double px, double py, double w, double h) { Image <Arthmetic, double> E = ComputeMatrix.E(F, ComputeMatrix.K(fx, fy, px, py)); Svd svd = new Svd(E); double s1 = svd.S[0, 0]; double s2 = svd.S[1, 0]; double errS = s2 == 0 ? 1.0 : (s1 - s2) / s2; return(errS); }
public static double Cost(List <Image <Arthmetic, double> > Fs, double fx, double fy, double px, double py, double w, double h) { double errS = 0; foreach (var F in Fs) { Image <Arthmetic, double> E = ComputeMatrix.E(F, ComputeMatrix.K(fx, fy, px, py)); Svd svd = new Svd(E); double s1 = svd.S[0, 0]; double s2 = svd.S[1, 0]; errS += s2 == 0 ? 1 : (s1 - s2) / s2; } return(errS); }
public static Image <Arthmetic, double> K(List <Image <Arthmetic, double> > Fs, double width, double height) { double fi = (width + height) / 2; var minimizer = new BfgsMinimizer(1e-6, 1e-6, 1e-6); var result = minimizer.FindMinimum( new ObjFunc() { Fs = Fs, Width = width, Height = height }, new DenseVector(new double[] { fi, fi, width / 2, height / 2 }) ); var p = result.MinimizingPoint; return(ComputeMatrix.K(p[0], p[1], p[2], p[3])); }