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

Function MouthRectShift

jni/stasm/eyedet.cpp:97–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95// Get adjustment for position of mouth, based on model type and eye angle.
96
97static void MouthRectShift(
98 int& ixshift, // out
99 int& iyshift, // out
100 EYAW eyaw, // in
101 int facerect_width, // in
102 int facerect_height, // in
103 int ileft_best, // in
104 int iright_best, // in
105 const vec_Rect& leyes, // in
106 const vec_Rect& reyes) // in
107{
108 double xshift = 0, yshift = 0;
109 switch (eyaw)
110 {
111 case EYAW00: // frontal model
112 break;
113 case EYAW_45: // left facing three-quarter model
114 xshift -= .04 * facerect_width;
115 break;
116 case EYAW_22: // left facing three-quarter model
117 xshift -= .03 * facerect_width;
118 break;
119 case EYAW22: // right facing three-quarter model
120 xshift += .03 * facerect_width;
121 break;
122 case EYAW45: // right facing three-quarter model
123 xshift += .04 * facerect_width;
124 break;
125 default:
126 Err("MouthRectShift: Invalid eyaw %d", eyaw);
127 break;
128 }
129 if (ileft_best != -1 && iright_best != -1) // got both eyes?
130 {
131 // get center of eye boxes to get eye angle
132 const int xleft = leyes[ileft_best].x + leyes[ileft_best].width/2;
133 const int yleft = leyes[ileft_best].y + leyes[ileft_best].height/2;
134 const int xright = reyes[iright_best].x + reyes[iright_best].width/2;
135 const int yright = reyes[iright_best].y + reyes[iright_best].height/2;
136 double theta = -atan2(double(yright - yleft), double(xright - xleft));
137 // move the mouth in the direction of rotation
138 xshift += .3 * facerect_height * tan(theta);
139 // as the face rotates, the mouth moves up the page
140 yshift -= .1 * facerect_height * ABS(tan(theta));
141 }
142 ixshift = cvRound(xshift);
143 iyshift = cvRound(yshift);
144}
145
146static Rect MouthSearchRect( // will search for mouth in this rectangle
147 const Rect& facerect, // in: the detected face rectangle

Callers 2

MouthSearchRectFunction · 0.85
MouthInnerRectFunction · 0.85

Calls 2

ErrFunction · 0.85
ABSFunction · 0.85

Tested by

no test coverage detected