Go to the documentation of this file.00001
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005
00006
00007
00008 #include "FMPlanarComputeNonLinear.h"
00009 #include <vgl/vgl_homg_point_2d.h>
00010 #include <mvl/PairSetCorner.h>
00011 #include <mvl/FMatrixPlanar.h>
00012 #include <mvl/FMPlanarNonLinFun.h>
00013 #include <vcl_iostream.h>
00014
00015
00016
00017
00018 FMPlanarComputeNonLinear::FMPlanarComputeNonLinear(const ImageMetric* image_metric1,
00019 const ImageMetric* image_metric2,
00020 double outlier_threshold)
00021 : FMatrixCompute()
00022 {
00023 image_metric1_ = image_metric1;
00024 image_metric2_ = image_metric2;
00025 outlier_distance_squared_ = outlier_threshold * outlier_threshold;
00026 }
00027
00028
00029 bool FMPlanarComputeNonLinear::compute_planar(PairMatchSetCorner& matches, FMatrixPlanar* F)
00030 {
00031 PairSetCorner inliers(matches);
00032 return compute_planar(inliers.points1, inliers.points2, F);
00033 }
00034
00035
00036 bool FMPlanarComputeNonLinear::compute_planar(vcl_vector<HomgPoint2D>& points1,
00037 vcl_vector<HomgPoint2D>& points2,
00038 FMatrixPlanar* F)
00039 {
00040 vcl_cerr << "FMPlanarComputeNonLinear: Fitting planar-motion F matrix [e1]_x [l]_x [e2]_x\n";
00041 FMPlanarNonLinFun computor(image_metric1_, image_metric2_, outlier_distance_squared_, points1, points2);
00042 return computor.compute(F);
00043 }
00044
00045
00046 bool FMPlanarComputeNonLinear::compute_planar(vcl_vector<vgl_homg_point_2d<double> >& points1,
00047 vcl_vector<vgl_homg_point_2d<double> >& points2,
00048 FMatrixPlanar& F)
00049 {
00050 vcl_cerr << "FMPlanarComputeNonLinear: Fitting planar-motion F matrix [e1]_x [l]_x [e2]_x\n";
00051 FMPlanarNonLinFun computor(image_metric1_, image_metric2_, outlier_distance_squared_, points1, points2);
00052 return computor.compute(&F);
00053 }
00054
00055 bool FMPlanarComputeNonLinear::compute(PairMatchSetCorner& matches, FMatrix* F)
00056 {
00057 FMatrixPlanar fplanar;
00058 fplanar.init(*F);
00059 if (!compute_planar(matches, &fplanar))
00060 return false;
00061
00062
00063 *F = fplanar;
00064 return true;
00065 }
00066
00067 bool FMPlanarComputeNonLinear::compute(vcl_vector<HomgPoint2D>& points1,
00068 vcl_vector<HomgPoint2D>& points2,
00069 FMatrix* F)
00070 {
00071 FMatrixPlanar fplanar;
00072 fplanar.init(*F);
00073 if (!compute_planar(points1, points2, &fplanar))
00074 return false;
00075
00076
00077 *F = fplanar;
00078 return true;
00079 }
00080
00081 bool FMPlanarComputeNonLinear::compute(vcl_vector<vgl_homg_point_2d<double> >& points1,
00082 vcl_vector<vgl_homg_point_2d<double> >& points2,
00083 FMatrix& F)
00084 {
00085 FMatrixPlanar fplanar;
00086 fplanar.init(F);
00087 if (!compute_planar(points1, points2, fplanar))
00088 return false;
00089
00090
00091 F = fplanar;
00092 return true;
00093 }