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

Function stasm_search_auto_ext

jni/stasm/stasm_lib.cpp:156–213  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154}
155
156int stasm_search_auto_ext( // extended version of stasm_search_auto
157 int* foundface, // out: 0=no more faces, 1=found face
158 float* landmarks, // out: x0, y0, x1, y1, ..., caller must allocate
159 float* estyaw) // out: NULL or pointer to estimated yaw
160{
161 int returnval = 1; // assume success
162 *foundface = 0; // but assume no face found
163 CatchOpenCvErrs();
164 try
165 {
166 CheckStasmInit();
167
168 if (img_g.rows == 0 || img_g.cols == 0)
169 Err("Image not open (missing call to stasm_open_image?)");
170
171 Shape shape; // the shape with landmarks
172 Image face_roi; // cropped to area around startshape and possibly rotated
173 DetectorParameter detpar_roi; // detpar translated to ROI frame
174 DetectorParameter detpar; // params returned by face det, in img frame
175
176 // Get the start shape for the next face in the image, and the ROI around it.
177 // The shape will be wrt the ROI frame.
178 if (NextStartShapeAndRoi(shape, face_roi, detpar_roi, detpar,
179 img_g, mods_g, facedet_g))
180 {
181 // now working with maybe flipped ROI and start shape in ROI frame
182 *foundface = 1;
183 if (trace_g) // show start shape?
184 LogShape(RoiShapeToImgFrame(shape, face_roi, detpar_roi, detpar),
185 "auto_start");
186
187 // select an ASM model based on the face's yaw
188 const int imod = ABS(EyawAsModIndex(detpar.eyaw, mods_g));
189
190 // do the actual ASM search
191 shape = mods_g[imod]->ModSearch_(shape, face_roi);
192#if TRACE_IMAGES
193 CImage cimg; cvtColor(face_roi, cimg, CV_GRAY2BGR); // color image
194 DrawShape(cimg, shape);
195 char s[SLEN]; sprintf(s, "%s_90_roishape.bmp", Base(imgpath_g));
196 lprintf("%s\n", s);
197 if (!cv::imwrite(s, cimg))
198 Err("Cannot write %s", s);
199#endif
200 shape = RoundMat(RoiShapeToImgFrame(shape, face_roi, detpar_roi, detpar));
201 // now working with non flipped start shape in image frame
202 ShapeToLandmarks(landmarks, shape);
203 if (estyaw)
204 *estyaw = float(detpar.yaw);
205 }
206 }
207 catch(...)
208 {
209 returnval = 0; // a call was made to Err or a CV_Assert failed
210 }
211 UncatchOpenCvErrs();
212 return returnval;
213}

Callers 1

stasm_search_autoFunction · 0.85

Calls 15

CatchOpenCvErrsFunction · 0.85
CheckStasmInitFunction · 0.85
ErrFunction · 0.85
NextStartShapeAndRoiFunction · 0.85
LogShapeFunction · 0.85
RoiShapeToImgFrameFunction · 0.85
ABSFunction · 0.85
EyawAsModIndexFunction · 0.85
DrawShapeFunction · 0.85
BaseFunction · 0.85
lprintfFunction · 0.85
RoundMatFunction · 0.85

Tested by

no test coverage detected