|
8 | 8 | #include <opencv2/core.hpp>
|
9 | 9 |
|
10 | 10 | namespace cv {
|
11 |
| - namespace ximgproc { |
| 11 | +namespace ximgproc { |
12 | 12 |
|
13 |
| - //! @addtogroup ximgproc_shape |
14 |
| - //! @{ |
| 13 | + //! @addtogroup ximgproc_fourier |
| 14 | + //! @{ |
15 | 15 |
|
16 |
| - /** @brief Class for ContourFitting algorithms. |
17 |
| - ContourFitting match two contours \f$ z_a \f$ and \f$ z_b \f$ minimizing distance |
18 |
| - \f[ d(z_a,z_b)=\sum (a_n - s b_n e^{j(n \alpha +\phi )})^2 \f] where \f$ a_n \f$ and \f$ b_n \f$ are Fourier descriptors of \f$ z_a \f$ and \f$ z_b \f$ and s is a scaling factor and \f$ \phi \f$ is angle rotation and \f$ \alpha \f$ is starting point factor adjustement |
19 |
| - */ |
20 |
| - class CV_EXPORTS_W ContourFitting : public Algorithm |
21 |
| - { |
22 |
| - int ctrSize; |
23 |
| - int fdSize; |
24 |
| - std::vector<std::complex<double> > b; |
25 |
| - std::vector<std::complex<double> > a; |
26 |
| - std::vector<double> frequence; |
27 |
| - std::vector<double> rho, psi; |
28 |
| - void frequencyInit(); |
29 |
| - void fAlpha(double x, double &fn, double &df); |
30 |
| - double distance(std::complex<double> r, double alpha); |
31 |
| - double newtonRaphson(double x1, double x2); |
32 |
| - public: |
33 |
| - /** @brief Fit two closed curves using fourier descriptors. More details in @cite PersoonFu1977 and @cite BergerRaghunathan1998 |
| 16 | + /** @brief Class for ContourFitting algorithms. |
| 17 | + ContourFitting match two contours \f$ z_a \f$ and \f$ z_b \f$ minimizing distance |
| 18 | + \f[ d(z_a,z_b)=\sum (a_n - s b_n e^{j(n \alpha +\phi )})^2 \f] where \f$ a_n \f$ and \f$ b_n \f$ are Fourier descriptors of \f$ z_a \f$ and \f$ z_b \f$ and s is a scaling factor and \f$ \phi \f$ is angle rotation and \f$ \alpha \f$ is starting point factor adjustement |
| 19 | + */ |
| 20 | + class CV_EXPORTS_W ContourFitting : public Algorithm |
| 21 | + { |
| 22 | + int ctrSize; |
| 23 | + int fdSize; |
| 24 | + std::vector<std::complex<double> > b; |
| 25 | + std::vector<std::complex<double> > a; |
| 26 | + std::vector<double> frequence; |
| 27 | + std::vector<double> rho, psi; |
| 28 | + void frequencyInit(); |
| 29 | + void fAlpha(double x, double &fn, double &df); |
| 30 | + double distance(std::complex<double> r, double alpha); |
| 31 | + double newtonRaphson(double x1, double x2); |
| 32 | + public: |
| 33 | + /** @brief Fit two closed curves using fourier descriptors. More details in @cite PersoonFu1977 and @cite BergerRaghunathan1998 |
34 | 34 |
|
35 |
| - * @param ctr number of Fourier descriptors equal to number of contour points after resampling. |
36 |
| - * @param fd Contour defining second shape (Target). |
37 |
| - */ |
38 |
| - ContourFitting(int ctr=1024,int fd=16):ctrSize(ctr),fdSize(fd){}; |
39 |
| - /** @brief Fit two closed curves using fourier descriptors. More details in @cite PersoonFu1977 and @cite BergerRaghunathan1998 |
| 35 | + * @param ctr number of Fourier descriptors equal to number of contour points after resampling. |
| 36 | + * @param fd Contour defining second shape (Target). |
| 37 | + */ |
| 38 | + ContourFitting(int ctr=1024,int fd=16):ctrSize(ctr),fdSize(fd){}; |
| 39 | + /** @brief Fit two closed curves using fourier descriptors. More details in @cite PersoonFu1977 and @cite BergerRaghunathan1998 |
40 | 40 |
|
41 |
| - @param src Contour defining first shape. |
42 |
| - @param dst Contour defining second shape (Target). |
43 |
| - @param _alphaPhiST : \f$ \alpha \f$=_alphaPhiST(0,0), \f$ \phi \f$=_alphaPhiST(0,1) (in radian), s=_alphaPhiST(0,2), Tx=_alphaPhiST(0,3), Ty=_alphaPhiST(0,4) rotation center |
44 |
| - @param dist distance between src and dst after matching. |
45 |
| - @param fdContour false then src and dst are contours and true src and dst are fourier descriptors. |
46 |
| - */ |
47 |
| - CV_WRAP void estimateTransformation(InputArray src, InputArray dst, OutputArray _alphaPhiST, double *dist = 0, bool fdContour = false); |
48 |
| - /** @brief Fit two closed curves using fourier descriptors. More details in @cite PersoonFu1977 and @cite BergerRaghunathan1998 |
| 41 | + @param src Contour defining first shape. |
| 42 | + @param dst Contour defining second shape (Target). |
| 43 | + @param alphaPhiST : \f$ \alpha \f$=alphaPhiST(0,0), \f$ \phi \f$=alphaPhiST(0,1) (in radian), s=alphaPhiST(0,2), Tx=alphaPhiST(0,3), Ty=alphaPhiST(0,4) rotation center |
| 44 | + @param dist distance between src and dst after matching. |
| 45 | + @param fdContour false then src and dst are contours and true src and dst are fourier descriptors. |
| 46 | + */ |
| 47 | + CV_WRAP void estimateTransformation(InputArray src, InputArray dst, OutputArray alphaPhiST, double *dist = 0, bool fdContour = false); |
| 48 | + /** @brief Fit two closed curves using fourier descriptors. More details in @cite PersoonFu1977 and @cite BergerRaghunathan1998 |
49 | 49 |
|
50 |
| - @param src Contour defining first shape. |
51 |
| - @param dst Contour defining second shape (Target). |
52 |
| - @param _alphaPhiST : \f$ \alpha \f$=_alphaPhiST(0,0), \f$ \phi \f$=_alphaPhiST(0,1) (in radian), s=_alphaPhiST(0,2), Tx=_alphaPhiST(0,3), Ty=_alphaPhiST(0,4) rotation center |
53 |
| - @param dist distance between src and dst after matching. |
54 |
| - @param fdContour false then src and dst are contours and true src and dst are fourier descriptors. |
55 |
| - */ |
56 |
| - CV_WRAP void estimateTransformation(InputArray src, InputArray dst, OutputArray _alphaPhiST, double &dist , bool fdContour = false); |
57 |
| - /** @brief set number of Fourier descriptors used in estimateTransformation |
| 50 | + @param src Contour defining first shape. |
| 51 | + @param dst Contour defining second shape (Target). |
| 52 | + @param alphaPhiST : \f$ \alpha \f$=alphaPhiST(0,0), \f$ \phi \f$=alphaPhiST(0,1) (in radian), s=alphaPhiST(0,2), Tx=alphaPhiST(0,3), Ty=alphaPhiST(0,4) rotation center |
| 53 | + @param dist distance between src and dst after matching. |
| 54 | + @param fdContour false then src and dst are contours and true src and dst are fourier descriptors. |
| 55 | + */ |
| 56 | + CV_WRAP void estimateTransformation(InputArray src, InputArray dst, OutputArray alphaPhiST, double &dist , bool fdContour = false); |
| 57 | + /** @brief set number of Fourier descriptors used in estimateTransformation |
58 | 58 |
|
59 |
| - @param n number of Fourier descriptors equal to number of contour points after resampling. |
60 |
| - */ |
61 |
| - CV_WRAP void setCtrSize(int n); |
62 |
| - /** @brief set number of Fourier descriptors when estimateTransformation used vector<Point> |
| 59 | + @param n number of Fourier descriptors equal to number of contour points after resampling. |
| 60 | + */ |
| 61 | + CV_WRAP void setCtrSize(int n); |
| 62 | + /** @brief set number of Fourier descriptors when estimateTransformation used vector<Point> |
63 | 63 |
|
64 |
| - @param n number of fourier descriptors used for optimal curve matching. |
65 |
| - */ |
66 |
| - CV_WRAP void setFDSize(int n); |
67 |
| - /** |
68 |
| - @returns number of fourier descriptors |
69 |
| - */ |
70 |
| - CV_WRAP int getCtrSize() { return ctrSize; }; |
71 |
| - /** |
72 |
| - @returns number of fourier descriptors used for optimal curve matching |
73 |
| - */ |
74 |
| - CV_WRAP int getFDSize() { return fdSize; }; |
75 |
| - }; |
76 |
| - /** |
77 |
| - * @brief Fourier descriptors for planed closed curves |
78 |
| - * |
79 |
| - * For more details about this implementation, please see @cite PersoonFu1977 |
80 |
| - * |
81 |
| - * @param _src contour type vector<Point> , vector<Point2f> or vector<Point2d> |
82 |
| - * @param _dst Mat of type CV_64FC2 and nbElt rows A VERIFIER |
83 |
| - * @param nbElt number of rows in _dst or getOptimalDFTSize rows if nbElt=-1 |
84 |
| - * @param nbFD number of FD return in _dst _dst = [FD(1...nbFD/2) FD(nbFD/2-nbElt+1...:nbElt)] |
85 |
| - * |
| 64 | + @param n number of fourier descriptors used for optimal curve matching. |
86 | 65 | */
|
87 |
| - CV_EXPORTS_W void fourierDescriptor(InputArray _src, OutputArray _dst, int nbElt=-1,int nbFD=-1); |
| 66 | + CV_WRAP void setFDSize(int n); |
88 | 67 | /**
|
89 |
| - * @brief transform a contour |
90 |
| - * |
91 |
| - * @param _src contour or Fourier Descriptors if fd is true |
92 |
| - * @param _t transform Mat given by estimateTransformation |
93 |
| - * @param _dst Mat of type CV_64FC2 and nbElt rows |
94 |
| - * @param fdContour true _src are Fourier Descriptors. fdContour false _src is a contour |
95 |
| - * |
| 68 | + @returns number of fourier descriptors |
96 | 69 | */
|
97 |
| - CV_EXPORTS_W void transform(InputArray _src, InputArray _t,OutputArray _dst, bool fdContour=true); |
| 70 | + CV_WRAP int getCtrSize() { return ctrSize; }; |
98 | 71 | /**
|
99 |
| - * @brief Contour sampling . |
100 |
| - * |
101 |
| - * @param _src contour type vector<Point> , vector<Point2f> or vector<Point2d> |
102 |
| - * @param _out Mat of type CV_64FC2 and nbElt rows |
103 |
| - * @param nbElt number of points in _out contour |
104 |
| - * |
| 72 | + @returns number of fourier descriptors used for optimal curve matching |
105 | 73 | */
|
106 |
| - CV_EXPORTS_W void contourSampling(InputArray _src, OutputArray _out, int nbElt); |
| 74 | + CV_WRAP int getFDSize() { return fdSize; }; |
| 75 | + }; |
| 76 | + /** |
| 77 | + * @brief Fourier descriptors for planed closed curves |
| 78 | + * |
| 79 | + * For more details about this implementation, please see @cite PersoonFu1977 |
| 80 | + * |
| 81 | + * @param src contour type vector<Point> , vector<Point2f> or vector<Point2d> |
| 82 | + * @param dst Mat of type CV_64FC2 and nbElt rows A VERIFIER |
| 83 | + * @param nbElt number of rows in dst or getOptimalDFTSize rows if nbElt=-1 |
| 84 | + * @param nbFD number of FD return in dst dst = [FD(1...nbFD/2) FD(nbFD/2-nbElt+1...:nbElt)] |
| 85 | + * |
| 86 | + */ |
| 87 | + CV_EXPORTS_W void fourierDescriptor(InputArray src, OutputArray dst, int nbElt=-1,int nbFD=-1); |
| 88 | + /** |
| 89 | + * @brief transform a contour |
| 90 | + * |
| 91 | + * @param src contour or Fourier Descriptors if fd is true |
| 92 | + * @param t transform Mat given by estimateTransformation |
| 93 | + * @param dst Mat of type CV_64FC2 and nbElt rows |
| 94 | + * @param fdContour true src are Fourier Descriptors. fdContour false src is a contour |
| 95 | + * |
| 96 | + */ |
| 97 | + CV_EXPORTS_W void transform(InputArray src, InputArray t,OutputArray dst, bool fdContour=true); |
| 98 | + /** |
| 99 | + * @brief Contour sampling . |
| 100 | + * |
| 101 | + * @param src contour type vector<Point> , vector<Point2f> or vector<Point2d> |
| 102 | + * @param out Mat of type CV_64FC2 and nbElt rows |
| 103 | + * @param nbElt number of points in out contour |
| 104 | + * |
| 105 | + */ |
| 106 | + CV_EXPORTS_W void contourSampling(InputArray src, OutputArray out, int nbElt); |
107 | 107 |
|
108 |
| - /** |
109 |
| - * @brief create |
| 108 | + /** |
| 109 | + * @brief create |
110 | 110 |
|
111 |
| - * @param ctr number of Fourier descriptors equal to number of contour points after resampling. |
112 |
| - * @param fd Contour defining second shape (Target). |
113 |
| - */ |
114 |
| - CV_EXPORTS_W Ptr<ContourFitting> create(int ctr = 1024, int fd = 16); |
| 111 | + * @param ctr number of Fourier descriptors equal to number of contour points after resampling. |
| 112 | + * @param fd Contour defining second shape (Target). |
| 113 | + */ |
| 114 | + CV_EXPORTS_W Ptr<ContourFitting> create(int ctr = 1024, int fd = 16); |
115 | 115 |
|
116 |
| - //! @} ximgproc_shape |
117 |
| - } |
| 116 | + //! @} ximgproc_fourier |
| 117 | +} |
118 | 118 | }
|
119 | 119 | #endif
|
0 commit comments