Skip to content

Commit 8b733e0

Browse files
committed
review
1 parent c17fd6e commit 8b733e0

File tree

4 files changed

+96
-100
lines changed

4 files changed

+96
-100
lines changed

modules/ximgproc/include/opencv2/ximgproc.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ i.e. algorithms which somehow takes into account pixel affinities in natural ima
7070
7171
@defgroup ximgproc_fast_line_detector Fast line detector
7272
73-
@defgroup ximgproc_shape Fourier descriptors
73+
@defgroup ximgproc_fourier Fourier descriptors
7474
@}
7575
*/
7676

modules/ximgproc/include/opencv2/ximgproc/fourier_descriptors.hpp

Lines changed: 92 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -8,112 +8,112 @@
88
#include <opencv2/core.hpp>
99

1010
namespace cv {
11-
namespace ximgproc {
11+
namespace ximgproc {
1212

13-
//! @addtogroup ximgproc_shape
14-
//! @{
13+
//! @addtogroup ximgproc_fourier
14+
//! @{
1515

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
3434
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
4040
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
4949
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
5858
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>
6363
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.
8665
*/
87-
CV_EXPORTS_W void fourierDescriptor(InputArray _src, OutputArray _dst, int nbElt=-1,int nbFD=-1);
66+
CV_WRAP void setFDSize(int n);
8867
/**
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
9669
*/
97-
CV_EXPORTS_W void transform(InputArray _src, InputArray _t,OutputArray _dst, bool fdContour=true);
70+
CV_WRAP int getCtrSize() { return ctrSize; };
9871
/**
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
10573
*/
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);
107107

108-
/**
109-
* @brief create
108+
/**
109+
* @brief create
110110
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);
115115

116-
//! @} ximgproc_shape
117-
}
116+
//! @} ximgproc_fourier
117+
}
118118
}
119119
#endif

modules/ximgproc/samples/fourier_descriptors_demo.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
// This file is part of OpenCV project.
2-
// It is subject to the license terms in the LICENSE file found in the top-level directory
3-
// of this distribution and at http://opencv.org/license.html.
4-
51
#include <opencv2/core.hpp>
62
#include <opencv2/core/utility.hpp>
73
#include <opencv2/highgui.hpp>
@@ -58,10 +54,10 @@ int main(void)
5854
double dist;
5955
vector<vector<Point> > c;
6056
Mat img;
61-
cout << "******************** PRESS G TO MATCH CURVES *************\n";
57+
cout << "******************** PRESS g TO MATCH CURVES *************\n";
6258
do
6359
{
64-
code = waitKey(30)&0xFF;
60+
code = waitKey(30);
6561
if (p.update)
6662
{
6763
Mat r = getRotationMatrix2D(Point(p.xg, p.yg), p.angle, 10.0/ p.scale10);

modules/ximgproc/src/fourier_descriptors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Coalescence in 2 dimensions: experiments on thin copolymer films and numerical s
1313
*/
1414

1515
namespace cv {
16-
namespace ximgproc {
16+
namespace ximgproc {
1717

1818

1919
void ContourFitting::setCtrSize(int n)

0 commit comments

Comments
 (0)