58 lines
1.3 KiB
C++
58 lines
1.3 KiB
C++
// test_liveness_ir.cpp : 定义控制台应用程序的入口点。
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include <Inc/CenterFaceMnn.h>
|
|
#include <Inc/LivenessIRDnn.h>
|
|
#include <Inc/LivenessIRMnn.h>
|
|
#include <Inc/toolkit/LocalCamera.h>
|
|
#include <Inc/TimeCount.h>
|
|
|
|
int main()
|
|
{
|
|
std::vector<CamObj> cams;
|
|
LocalCamera::GetAllCam(cams);
|
|
|
|
cv::VideoCapture camera1(0);
|
|
if (!camera1.isOpened())
|
|
return 1;
|
|
while (true)
|
|
{
|
|
cv::Mat img;
|
|
camera1 >> img;
|
|
|
|
std::vector<FaceInfo> faces;
|
|
{
|
|
USE_TIME T("CenterFaceMnn => ");
|
|
CenterFaceMnn::GetInstance()->Detect(img, faces);
|
|
}
|
|
|
|
if (faces.size() > 0)
|
|
{
|
|
float score = 0.f;
|
|
{
|
|
USE_TIME t("LivenessIRMnn");
|
|
LivenessIRMnn::GetInstance()->LivenessDetect(img, faces[0], score, true, 5);
|
|
//LivenessIRDnn::GetInstance()->LivenessDetect(img, faces[0], score, true,1);
|
|
//LivenessIRDnn::GetInstance()->LivenessDetect(img, faces[0].x1, faces[0].y1, faces[0].x2, faces[0].y2, faces[0].landmarks, score, true, 1);
|
|
}
|
|
|
|
std::cout << "score => " << score << std::endl;
|
|
|
|
cv::Scalar color(0,0,255);
|
|
if (score > 0.8)
|
|
{
|
|
color = cv::Scalar(0, 255, 0);
|
|
}
|
|
cv::rectangle(img, cv::Rect(faces[0].x1, faces[0].y1, faces[0].GetWidth(), faces[0].GetHeight()), color, 2);
|
|
|
|
}
|
|
|
|
cv::imshow("show", img);
|
|
cv::waitKey(10);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|