bazar  1.3.1
affinity.h
Go to the documentation of this file.
1 /*
2 Copyright 2005, 2006 Computer Vision Lab,
3 Ecole Polytechnique Federale de Lausanne (EPFL), Switzerland.
4 All rights reserved.
5 
6 This file is part of BazAR.
7 
8 BazAR is free software; you can redistribute it and/or modify it under the
9 terms of the GNU General Public License as published by the Free Software
10 Foundation; either version 2 of the License, or (at your option) any later
11 version.
12 
13 BazAR is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15 PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License along with
18 BazAR; if not, write to the Free Software Foundation, Inc., 51 Franklin
19 Street, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21 #ifndef AFFINITY_H
22 #define AFFINITY_H
23 
24 #include <iostream>
25 #include <assert.h>
26 #include <cv.h>
27 
28 using namespace std;
29 
33 class affinity : public CvMat
34 {
35 public:
36  affinity(void);
37  affinity(float u1, float v1, float up1, float vp1,
38  float u2, float v2, float up2, float vp2,
39  float u3, float v3, float up3, float vp3);
40 
41  ~affinity();
42 
43  bool estimate(float u1, float v1, float up1, float vp1,
44  float u2, float v2, float up2, float vp2,
45  float u3, float v3, float up3, float vp3);
46 
47  void transform_point(float u, float v, float * up, float * vp);
48  void transform_point(double u, double v, double * up, double * vp);
49 
50  void compute_cvGetQuandrangleSubPix_transform(CvMat * A_quadrangle, int width, int height);
51 
52  friend ostream& operator<< (ostream& o, const affinity& A);
53 
54  float cvmGet(const int i, const int j);
55  void cvmSet(const int i, const int j, const float val);
56  void cvmSet(const int i, const int j, const double val);
57 
58  friend float cvmGet(const affinity * A, const int i, const int j);
59  friend void cvmSet(const affinity * A, const int i, const int j, const float val);
60  friend void cvmSet(const affinity * A, const int i, const int j, const double val);
61  friend void mcvGetQuadrangleSubPix(IplImage * src, IplImage * dest, affinity * A,
62  int fill_outliers = 0, CvScalar fill_value = cvScalarAll(0));
63 
64 private:
65  void initialize(void);
66  CvMat * AA, * B, * X;
67 };
68 
69 ostream& operator<< (ostream& o, const affinity& A);
70 
71 inline float affinity::cvmGet(const int i, const int j)
72 {
73  return data.fl[3 * i + j];
74 }
75 
76 inline void affinity::cvmSet(const int i, const int j, const float val)
77 {
78  data.fl[3 * i + j] = val;
79 }
80 
81 inline void affinity::cvmSet(const int i, const int j, const double val)
82 {
83  data.fl[3 * i + j] = (float)val;
84 }
85 
86 inline float cvmGet(const affinity * A, const int i, const int j)
87 {
88  assert (A->rows == 3 && A->cols == 3);
89 
90  return A->data.fl[3 * i + j];
91 }
92 
93 inline void cvmSet(const affinity * A, const int i, const int j, const float val)
94 {
95  assert (A->rows == 3 && A->cols == 3);
96 
97  A->data.fl[3 * i + j] = val;
98 }
99 
100 inline void cvmSet(const affinity * A, const int i, const int j, const double val)
101 {
102  assert (A->rows == 3 && A->cols == 3);
103 
104  A->data.fl[3 * i + j] = (float)val;
105 }
106 
108 void mcvGetQuadrangleSubPix(IplImage * src, IplImage * dest, affinity * A,
109  int fill_outliers, CvScalar fill_value);
110 
111 #endif // AFFINITY_H