00001 #include "HMatrix2DCompute.h"
00002
00003 #include <vcl_cstdlib.h>
00004 #include <vcl_iostream.h>
00005
00006 #include <mvl/HMatrix2D.h>
00007 #include <mvl/PairMatchSetCorner.h>
00008 #include <vcl_vector.h>
00009
00010 bool
00011 HMatrix2DCompute::compute_p(PointArray const&p1,
00012 PointArray const&p2,
00013 HMatrix2D * H)
00014 {
00015 LineArray empty;
00016 return compute_pl(p1, p2, empty, empty, H);
00017 }
00018
00019 bool
00020 HMatrix2DCompute::compute_l(LineArray const&l1,
00021 LineArray const&l2,
00022 HMatrix2D * H)
00023 {
00024 PointArray empty;
00025 return compute_pl(empty, empty, l1, l2, H);
00026 }
00027
00028 bool
00029 HMatrix2DCompute::compute_pl(PointArray const&,
00030 PointArray const&,
00031 LineArray const&,
00032 LineArray const&,
00033 HMatrix2D *)
00034 {
00035 vcl_cerr << vcl_endl;
00036 vcl_cerr << "HMatrix2DCompute::compute_pl() :" << vcl_endl;
00037 vcl_cerr << "This is a virtual method which should have been" << vcl_endl;
00038 vcl_cerr << "overridden by a class derived from HMatrix2DCompute." << vcl_endl;
00039 vcl_cerr << "The derived class may have omitted to implement" << vcl_endl;
00040 vcl_cerr << "enough of the methods compute_p(),compute_l() and" << vcl_endl;
00041 vcl_cerr << "compute_pl()." << vcl_endl;
00042 vcl_abort();
00043 return false;
00044 }
00045
00046
00047
00048
00049
00050
00051
00052 bool
00053 HMatrix2DCompute::compute(PointArray const&p1,
00054 PointArray const&p2,
00055 HMatrix2D * H)
00056 {
00057 return compute_p(p1, p2, H);
00058 }
00059
00060 HMatrix2D
00061 HMatrix2DCompute::compute(PointArray const&p1,
00062 PointArray const&p2)
00063 {
00064 HMatrix2D H;
00065 compute_p(p1, p2, &H);
00066 return H;
00067 }
00068
00069
00070
00071 bool
00072 HMatrix2DCompute::compute(LineArray const&l1,
00073 LineArray const&l2,
00074 HMatrix2D * H)
00075 {
00076 return compute_l(l1, l2, H);
00077 }
00078
00079 HMatrix2D
00080 HMatrix2DCompute::compute(LineArray const&l1,
00081 LineArray const&l2)
00082 {
00083 HMatrix2D H;
00084 compute_l(l1, l2, &H);
00085 return H;
00086 }
00087
00088
00089
00090 bool
00091 HMatrix2DCompute::compute(PointArray const&p1,
00092 PointArray const&p2,
00093 LineArray const&l1,
00094 LineArray const&l2,
00095 HMatrix2D*H)
00096 {
00097 return compute_pl(p1, p2, l1, l2, H);
00098 }
00099
00100 HMatrix2D
00101 HMatrix2DCompute::compute(PointArray const&p1,
00102 PointArray const&p2,
00103 LineArray const&l1,
00104 LineArray const &l2)
00105 {
00106 HMatrix2D H;
00107 compute_pl(p1, p2, l1, l2, &H);
00108 return H;
00109 }
00110
00111
00112
00113 bool
00114 HMatrix2DCompute::compute(PairMatchSetCorner const &matches,
00115 HMatrix2D *H)
00116 {
00117 vcl_vector<HomgPoint2D> pts1(matches.count());
00118 vcl_vector<HomgPoint2D> pts2(matches.count());
00119 matches.extract_matches(pts1, pts2);
00120 return compute(pts1, pts2, H);
00121 }
00122
00123 HMatrix2D
00124 HMatrix2DCompute::compute(PairMatchSetCorner const &matches)
00125 {
00126 HMatrix2D H;
00127 compute(matches, &H);
00128 return H;
00129 }