Skip to content

Commit 4a06631

Browse files
committed
Merge pull request #1428 from alalek:pr1257_refactoring
2 parents 1f8ccc1 + e310fc5 commit 4a06631

File tree

14 files changed

+3294
-3664
lines changed

14 files changed

+3294
-3664
lines changed

modules/face/include/opencv2/face/facemark.hpp

Lines changed: 328 additions & 355 deletions
Large diffs are not rendered by default.

modules/face/include/opencv2/face/facemarkAAM.hpp

Lines changed: 100 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,9 @@
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+
15
/*
2-
By downloading, copying, installing or using the software you agree to this
3-
license. If you do not agree to this license, do not download, install,
4-
copy or use the software.
5-
License Agreement
6-
For Open Source Computer Vision Library
7-
(3-clause BSD License)
8-
Copyright (C) 2013, OpenCV Foundation, all rights reserved.
9-
Third party copyrights are property of their respective owners.
10-
Redistribution and use in source and binary forms, with or without modification,
11-
are permitted provided that the following conditions are met:
12-
* Redistributions of source code must retain the above copyright notice,
13-
this list of conditions and the following disclaimer.
14-
* Redistributions in binary form must reproduce the above copyright notice,
15-
this list of conditions and the following disclaimer in the documentation
16-
and/or other materials provided with the distribution.
17-
* Neither the names of the copyright holders nor the names of the contributors
18-
may be used to endorse or promote products derived from this software
19-
without specific prior written permission.
20-
This software is provided by the copyright holders and contributors "as is" and
21-
any express or implied warranties, including, but not limited to, the implied
22-
warranties of merchantability and fitness for a particular purpose are
23-
disclaimed. In no event shall copyright holders or contributors be liable for
24-
any direct, indirect, incidental, special, exemplary, or consequential damages
25-
(including, but not limited to, procurement of substitute goods or services;
26-
loss of use, data, or profits; or business interruption) however caused
27-
and on any theory of liability, whether in contract, strict liability,
28-
or tort (including negligence or otherwise) arising in any way out of
29-
the use of this software, even if advised of the possibility of such damage.
30-
31-
This file was part of GSoC Project: Facemark API for OpenCV
6+
This file contains results of GSoC Project: Facemark API for OpenCV
327
Final report: https://gist.github.com/kurnianggoro/74de9121e122ad0bd825176751d47ecc
338
Student: Laksono Kurnianggoro
349
Mentor: Delia Passalacqua
@@ -44,114 +19,114 @@ namespace face {
4419
//! @addtogroup face
4520
//! @{
4621

47-
class CV_EXPORTS_W FacemarkAAM : public Facemark
22+
class CV_EXPORTS_W FacemarkAAM : public Facemark
23+
{
24+
public:
25+
struct CV_EXPORTS Params
4826
{
49-
public:
50-
struct CV_EXPORTS Params
51-
{
52-
/**
53-
* \brief Constructor
54-
*/
55-
Params();
56-
57-
/**
58-
* \brief Read parameters from file, currently unused
59-
*/
60-
void read(const FileNode& /*fn*/);
61-
62-
/**
63-
* \brief Read parameters from file, currently unused
64-
*/
65-
void write(FileStorage& /*fs*/) const;
66-
67-
std::string model_filename;
68-
int m;
69-
int n;
70-
int n_iter;
71-
bool verbose;
72-
bool save_model;
73-
int max_m, max_n, texture_max_m;
74-
std::vector<float>scales;
75-
};
76-
7727
/**
78-
* \brief Optional parameter for fitting process.
28+
* \brief Constructor
7929
*/
80-
struct CV_EXPORTS Config
81-
{
82-
Config( Mat rot = Mat::eye(2,2,CV_32F),
83-
Point2f trans = Point2f(0.0,0.0),
84-
float scaling = 1.0,
85-
int scale_id=0
86-
);
87-
88-
Mat R;
89-
Point2f t;
90-
float scale;
91-
int model_scale_idx;
92-
93-
};
30+
Params();
9431

9532
/**
96-
* \brief Data container for the facemark::getData function
33+
* \brief Read parameters from file, currently unused
9734
*/
98-
struct CV_EXPORTS Data
99-
{
100-
std::vector<Point2f> s0;
101-
};
35+
void read(const FileNode& /*fn*/);
10236

10337
/**
104-
* \brief The model of AAM Algorithm
38+
* \brief Read parameters from file, currently unused
10539
*/
106-
struct CV_EXPORTS Model
107-
{
108-
int npts; //!< unused delete
109-
int max_n; //!< unused delete
110-
std::vector<float>scales;
111-
//!< defines the scales considered to build the model
112-
113-
/*warping*/
114-
std::vector<Vec3i> triangles;
115-
//!< each element contains 3 values, represent index of facemarks that construct one triangle (obtained using delaunay triangulation)
116-
117-
struct Texture{
118-
int max_m; //!< unused delete
119-
Rect resolution;
120-
//!< resolution of the current scale
121-
Mat A;
122-
//!< gray values from all face region in the dataset, projected in PCA space
123-
Mat A0;
124-
//!< average of gray values from all face region in the dataset
125-
Mat AA;
126-
//!< gray values from all erorded face region in the dataset, projected in PCA space
127-
Mat AA0;
128-
//!< average of gray values from all erorded face region in the dataset
129-
130-
std::vector<std::vector<Point> > textureIdx;
131-
//!< index for warping of each delaunay triangle region constructed by 3 facemarks
132-
std::vector<Point2f> base_shape;
133-
//!< basic shape, normalized to be fit in an image with current detection resolution
134-
std::vector<int> ind1;
135-
//!< index of pixels for mapping process to obtains the grays values of face region
136-
std::vector<int> ind2;
137-
//!< index of pixels for mapping process to obtains the grays values of eroded face region
138-
};
139-
std::vector<Texture> textures;
140-
//!< a container to holds the texture data for each scale of fitting
141-
142-
/*shape*/
143-
std::vector<Point2f> s0;
144-
//!< the basic shape obtained from training dataset
145-
Mat S,Q;
146-
//!< the encoded shapes from training data
40+
void write(FileStorage& /*fs*/) const;
41+
42+
std::string model_filename;
43+
int m;
44+
int n;
45+
int n_iter;
46+
bool verbose;
47+
bool save_model;
48+
int max_m, max_n, texture_max_m;
49+
std::vector<float>scales;
50+
};
51+
52+
/**
53+
* \brief Optional parameter for fitting process.
54+
*/
55+
struct CV_EXPORTS Config
56+
{
57+
Config( Mat rot = Mat::eye(2,2,CV_32F),
58+
Point2f trans = Point2f(0.0f,0.0f),
59+
float scaling = 1.0f,
60+
int scale_id=0
61+
);
62+
63+
Mat R;
64+
Point2f t;
65+
float scale;
66+
int model_scale_idx;
67+
68+
};
69+
70+
/**
71+
* \brief Data container for the facemark::getData function
72+
*/
73+
struct CV_EXPORTS Data
74+
{
75+
std::vector<Point2f> s0;
76+
};
14777

78+
/**
79+
* \brief The model of AAM Algorithm
80+
*/
81+
struct CV_EXPORTS Model
82+
{
83+
int npts; //!< unused delete
84+
int max_n; //!< unused delete
85+
std::vector<float>scales;
86+
//!< defines the scales considered to build the model
87+
88+
/*warping*/
89+
std::vector<Vec3i> triangles;
90+
//!< each element contains 3 values, represent index of facemarks that construct one triangle (obtained using delaunay triangulation)
91+
92+
struct Texture{
93+
int max_m; //!< unused delete
94+
Rect resolution;
95+
//!< resolution of the current scale
96+
Mat A;
97+
//!< gray values from all face region in the dataset, projected in PCA space
98+
Mat A0;
99+
//!< average of gray values from all face region in the dataset
100+
Mat AA;
101+
//!< gray values from all erorded face region in the dataset, projected in PCA space
102+
Mat AA0;
103+
//!< average of gray values from all erorded face region in the dataset
104+
105+
std::vector<std::vector<Point> > textureIdx;
106+
//!< index for warping of each delaunay triangle region constructed by 3 facemarks
107+
std::vector<Point2f> base_shape;
108+
//!< basic shape, normalized to be fit in an image with current detection resolution
109+
std::vector<int> ind1;
110+
//!< index of pixels for mapping process to obtains the grays values of face region
111+
std::vector<int> ind2;
112+
//!< index of pixels for mapping process to obtains the grays values of eroded face region
148113
};
114+
std::vector<Texture> textures;
115+
//!< a container to holds the texture data for each scale of fitting
116+
117+
/*shape*/
118+
std::vector<Point2f> s0;
119+
//!< the basic shape obtained from training dataset
120+
Mat S,Q;
121+
//!< the encoded shapes from training data
122+
123+
};
149124

150-
//!< initializer
151-
static Ptr<FacemarkAAM> create(const FacemarkAAM::Params &parameters = FacemarkAAM::Params() );
152-
virtual ~FacemarkAAM() {}
125+
//!< initializer
126+
static Ptr<FacemarkAAM> create(const FacemarkAAM::Params &parameters = FacemarkAAM::Params() );
127+
virtual ~FacemarkAAM() {}
153128

154-
}; /* AAM */
129+
}; /* AAM */
155130

156131
//! @}
157132

0 commit comments

Comments
 (0)