| 145 | } |
| 146 | |
| 147 | static void TraceFaces( // write image showing detected face rects |
| 148 | const std::vector<DetectorParameter>& detpars, // in |
| 149 | const Image& img, // in |
| 150 | const char* path) // in |
| 151 | { |
| 152 | #if TRACE_IMAGES // will be 0 unless debugging (defined in stasm.h) |
| 153 | |
| 154 | CImage cimg; cvtColor(img, cimg, CV_GRAY2BGR); // color image |
| 155 | for (int iface = 0; iface < NSIZE(detpars); iface++) |
| 156 | { |
| 157 | const DetectorParameter &detpar = detpars[iface]; |
| 158 | |
| 159 | rectangle(cimg, |
| 160 | cv::Point(cvRound(detpar.x - detpar.width/2), |
| 161 | cvRound(detpar.y - detpar.height/2)), |
| 162 | cv::Point(cvRound(detpar.x + detpar.width/2), |
| 163 | cvRound(detpar.y + detpar.height/2)), |
| 164 | CV_RGB(255,255,0), 2); |
| 165 | |
| 166 | ImgPrintf(cimg, // 10 * iface to minimize overplotting |
| 167 | detpar.x + 10 * iface, detpar.y, |
| 168 | C_YELLOW, 1, ssprintf("%d", iface)); |
| 169 | } |
| 170 | lprintf("%s\n", path); |
| 171 | if (!cv::imwrite(path, cimg)) |
| 172 | Err("Cannot write %s", path); |
| 173 | #endif |
| 174 | } |
| 175 | |
| 176 | void FaceDetector::DetectFaces_( // call once per image to find all the faces |
| 177 | const Image& img, // in: the image (grayscale) |