Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SFaceRecognizer model face recognition C++ test failed #256

Closed
Linktin opened this issue May 8, 2024 · 2 comments
Closed

SFaceRecognizer model face recognition C++ test failed #256

Linktin opened this issue May 8, 2024 · 2 comments

Comments

@Linktin
Copy link

Linktin commented May 8, 2024

YuNet model("/home/hy/code/face_detection_yunet_2023mar.onnx", cv::Size(160, 120), 0.9, 0.3, 5000, 0, 0);
SFace sface("/home/hy/code/face_recognition_sface_2021dec_int8.onnx",0,0,0);
DetectedFace dface1,dface2;

Mat img1 = imread("/home/hy/code/heye.jpg");
Mat img2 = imread("/home/hy/code/demo.jpg");

//face detection
model.setInputSize(Size(img1.cols,img1.rows));
dface1 = model.infer(img1);
model.setInputSize(Size(img2.cols,img2.rows));
dface2 = model.infer(img2);

std::cout<<"face1 nums:"<<dface1.nums<<std::endl;
std::cout<<"face2 nums:"<<dface2.nums<<std::endl;
//face recognition
auto tick_meter = cv::TickMeter();
tick_meter.start();

// std::cout<<"scores:"<<static_cast(dface1.faces.at(0, 14))<<std::endl;
cv::Range cols_range(0, 13);
cv::Mat face1_features = dface1.faces.row(0).colRange(cols_range);
cv::Mat face2_features = dface2.faces.row(0).colRange(cols_range);

pair<double, bool> res = sface.match(img1, face1_features, img2, face2_features);

When I use the image and the detected facial feature information using YuNet for inference with this model, the result is as follows:
image
In any case, the facial matching score is always 1! This is not normal.

@Linktin
Copy link
Author

Linktin commented May 9, 2024

已解决,feature的浅拷贝导致得到相同的人脸特征,加上clone()函数进行深拷贝即可解决。
Mat feature1 = infer(image1,face1).clone(); // 提取第一张图像的特征
Mat feature2 = infer(image2,face2).clone(); // 提取第二张图像的特征

@fengyuentau
Copy link
Member

Duplicate of #189

@fengyuentau fengyuentau marked this as a duplicate of #189 May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants