OpenCV 4.5.3(日本語機械翻訳)
facemarkAAM.hpp
1 /*
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
32 Final report: https://gist.github.com/kurnianggoro/74de9121e122ad0bd825176751d47ecc
33 Student: Laksono Kurnianggoro
34 Mentor: Delia Passalacqua
35 */
36
37 #ifndef __OPENCV_FACEMARK_AAM_HPP__
38 #define __OPENCV_FACEMARK_AAM_HPP__
39
40 #include "opencv2/face/facemark_train.hpp"
41 namespace cv {
42 namespace face {
43
46
47 class CV_EXPORTS_W FacemarkAAM : public FacemarkTrain
48{
49 public:
50 struct CV_EXPORTS Params
51 {
56
60 void read(const FileNode& /*fn*/);
61
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
80 struct CV_EXPORTS Config
81 {
82 Config( Mat rot = Mat::eye(2,2,CV_32F),
83 Point2f trans = Point2f(0.0f, 0.0f),
84 float scaling = 1.0f,
85 int scale_id=0
86 );
87
88 Mat R;
89 Point2f t;
90 float scale;
91 int model_scale_idx;
92
93 };
94
98 struct CV_EXPORTS Data
99 {
100 std::vector<Point2f> s0;
101 };
102
106 struct CV_EXPORTS Model
107 {
108 std::vector<float>scales;
110
111 /*warping*/
112 std::vector<Vec3i> triangles;
114
115 struct Texture{
116 int max_m;
127
128 std::vector<std::vector<Point> > textureIdx;
130 std::vector<Point2f> base_shape;
132 std::vector<int> ind1;
134 std::vector<int> ind2;
136 };
137 std::vector<Texture> textures;
139
140 /*shape*/
141 std::vector<Point2f> s0;
145
146 };
147
149 virtual bool fitConfig( InputArray image, InputArray roi, OutputArrayOfArrays _landmarks, const std::vector<Config> &runtime_params ) = 0;
150
151
154 virtual ~FacemarkAAM() {}
155
156}; /* AAM */
157
159
160} /* namespace face */
161} /* namespace cv */
162 #endif
This type is very similar to InputArray except that it is used for input/output and output function p...
Definition: mat.hpp:295
File Storage Node class.
Definition: persistence.hpp:482
XML/YAML/JSON file storage class that encapsulates all the information necessary for writing or readi...
Definition: persistence.hpp:304
n-dimensional dense array class
Definition: mat.hpp:802
static MatExpr eye(int rows, int cols, int type)
Returns an identity matrix of the specified size and type.
Template class for 2D rectangles
Definition: core/types.hpp:421
Definition: facemarkAAM.hpp:48
virtual bool fitConfig(InputArray image, InputArray roi, OutputArrayOfArrays _landmarks, const std::vector< Config > &runtime_params)=0
overload with additional Config structures
static Ptr< FacemarkAAM > create(const FacemarkAAM::Params &parameters=FacemarkAAM::Params())
initializer
Abstract base class for trainable facemark models
Definition: facemark_train.hpp:263
cv
"black box" representation of the file storage associated with a file on disk.
Definition: aruco.hpp:75
Definition: cvstd_wrapper.hpp:74
Optional parameter for fitting process.
Definition: facemarkAAM.hpp:81
Data container for the facemark::getData function
Definition: facemarkAAM.hpp:99
Definition: facemarkAAM.hpp:115
std::vector< Point2f > base_shape
basic shape, normalized to be fit in an image with current detection resolution
Definition: facemarkAAM.hpp:130
Mat AA0
average of gray values from all erorded face region in the dataset
Definition: facemarkAAM.hpp:125
Mat A0
average of gray values from all face region in the dataset
Definition: facemarkAAM.hpp:121
Rect resolution
resolution of the current scale
Definition: facemarkAAM.hpp:117
Mat AA
gray values from all erorded face region in the dataset, projected in PCA space
Definition: facemarkAAM.hpp:123
std::vector< int > ind2
index of pixels for mapping process to obtains the grays values of eroded face region
Definition: facemarkAAM.hpp:134
std::vector< std::vector< Point > > textureIdx
index for warping of each delaunay triangle region constructed by 3 facemarks
Definition: facemarkAAM.hpp:128
std::vector< int > ind1
index of pixels for mapping process to obtains the grays values of face region
Definition: facemarkAAM.hpp:132
Mat A
gray values from all face region in the dataset, projected in PCA space
Definition: facemarkAAM.hpp:119
int max_m
unused delete
Definition: facemarkAAM.hpp:116
The model of AAM Algorithm
Definition: facemarkAAM.hpp:107
std::vector< Vec3i > triangles
each element contains 3 values, represent index of facemarks that construct one triangle (obtained us...
Definition: facemarkAAM.hpp:112
std::vector< float > scales
defines the scales considered to build the model
Definition: facemarkAAM.hpp:108
std::vector< Point2f > s0
the basic shape obtained from training dataset
Definition: facemarkAAM.hpp:141
Mat Q
the encoded shapes from training data
Definition: facemarkAAM.hpp:143
std::vector< Texture > textures
a container to holds the texture data for each scale of fitting
Definition: facemarkAAM.hpp:137
Definition: facemarkAAM.hpp:51
void read(const FileNode &)
Read parameters from file, currently unused
void write(FileStorage &) const
Read parameters from file, currently unused