From 94e704acde59df60bd42f6f90b94d462d1bfa37c Mon Sep 17 00:00:00 2001 From: xuxiuxi <xuxiuxi@454eff88-639b-444f-9e54-f578c98de674> Date: 星期日, 23 七月 2017 12:09:41 +0800 Subject: [PATCH] --- FaceServer/sample_face_search.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 42 insertions(+), 2 deletions(-) diff --git a/FaceServer/sample_face_search.cpp b/FaceServer/sample_face_search.cpp index 93a6bdc..12e1196 100644 --- a/FaceServer/sample_face_search.cpp +++ b/FaceServer/sample_face_search.cpp @@ -133,6 +133,17 @@ // fclose(pFile); //} } + else if (image.mb_type == MB_Frame::MBFT_JPEG) + { + Mat matTmp = imdecode(_InputArray(image.buff, image.size), CV_LOAD_IMAGE_COLOR); + + //imwrite("aaa.jpg", matTmp); + + imgbufSize = matTmp.total() * matTmp.elemSize(); + memcpy(imgbuf, matTmp.ptr(), imgbufSize); + + stimgfmt = CV_PIX_FMT_BGR888; + } else { LOG_WARN << "mb frame type not support" << LOG_ENDL; @@ -144,12 +155,12 @@ // ++f; // // char fname[50]; - // sprintf(fname, "st-%d.rgb", f); + // sprintf(fname, "st-%d.img", f); // FILE *pFile = fopen(fname, "wb"); // fwrite(image.buff, 1, image.size, pFile); // fclose(pFile); // - // sprintf(fname, "st-%d.yuv", f); + // sprintf(fname, "st-%d.img", f); // pFile = fopen(fname, "wb"); // fwrite(imgbuf, 1, imgbufSize, pFile); // fclose(pFile); @@ -178,6 +189,35 @@ return p_feature; } +float stface_compare(stface_handles& handles, const STFaceImage& image1, const STFaceImage& image2) +{ + cv_feature_t* f1 = stface_extract_feature(handles, image1); + if (f1 == nullptr) + { + LOGP(INFO, "can't find face in image1"); + return -1.0; + } + + cv_feature_t* f2 = stface_extract_feature(handles, image2); + if (f2 == nullptr) + { + cv_verify_release_feature(f1); + LOGP(INFO, "can't find face in image2"); + return -1.0; + } + + float score = -1.0; + cv_result_t cv_result = cv_verify_compare_feature(handles.handle_verify, f1, f2, &score); + if (cv_result != CV_OK) { + LOGP(DEBUG, "cv_verify_compare_feature failed, error code %d", cv_result); + score = -1.0; + } + + cv_verify_release_feature(f1); + cv_verify_release_feature(f2); + return score; +} + int stface_db_add(stface_handles& handles, const char *image_path) { cv_feature_t *p_feature = stface_extract_feature(handles, image_path); if (!p_feature) { -- Gitblit v1.8.0