class impl
class FaceDetection::Impl { public: Impl() : detector_(new seeta::fd::FuStDetector()), slide_wnd_step_x_(4), slide_wnd_step_y_(4), min_face_size_(20), max_face_size_(-1), cls_thresh_(3.85f) {} ~Impl() {} inline bool IsLegalImage(const seeta::ImageData & image) { return (image.num_channels == 1 && image.width > 0 && image.height > 0 && image.data != nullptr); } public: static const int32_t kWndSize = 40; int32_t min_face_size_; int32_t max_face_size_; int32_t slide_wnd_step_x_; int32_t slide_wnd_step_y_; float cls_thresh_; std::vector<seeta::FaceInfo> pos_wnds_; std::unique_ptr<seeta::fd::Detector> detector_; seeta::fd::ImagePyramid img_pyramid_; };
score
impl_->pos_wnds_ = impl_->detector_->Detect(&(impl_->img_pyramid_));
fust.cpp
std::vector<seeta::FaceInfo> FuStDetector::Detect(
seeta::fd::ImagePyramid* img_pyramid) {
score
for (int32_t i = 0; i < hierarchy_size_[0]; i++) { if (model_[i]->Classify(&score)) { wnd_info.score = static_cast<double>(score); proposals[i].push_back(wnd_info); } }
2
if (model_[model_idx]->Classify(&score, mlp_predicts.data())) { float x = static_cast<float>(bboxes[m].bbox.x); float y = static_cast<float>(bboxes[m].bbox.y); float w = static_cast<float>(bboxes[m].bbox.width); float h = static_cast<float>(bboxes[m].bbox.height); bboxes[bbox_idx].bbox.width = static_cast<int32_t>((mlp_predicts[3] * 2 - 1) * w + w + 0.5); bboxes[bbox_idx].bbox.height = bboxes[bbox_idx].bbox.width; bboxes[bbox_idx].bbox.x = static_cast<int32_t>((mlp_predicts[1] * 2 - 1) * w + x + (w - bboxes[bbox_idx].bbox.width) * 0.5 + 0.5); bboxes[bbox_idx].bbox.y = static_cast<int32_t>((mlp_predicts[2] * 2 - 1) * h + y + (h - bboxes[bbox_idx].bbox.height) * 0.5 + 0.5); bboxes[bbox_idx].score = score; bbox_idx++; }