|
@@ -1,8 +1,13 @@
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
#include "stdafx.h"
|
|
|
+#endif // RVC_OS_WIN
|
|
|
#include "mod_livenessdetection.h"
|
|
|
|
|
|
-CLivenessDetectionEntity::CLivenessDetectionEntity(): m_bStarted(FALSE), m_nCaptureType(-1), m_pFsm(NULL), m_pCapturer(NULL)
|
|
|
+CLivenessDetectionEntity::CLivenessDetectionEntity(): m_bStarted(FALSE), m_nCaptureType(-1)//, m_pCapturer(NULL)
|
|
|
{
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
+ m_pFsm = NULL;
|
|
|
+#endif
|
|
|
//m_pFsm = new CLivenessDetectionFSM(8,REC_COMMON_VIDEO_ENV_SHM_SNAPSHOT_QUEUE,REC_COMMON_VIDEO_OPT_SHM_SNAPSHOT_QUEUE);
|
|
|
}
|
|
|
|
|
@@ -84,13 +89,23 @@ ErrorCodeEnum CLivenessDetectionEntity::__OnStart(ErrorCodeEnum preOperationErro
|
|
|
|
|
|
if (ePadtype==m_eDeviceType||eMobilePadType==m_eDeviceType||eDesk2SType==m_eDeviceType)
|
|
|
{
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
m_pFsm = new CLivenessDetectionFSM(8,REC_COMMON_VIDEO_ENV_SHM_SNAPSHOT_QUEUE,NULL,640,360);
|
|
|
- m_pCapturer = new RvcFaceCapture::RvcFaceCapturer(REC_COMMON_VIDEO_ENV_SHM_SNAPSHOT_QUEUE,NULL,640,360);
|
|
|
+#endif
|
|
|
+
|
|
|
+#ifndef CLOSE_CAPTURE
|
|
|
+ m_pCapturer = new RvcFaceCapture::RvcFaceCapturer(REC_COMMON_VIDEO_ENV_SHM_SNAPSHOT_QUEUE, NULL, 640, 360);
|
|
|
+#endif // !CLOSE_CAPTURE
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
m_pFsm = new CLivenessDetectionFSM(8,REC_COMMON_VIDEO_ENV_SHM_SNAPSHOT_QUEUE,REC_COMMON_VIDEO_OPT_SHM_SNAPSHOT_QUEUE,640,360);
|
|
|
- m_pCapturer = new RvcFaceCapture::RvcFaceCapturer(REC_COMMON_VIDEO_ENV_SHM_SNAPSHOT_QUEUE,REC_COMMON_VIDEO_OPT_SHM_SNAPSHOT_QUEUE,640,360);
|
|
|
+#endif
|
|
|
+#ifndef CLOSE_CAPTURE
|
|
|
+ m_pCapturer = new RvcFaceCapture::RvcFaceCapturer(REC_COMMON_VIDEO_ENV_SHM_SNAPSHOT_QUEUE, REC_COMMON_VIDEO_OPT_SHM_SNAPSHOT_QUEUE, 640, 360);
|
|
|
+#endif // !CLOSE_CAPTURE
|
|
|
+
|
|
|
}
|
|
|
|
|
|
int i = 0;
|
|
@@ -120,6 +135,7 @@ ErrorCodeEnum CLivenessDetectionEntity::__OnStart(ErrorCodeEnum preOperationErro
|
|
|
nActiveCamera = CAMERA_TYPE_ENV;
|
|
|
}
|
|
|
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
//MessageBox(NULL,"hh","tishi",0);
|
|
|
ErrorCodeEnum rt = m_pFsm->Init(this);
|
|
|
Dbg("FsmInit:%d", rt);
|
|
@@ -127,13 +143,16 @@ ErrorCodeEnum CLivenessDetectionEntity::__OnStart(ErrorCodeEnum preOperationErro
|
|
|
{
|
|
|
return rt;
|
|
|
}
|
|
|
+#endif
|
|
|
|
|
|
+#ifndef CLOSE_CAPTURE
|
|
|
rt = m_pCapturer->Init(this);
|
|
|
Dbg("CapturerInit:0x%08x", rt);
|
|
|
if (rt!=Error_Succeed)
|
|
|
{
|
|
|
return rt;
|
|
|
}
|
|
|
+#endif
|
|
|
|
|
|
return Error;
|
|
|
}
|
|
@@ -150,15 +169,18 @@ ErrorCodeEnum CLivenessDetectionEntity::__OnClose( ErrorCodeEnum preOperationErr
|
|
|
spFunction->UnsubscribeLog(m_arrListener[i]);
|
|
|
}
|
|
|
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
m_pFsm->OnExit();
|
|
|
|
|
|
delete m_pFsm;
|
|
|
m_pFsm = NULL;
|
|
|
+#endif
|
|
|
|
|
|
+#ifndef CLOSE_CAPTURE
|
|
|
m_pCapturer->UnInit();
|
|
|
-
|
|
|
delete m_pCapturer;
|
|
|
m_pCapturer = NULL;
|
|
|
+#endif
|
|
|
|
|
|
ErrorCodeEnum Error = Error_Succeed;
|
|
|
return Error;
|
|
@@ -222,8 +244,12 @@ void CLivenessDetectionEntity::OnSysVarEvent( const char *pszKey, const char *ps
|
|
|
else if(pszValue[0] == 'B') ///////显示贴图
|
|
|
{
|
|
|
nActiveCamera = CAMERA_TYPE_ERROR;
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
m_pFsm->NotifyCameraFault(); // 摄像头故障,停止捕获
|
|
|
+#endif
|
|
|
+#ifndef CLOSE_CAPTURE
|
|
|
m_pCapturer->NotifyCameraFault(); // 摄像头故障,停止捕获
|
|
|
+#endif
|
|
|
}
|
|
|
else if (pszValue[0] == 'N')
|
|
|
{
|
|
@@ -286,6 +312,7 @@ void CLivenessDetectionEntity::StartLivenessDetection( SpReqAnsContext<LivenessD
|
|
|
bool bDoActiveDetect=CSimpleStringW2A(ctx->Req.Reserved)=="Y"?true:false;
|
|
|
if(!ctx->Req.IsActive||bDoActiveDetect) // 禁止pad或低柜双屏做被动捕获或者带活体检测的主动捕获
|
|
|
{
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
ctx->Answer(Error_Succeed); // 告知中台已经收到了启动活体请求
|
|
|
Dbg("Pad or desk2s VTM only support active capture without liveness now!");
|
|
|
DetectionStopUnExpected evt;
|
|
@@ -295,30 +322,47 @@ void CLivenessDetectionEntity::StartLivenessDetection( SpReqAnsContext<LivenessD
|
|
|
evt.ErrorMsg = CSimpleStringA2W("Pad版或低柜双屏版VTM暂仅支持不带活体检测的主动捕获!");
|
|
|
SpSendBroadcast(GetFunction(), SP_MSG_OF(DetectionStopUnExpected), SP_MSG_SIG_OF(DetectionStopUnExpected), evt);
|
|
|
return;
|
|
|
+#else
|
|
|
+ ctx->Answer(Error_Succeed); // 告知中台已经收到了启动活体请求
|
|
|
+ Dbg("linux机器暂不支持活体检测");
|
|
|
+ DetectionStopUnExpected evt;
|
|
|
+ evt.IsActive = (false);
|
|
|
+ evt.ActionID = ctx->Req.ActionID;
|
|
|
+ evt.ErrorCode = CSimpleStringA2W("Error_LiveDetectType");
|
|
|
+ evt.ErrorMsg = CSimpleStringA2W("linux机器暂不支持活体检测");
|
|
|
+ SpSendBroadcast(GetFunction(), SP_MSG_OF(DetectionStopUnExpected), SP_MSG_SIG_OF(DetectionStopUnExpected), evt);
|
|
|
+#endif
|
|
|
}
|
|
|
}
|
|
|
if (ctx->Req.IsActive&&CSimpleStringW2A(ctx->Req.Reserved)=="S")
|
|
|
{
|
|
|
ctx->Answer(Error_Succeed);
|
|
|
+#ifndef CLOSE_CAPTURE
|
|
|
if (ctx->Req.ActionID.GetLength()>0)
|
|
|
{
|
|
|
m_pCapturer->m_ActionID=CSimpleStringW2A(ctx->Req.ActionID);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- m_pCapturer->m_ActionID=m_pFsm->m_uid.ToString();
|
|
|
+ m_pCapturer->m_ActionID= CUUID::Create(m_pCapturer->m_ActionID)
|
|
|
}
|
|
|
|
|
|
m_pCapturer->StartFaceCapture();
|
|
|
+#endif
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
m_pFsm->StartLiveDetect(ctx);
|
|
|
+#else
|
|
|
+ Dbg("linux机器暂不支持活体检测");
|
|
|
+#endif
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void CLivenessDetectionEntity::StopLivenessDetection( SpReqAnsContext<LivenessDetectionService_StopLivenessDetection_Req, LivenessDetectionService_StopLivenessDetection_Ans>::Pointer ctx )
|
|
|
{
|
|
|
+#ifdef RVC_OS_WIN
|
|
|
bool bHasCapTask = m_pCapturer->GetHasCapTask();
|
|
|
bool bHasLiveTask = m_pFsm->GetHasLiveTask();
|
|
|
|
|
@@ -342,6 +386,16 @@ void CLivenessDetectionEntity::StopLivenessDetection( SpReqAnsContext<LivenessDe
|
|
|
{
|
|
|
m_pFsm->SetActiveStopLiveDetect(ctx);
|
|
|
}
|
|
|
+#else
|
|
|
+#ifndef CLOSE_CAPTURE
|
|
|
+ bool bHasCapTask = m_pCapturer->GetHasCapTask();
|
|
|
+ if (bHasCapTask)
|
|
|
+ {
|
|
|
+ m_pCapturer->StopFaceCapture();
|
|
|
+ ctx->Answer(Error_Succeed);
|
|
|
+ }
|
|
|
+#endif
|
|
|
+#endif
|
|
|
}
|
|
|
|
|
|
void LivenessDetectionServerSession::Handle_StartLivenessDetection( SpReqAnsContext<LivenessDetectionService_StartLivenessDetection_Req, LivenessDetectionService_StartLivenessDetection_Ans>::Pointer ctx )
|