| 135 | } |
| 136 | |
| 137 | int caffe_mtcnn::run_PNet(const cv::Mat& img, scale_window& win, std::vector<face_box>& box_list) |
| 138 | { |
| 139 | cv::Mat resized; |
| 140 | int scale_h = win.h; |
| 141 | int scale_w = win.w; |
| 142 | float scale = win.scale; |
| 143 | |
| 144 | cv::resize(img, resized, cv::Size(scale_w, scale_h), 0, 0, cv::INTER_NEAREST); |
| 145 | |
| 146 | Blob<float>* input_blob = PNet_->input_blobs()[0]; |
| 147 | input_blob->Reshape(1, 3, scale_h, scale_w); |
| 148 | PNet_->Reshape(); |
| 149 | |
| 150 | std::vector<cv::Mat> input_channels; |
| 151 | float* input_data = PNet_->input_blobs()[0]->mutable_cpu_data(); |
| 152 | set_input_buffer(input_channels, input_data, scale_h, scale_w); |
| 153 | |
| 154 | cv::split(resized, input_channels); |
| 155 | |
| 156 | PNet_->Forward(); |
| 157 | |
| 158 | Blob<float>* reg = PNet_->output_blobs()[0]; |
| 159 | Blob<float>* confidence = PNet_->output_blobs()[1]; |
| 160 | |
| 161 | int feature_h = reg->shape(2); |
| 162 | int feature_w = reg->shape(3); |
| 163 | std::vector<face_box> candidate_boxes; |
| 164 | |
| 165 | generate_bounding_box(confidence->cpu_data(), confidence->count(), reg->cpu_data(), scale, pnet_threshold_, |
| 166 | feature_h, feature_w, candidate_boxes, true); |
| 167 | |
| 168 | nms_boxes(candidate_boxes, 0.5, NMS_UNION, box_list); |
| 169 | |
| 170 | return 0; |
| 171 | } |
| 172 | |
| 173 | void caffe_mtcnn::copy_one_patch(const cv::Mat& img, face_box& input_box, float* data_to, int width, int height) |
| 174 | { |
nothing calls this directly
no test coverage detected