人脸置信度比较
This commit is contained in:
parent
4890cf8b7a
commit
5845fd203b
31
src/demo.cpp
31
src/demo.cpp
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue