#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; }