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

Function PinnedStartShapeAndRoi

jni/stasm/pinstart.cpp:251–292  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249// points. But the routine also works if any two or more points are pinned.
250
251void PinnedStartShapeAndRoi( // use the pinned landmarks to init the start shape
252 Shape& startshape, // out: the start shape (in ROI frame)
253 Image& face_roi, // out: ROI around face, possibly rotated upright
254 DetectorParameter& detpar_roi, // out: detpar wrt to face_roi
255 DetectorParameter& detpar, // out: detpar wrt to img
256 Shape& pinned_roi, // out: pinned arg translated to ROI frame
257 const Image& img, // in: the image (grayscale)
258 const vec_Mod& mods, // in: a vector of models, one for each yaw range
259 const Shape& pinned) // in: manually pinned landmarks
260{
261 double rot, yaw;
262 EstRotAndYawFrom5PointShape(rot, yaw,
263 Shape5(pinned, mods[0]->MeanShape_()));
264 const EYAW eyaw = DegreesAsEyaw(yaw, NSIZE(mods));
265 const int imod = EyawAsModIndex(eyaw, mods); // select ASM model based on yaw
266 if (trace_g)
267 lprintf("%-6.6s yaw %3.0f rot %3.0f ", EyawAsString(eyaw), yaw, rot);
268 pinned_roi = pinned; // use pinned_roi as a temp shape we can change
269 Image workimg(img); // possibly flipped image
270 if (IsLeftFacing(eyaw)) // left facing? (our models are for right facing faces)
271 {
272 pinned_roi = FlipShape(pinned_roi, workimg.cols);
273 FlipImgInPlace(workimg);
274 }
275 const Mod* mod = mods[ABS(imod)];
276 startshape = PinMeanShape(pinned_roi, mod->MeanShape_());
277 startshape = mod->ConformShapeToMod_Pinned_(startshape, pinned_roi);
278 detpar = PseudoDetParFromStartShape(startshape, rot, yaw, NSIZE(mods));
279 if (IsLeftFacing(eyaw))
280 detpar.rot *= -1;
281 FaceRoiAndDetectorParameter(face_roi, detpar_roi, workimg, detpar, false);
282 startshape = ImgShapeToRoiFrame(startshape, detpar_roi, detpar);
283 pinned_roi = ImgShapeToRoiFrame(pinned_roi, detpar_roi, detpar);
284 // following line not strictly necessary because don't actually need eyes/mouth
285 InitDetParEyeMouthFromShape(detpar_roi, startshape);
286 if (IsLeftFacing(eyaw))
287 {
288 detpar = FlipDetPar(detpar, img.cols);
289 detpar.rot = -detpar.rot;
290 detpar_roi.x += 2. * (face_roi.cols/2. - detpar_roi.x);
291 }
292}
293
294} // namespace stasm

Callers 1

stasm_search_pinnedFunction · 0.85

Calls 15

Shape5Function · 0.85
DegreesAsEyawFunction · 0.85
NSIZEFunction · 0.85
EyawAsModIndexFunction · 0.85
lprintfFunction · 0.85
EyawAsStringFunction · 0.85
IsLeftFacingFunction · 0.85
FlipShapeFunction · 0.85
FlipImgInPlaceFunction · 0.85
ABSFunction · 0.85
PinMeanShapeFunction · 0.85

Tested by

no test coverage detected