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

Function TraceShape

jni/stasm/asm.cpp:11–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9namespace stasm
10{
11static void TraceShape( // write an image file showing current shape on the image
12 const Shape& shape, // in: current search shape
13 const Image& pyrimg, // in: image scaled to this pyramid level
14 int ilev, // in: pyramid level (0 is full size)
15 int iter, // in: model iteration (-1 if start shape)
16 const char* suffix) // in
17{
18#if TRACE_IMAGES // will be 0 unless debugging (defined in stasm.h)
19
20 static int index; // number images so they appear in order in the directory
21 // start at index 30 because lower indices have already used for facedet etc.
22 if (strcmp(suffix, "start") == 0)
23 index = 30;
24 Image img; // pyrimg rescaled back to full size image (after rescaling by eyemouth)
25 const double RESOLUTION = 2; // 1 for no extra resolution, 2 for double resolution
26 const double rescale = RESOLUTION / GetPyrScale(ilev);
27 cv::resize(pyrimg, img, cv::Size(), rescale, rescale, cv::INTER_NEAREST);
28 CImage cimg; cvtColor(img, cimg, CV_GRAY2BGR); // color image
29 DesaturateImg(cimg);
30 Shape shape1(RoundMat(shape));
31 shape1 += .4; // put shape points in center of rescaled pixels
32 shape1 *= rescale;
33 DrawShape(cimg, shape1, C_YELLOW, false, 1);
34 char path[SLEN];
35 if (iter < 0) // start shape?
36 sprintf(path, "%s_%2.2d_%s.bmp", Base(imgpath_g), index, suffix);
37 else
38 sprintf(path, "%s_%2.2d_lev%d_iter%d_%s.bmp",
39 Base(imgpath_g), index, ilev, iter, suffix);
40 ImgPrintf(cimg, 10 * RESOLUTION, 20 * RESOLUTION, C_YELLOW, 2, path);
41 if (iter >= 0)
42 {
43 // draw 1D patch boundary at one point (patch is drawn
44 // horizontal, not rotated to shape boundary as it should be)
45 // [Thanks to Satish Lokkoju for RoundMat fix]
46
47 Shape shape2(RoundMat(shape));
48 int ipoint = 0;
49 int proflen = 9; // TASM_1D_PROFLEN
50 int x1 = cvRound(shape2(ipoint, IX)) - proflen / 2;
51 int x2 = x1 + proflen;
52 int y1 = cvRound(shape2(ipoint, IY));
53 int y2 = y1 + 1;
54 rectangle(cimg,
55 cv::Point(cvRound(rescale * x1), cvRound(rescale * y1)),
56 cv::Point(cvRound(rescale * x2), cvRound(rescale * y2)),
57 CV_RGB(255,0,0), 1);
58
59 // draw 2D patch boundary at one point
60
61 if (ilev <= HAT_START_LEV) // we use HATs only at upper pyr levs
62 {
63 // get position of left eye pupil by first converting to a shape17
64 ipoint = 0; // assume we can't get position of left eye pupil
65 Shape newshape(Shape17OrEmpty(shape2));
66 if (newshape.rows) // successfully converted to a shape17?
67 ipoint = L17_LPupil;
68 else

Callers 2

LevSearch_Method · 0.85
ModSearch_Method · 0.85

Calls 11

GetPyrScaleFunction · 0.85
DesaturateImgFunction · 0.85
RoundMatFunction · 0.85
DrawShapeFunction · 0.85
BaseFunction · 0.85
ImgPrintfFunction · 0.85
Shape17OrEmptyFunction · 0.85
round2Function · 0.85
lprintfFunction · 0.85
ErrFunction · 0.85
resizeFunction · 0.50

Tested by

no test coverage detected