人脸置信度比较

This commit is contained in:
mayang_tal 2023-09-11 20:17:27 +08:00
parent 4890cf8b7a
commit 5845fd203b
1 changed files with 12 additions and 19 deletions

View File

@ -164,7 +164,7 @@ int main(int argc, char *argv[]){
std::cout << "Regist over" << std::endl;
// Feature merge process
std::vector<cv::Mat> target_features;
std::vector<size_t> target_ids;
std::vector<size_t> target_ids; //要识别的人脸列表
for (auto item = id_features.begin(); item != id_features.end(); item++){
int id = item->first;
@ -187,27 +187,20 @@ int main(int argc, char *argv[]){
std::vector<cv::Rect> rectangles;
std::vector<float> confidences;
std::vector<std::vector<cv::Point>> alignment;
face_detector->detection_SCALE(img, rectangles, confidences, alignment);
std::vector<cv::Mat> features;
int ret = faceID_detector->calc_feature(img, rectangles, alignment, features);
std::vector<int> detect_ids;
std::vector<float> detect_conf;
faceID_detector->get_ids(features, target_ids, target_features, detect_ids, detect_conf);
for (int j = 0; j < rectangles.size(); j++) {
cv::rectangle(img, rectangles[j], {0, 0, 255}, 1);
std::string label = std::to_string(detect_ids[j]) + " " + std::to_string(detect_conf[j]);
cv::putText(img, label, {rectangles[j].x, rectangles[j].y}, cv::FONT_HERSHEY_COMPLEX_SMALL, 0.8, {0, 255, 0}, 1, CV_AA);
BOOST_LOG_TRIVIAL(info) << "Det Face:" << img_path << " " <<
rectangles[j].x << " " <<
rectangles[j].y << " " <<
rectangles[j].width << " " <<
rectangles[j].height << " " <<
detect_ids[j] << " " <<
detect_conf[j];
//get all confidences
for(int j = 0;j < confidences.size();j++){
std::cout << std::to_string(j) + ":" << confidences[j] << std::endl;
}
// Find the index of the highest confidence
int maxConfidenceIndex = max_element(confidences.begin(),confidences.end()) - confidences.begin();
// Print the rectangle of highest confidence
std::cout << "Highest Confidence Rectangle: "<< rectangles[maxConfidenceIndex] <<std::endl;
cv:rectangle(img, rectangles[maxConfidenceIndex], {0, 0, 255}, 2);
cv::imwrite("./rslt/rs_nomeg_1/" + std::to_string(i) + ".jpg", img);
std::cout << "succ" << loop++ << std::endl;
}