MCPcopy Create free account
hub / github.com/KAlO2/PerfectShow / AlignMeanShapeToBothEyesEstMouth

Function AlignMeanShapeToBothEyesEstMouth

jni/stasm/startshape.cpp:156–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154// return the model meanshape aligned to both eyes (mouth is not avail)
155
156static Shape AlignMeanShapeToBothEyesEstMouth(
157 const DetectorParameter& detpar, // in
158 const Shape& meanshape) // in
159{
160 // .48 was tested to give slightly better worse case results than .50
161 static const double EYEMOUTH_TO_FACERECT_RATIO = .48;
162
163 if (trace_g)
164 lprintf("AlignToBothEyesEstMouth ");
165
166 CV_Assert(NSIZE(meanshape) > 0 && PointUsed(meanshape, 0));
167 CV_Assert(Valid(detpar.lex));
168 CV_Assert(Valid(detpar.rex));
169
170 // estimate the mouth's position
171
172 double x_eyemid = 0;
173 switch (detpar.eyaw)
174 {
175 case EYAW00: // mid point
176 x_eyemid = .50 * detpar.lex + .50 * detpar.rex;
177 break;
178 // TODO The constants below have not been empirically optimized.
179 case EYAW_45: // closer to left eye
180 x_eyemid = .30 * detpar.lex + .70 * detpar.rex;
181 break;
182 case EYAW_22: // closer to left eye
183 x_eyemid = .30 * detpar.lex + .70 * detpar.rex;
184 break;
185 case EYAW22: // closer to right eye
186 x_eyemid = .30 * detpar.lex + .70 * detpar.rex;
187 break;
188 case EYAW45: // closer to right eye
189 x_eyemid = .30 * detpar.lex + .70 * detpar.rex;
190 break;
191 default:
192 Err("AlignMeanShapeToBothEyesEstMouth: Invalid eyaw %d", detpar.eyaw);
193 break;
194 }
195 const double y_eyemid = (detpar.ley + detpar.rey) / 2;
196
197 Shape mean_tri(3, 2), det_tri(3, 2); // triangle of eyes and mouth
198
199 const Shape shape17(Shape17(meanshape));
200
201 mean_tri(0, IX) = shape17(L17_LPupil, IX); // left eye
202 mean_tri(0, IY) = shape17(L17_LPupil, IY);
203 mean_tri(1, IX) = shape17(L17_RPupil, IX); // right eye
204 mean_tri(1, IY) = shape17(L17_RPupil, IY);
205 mean_tri(2, IX) = shape17(L17_CBotOfBotLip, IX); // mouth
206 mean_tri(2, IY) = shape17(L17_CBotOfBotLip, IY);
207
208 det_tri(0, IX) = detpar.lex; // left eye
209 det_tri(0, IY) = detpar.ley;
210 det_tri(1, IX) = detpar.rex; // right eye
211 det_tri(1, IY) = detpar.rey;
212 det_tri(2, IX) = x_eyemid; // mouth
213 det_tri(2, IY) = y_eyemid + EYEMOUTH_TO_FACERECT_RATIO * detpar.width;

Callers 2

EstartEyesFunction · 0.85
EstartEyeMouthFunction · 0.85

Calls 8

lprintfFunction · 0.85
NSIZEFunction · 0.85
PointUsedFunction · 0.85
ValidFunction · 0.85
ErrFunction · 0.85
Shape17Function · 0.85
TransformShapeFunction · 0.85
AlignmentMatFunction · 0.85

Tested by

no test coverage detected