We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I write a c++ demo code using SFace model,but I find the match ouput is always 1.0000
The python code has correct output: ( the face image has already been aligned and croped from original big image to 112*112)
sface_model = cv.FaceRecognizerSF.create( model="./face_recognition_sface_2021dec.onnx", config="", backend_id=0, target_id=0 ) img1 = cv.imread("./tmp/face_112x112_0.bmp") feat1 = sface_model.feature(img1) print(feat1) img2 = cv.imread("./tmp/match/face_112x112_1.bmp") feat2 = sface_model.feature(img2) cosine_score = sface_model.match(feat1, feat2, 0) print("cosine_score=",cosine_score)
python output 's screenshot:
the c++ demo code is here:
std::string sface_model_file = "./face_recognition_sface_2021dec.onnx"; cv::Ptr<cv::FaceRecognizerSF> sface_model = nullptr; sface_model = cv::FaceRecognizerSF::create(sface_model_file,"",cv::dnn::DNN_BACKEND_OPENCV,cv::dnn::DNN_TARGET_CPU); printf("Init SFace model ok\n"); cv::Mat face_mat1 = cv::imread("./tmp/face_112x112_0.bmp"); cv::Mat face_feat1; //face_feat1.convertTo(face_feat1, CV_32FC3, 1.0 / 255, 0); sface_model->feature( face_mat1,face_feat1); //print feature value, the values seems to be totaly different from the values output in Python :-) for(int j=0;j<face_feat1.cols;j++) { double *f = (double*)face_feat1.data + j; printf("%lf ",*f); } printf("\n"); cv::Mat face_mat2 = cv::imread("./tmp/face_112x112_1.bmp"); cv::Mat face_feat2; //face_feat2.convertTo(face_feat2, CV_32FC3, 1.0 / 255, 0); sface_model->feature( face_mat2,face_feat2); double cosine_sim = sface_model->match( face_feat1,face_feat2,0); printf("sim=%.4lf\n",cosine_sim);
c++ output's :
Env: centos on x64/gcc 8.3/python 3.6.8/opencv-4.5.5
want help..... :-) :-) Thanks !
The text was updated successfully, but these errors were encountered:
double f = (double)face_feat1.data + j;
I believe it should be a float pointer instead.
Sorry, something went wrong.
Yes , Using float has printed same values output by Python.:-) Thanks,
but the match result is still 1.000,
Have I lost some preprocess or postprocess codes in c++?
printf("sim=%.4lf\n",cosine_sim);
Maybe the usage of printf is wrong: printf("sim=%.4f\n",cosine_sim);. See this https://stackoverflow.com/questions/4264127/correct-format-specifier-for-double-in-printf.
printf
printf("sim=%.4f\n",cosine_sim);
No branches or pull requests
I write a c++ demo code using SFace model,but I find the match ouput is always 1.0000
The python code has correct output: ( the face image has already been aligned and croped from original big image to 112*112)
python output 's screenshot:
the c++ demo code is here:
c++ output's :
Env: centos on x64/gcc 8.3/python 3.6.8/opencv-4.5.5
want help..... :-) :-) Thanks !
The text was updated successfully, but these errors were encountered: