Beispiel #1
0
        public MError SetLivenessParam(ASF_LivenessThreshold livenessThreshold)
        {
            var    retCode = MError.MERR_UNKNOWN;
            IntPtr ptrLivenessThreshold = MemoryHelper.Malloc(MemoryHelper.SizeOf <ASF_LivenessThreshold>());

            MemoryHelper.StructureToPtr <ASF_LivenessThreshold>(livenessThreshold, ptrLivenessThreshold);
            try
            {
                if (ptrVideoEngine == IntPtr.Zero)
                {
                    retCode = InitialEngineForVideo();
                }
                else
                {
                    retCode = MError.MOK;
                }

                if (retCode == MError.MOK)
                {
                    retCode = Afw.Services.Initialization.SetLivenessParam(ptrVideoEngine, ptrLivenessThreshold);
                }

                if (retCode != MError.MOK)
                {
                    Afw.Core.Helper.SimplifiedLogHelper.WriteIntoSystemLog(nameof(Afw.WinForm.EngineContext), $"SetLivenessParam Error:{retCode.GetFieldDescription()}");
                }
            }
            catch (Exception ex)
            {
                Afw.Core.Helper.SimplifiedLogHelper.WriteIntoSystemLog(nameof(Afw.WinForm.EngineContext), $"SetLivenessParam Exception:{ex.ToString()}");
            }
            return(retCode);
        }
Beispiel #2
0
        private void SetLivenessParam()
        {
            ASF_LivenessThreshold a = new ASF_LivenessThreshold();

            if (engineContext.IrCameraIdx >= 0)
            {
                a.thresholdmodel_BGR = 0.75f;
            }
            else
            {
                a.thresholdmodel_BGR = 0.85f;
            }
            a.thresholdmodel_IR = 0.7f;
            engineContext.SetLivenessParam(a);
        }
        /// <summary>
        /// 设置活体阈值:取值范围[0-1]内部默认数值RGB-0.5,IR-0.7, 用户可以根据实际需求,设置不同的阈值
        /// </summary>
        /// <param name="rgbThreshold">RGB活体阈值</param>
        /// <param name="irThreshole">IR活体阈值</param>
        /// <returns>返回0表示正常;返回负数请根据ErrorCodeUtil类注释查看;其他值请在官网-帮助中心查询</returns>
        public int ASFSetLivenessParam(float rgbThreshold = 0.5f, float irThreshole = 0.7f)
        {
            ASF_LivenessThreshold livebessThreshold = new ASF_LivenessThreshold();

            //对应设置阈值
            livebessThreshold.thresholdmodel_BGR = (rgbThreshold >= 0 && rgbThreshold <= 1) ? rgbThreshold : 0.5f;
            livebessThreshold.thresholdmodel_IR  = (irThreshole >= 0 && irThreshole <= 1) ? irThreshole : 0.7f;
            IntPtr pLivenessThreshold = MemoryUtil.Malloc(MemoryUtil.SizeOf <ASF_LivenessThreshold>());

            MemoryUtil.StructureToPtr(livebessThreshold, pLivenessThreshold);
            //调用SDK接口
            int retCode = ASFFunctions.ASFSetLivenessParam(pEngine, pLivenessThreshold);

            MemoryUtil.Free(pLivenessThreshold);
            return(retCode);
        }
Beispiel #4
0
 public static extern MResult ASFSetLivenessParam(IntPtr hEngine, ASF_LivenessThreshold threshold);