a
554325746@qq.com
2019-12-25 603cb36a5123e46656b06a5deb8d7ac7ff81307f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "LivenessDetect.h"
 
#include "FiStdDefEx.h"
//#include "THFaceLive_i.h"
#include "RgbDetect.h"
#include "GrayDetect.h"
#include "THFaceLive_i.h"
#include "LogUtil.h"
 
bool LivenessDetect::detect(int faceIndex) {
    bool success = false;
    try {
        if (GrayDetect::grayImageBuff != nullptr && GrayDetect::grayImageBuff.get() != nullptr && GrayDetect::grayImageBuff.get()->data() !=
                                                                                                          nullptr) {
            unsigned char* pBuf_color = RgbDetect::rgb_image_buffer.get()->data();
            unsigned char* pBuf_bw = GrayDetect::grayImageBuff.get()->data();
            THFI_FacePos*  ptfp_color = &RgbDetect::facePos.get()->at(faceIndex);
            THFI_FacePos* ptfp_bw  = &GrayDetect::facePos.get()->at(faceIndex);
            int    liveness = 0;
 
            float score[2]={0};
            liveness = THFL_Detect(0,RgbDetect::rgb_image_buffer.get()->data(),
                GrayDetect::grayImageBuff.get()->data(), RgbDetect::width,  RgbDetect::height, &RgbDetect::facePos.get()->at(faceIndex),
                 &GrayDetect::facePos.get()->at(faceIndex),50,score);
                 //int    nLiveness = THFL_Detect(0,img1.data, img2.data, nWidth1, nHeight1, &fps1[0], &fps2[0],70,score);
//            THFL_Detect(0,  RgbDetect::rgb_image_buffer.get()->data(),
//                                          GrayDetect::grayImageBuff.get()->data(),
//                                          RgbDetect::width, RgbDetect::height,
//                                          &RgbDetect::facePos.get()->at(faceIndex), &GrayDetect::facePos.get()->at(faceIndex),20);
            printf("Live Result:\nscore[0]=%f,score[1]=%f\n",score[0],score[1]);
            float score1 = score[0];
            float score2 = score[1];
            this->liveness = liveness;
            if(liveness == 1) {
                success = true;
            }
        }
 
 
    }catch (exception & e) {
        LogUtil::log(e.what());
    }
    return success;
}