| 174 | } |
| 175 | |
| 176 | void FaceDetector::DetectFaces_( // call once per image to find all the faces |
| 177 | const Image& img, // in: the image (grayscale) |
| 178 | const char* imgpath, // in: used only for debugging |
| 179 | bool multiface, // in: if false, want only the best face |
| 180 | int minwidth, // in: min face width as percentage of img width |
| 181 | void* user) // in: unused (match virt func signature) |
| 182 | { |
| 183 | CV_Assert(user == NULL); |
| 184 | DetectFaces(detpars_, img, minwidth); |
| 185 | char tracepath[SLEN]; |
| 186 | sprintf(tracepath, "%s_00_unsortedfacedet.bmp", Base(imgpath)); |
| 187 | TraceFaces(detpars_, img, tracepath); |
| 188 | DiscardMissizedFaces(detpars_); |
| 189 | if (multiface) // order faces on increasing distance from left margin |
| 190 | { |
| 191 | sort(detpars_.begin(), detpars_.end(), IncreasingLeftMargin); |
| 192 | sprintf(tracepath, "%s_05_facedet.bmp", Base(imgpath)); |
| 193 | TraceFaces(detpars_, img, tracepath); |
| 194 | } |
| 195 | else |
| 196 | { |
| 197 | // order faces on decreasing width, keep only the first (the largest face) |
| 198 | std::sort(detpars_.begin(), detpars_.end(), DecreasingWidth); |
| 199 | sprintf(tracepath, "%s_05_sortedfaces.bmp", Base(imgpath)); |
| 200 | TraceFaces(detpars_, img, tracepath); |
| 201 | if (NSIZE(detpars_)) |
| 202 | detpars_.resize(1); |
| 203 | } |
| 204 | iface_ = 0; // next invocation of NextFace_ must get first face |
| 205 | } |
| 206 | |
| 207 | // Get the (next) face from the image. |
| 208 | // If no face available, return detpar.x INVALID. |
no test coverage detected