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

Function InterEyeDist

jni/stasm/eyedist.cpp:96–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94}
95
96double InterEyeDist( // inter-pupil distance of a face shape
97 const Shape& shape) // in
98{
99 static const int leyes[] = // surrogates for left pupil
100 {
101 L17_LPupil,
102 L17_LEyeOuter,
103 L17_LEyeInner,
104 L17_LEyebrowInner,
105 L17_LEyebrowOuter
106 };
107 static const int reyes[] = // surrogates for right pupil
108 {
109 L17_RPupil,
110 L17_REyeOuter,
111 L17_REyeInner,
112 L17_REyebrowInner,
113 L17_REyebrowOuter
114 };
115 const Shape shape17(Shape17OrEmpty(shape));
116 if (shape17.rows == 0) // could not convert the shape to a Shape17?
117 return ShapeWidth(shape) / 2; // fallback, note return
118 double eyedist = 0;
119 const int leye = TabPoint(leyes, NELEMS(leyes), shape17);
120 const int reye = TabPoint(reyes, NELEMS(reyes), shape17);
121 if (leye >= 0 && reye >= 0 && // actual or surrogate points available?
122 PointDist(shape17, leye, reye) > 1) // surrogates aren't co-located?
123 {
124 eyedist = PointDist(shape17, leye, reye) *
125 PointDist(MEANSHAPE17, L17_LPupil, L17_RPupil) /
126 PointDist(MEANSHAPE17, leye, reye);
127 }
128 else // last resort, estimate inter-pupil distance from shape extent
129 {
130 eyedist = MAX(ShapeWidth(shape17), ShapeHeight(shape17)) *
131 PointDist(MEANSHAPE17, L17_LPupil, L17_RPupil) /
132 MAX(ShapeWidth(MEANSHAPE17), ShapeHeight(MEANSHAPE17));
133 }
134 CV_Assert(eyedist > 1 && eyedist < 1e5); // sanity check
135 return eyedist;
136}
137
138} // namespace stasm

Callers

nothing calls this directly

Calls 6

Shape17OrEmptyFunction · 0.85
ShapeWidthFunction · 0.85
TabPointFunction · 0.85
NELEMSFunction · 0.85
PointDistFunction · 0.85
ShapeHeightFunction · 0.85

Tested by

no test coverage detected