基本思想:给客户搞了个摄像头的人证比对历程,真艰辛;
本以为很简单的一个事情,最开始是人证比对,客户搞成了照片测试;我又搞成了眨眼测试,客户用上了手机播放视频;我又又搞成了手机检测,客户搞成了流媒体设备播放,深受其害,导入百度活体检测吧!
(1)、https://ai.baidu.com/ai-doc/FACE/4k37c1kj1 下载百度的C++ 活体检测SDK
(2)、然后离线激活一下
(3)将下载的License.zip 导入许可文件F:\temp\Baidu_Face_Offline_SDK_Windows_Cpp_V6.0\face-sdk-demo\windows\face_demo\License.zip,然后测试
(4)修改一下百度提供的vs工程,进行活体检测,效果还可以啊~ (测试官方提供的demo)
测试了一张图片,测试结果
rgb_img_path=G:\A.png
FaceSDK ---perf--- <line 32: bdface::bdface_create_img_instance> 0.739600ms
FaceSDK ---value--- <line 138: bdface::FaceBoxesDetect::_predict> output tensor size: 1
FaceSDK ---value--- <line 50: bdface::FaceDetectPreprocessor::run> detected faces size before filtered by score: 1
FaceSDK ---value--- <line 104: bdface::FaceDetectPreprocessor::run> detected faces size after filtered by score: 1
FaceSDK ---perf--- <line 180: bdface::bdface_detect> 16.067300ms
FaceSDK ---perf--- <line 143: bdface::bdface_align> 20.871900ms
FaceSDK ---perf--- <line 202: bdface::bdface_silent_live> 21.947800ms
face-demo ---info--- frame 1 -----------------------------------------------------
face-demo ---info--- rgb silent live test -- face 1:
face-demo ---info--- liveness value: 0.709688
(5)开始移植吧
添加头文件
D:\Baidu_Face_Offline_SDK_Windows_Cpp_V6.0\face-sdk-demo\common\include
D:\Baidu_Face_Offline_SDK_Windows_Cpp_V6.0\face-sdk\output\face_sdk\include
D:\Baidu_Face_Offline_SDK_Windows_Cpp_V6.0\face-sdk-demo\third_party\zlib\windows\zlib\include
D:\Baidu_Face_Offline_SDK_Windows_Cpp_V6.0\face-sdk-demo\third_party\libzip\include
D:\Opencv440\build\include\opencv2
D:\Opencv440\build\include
添加库目录
D:\Baidu_Face_Offline_SDK_Windows_Cpp_V6.0\face-sdk-demo\third_party\libzip\x64
D:\Baidu_Face_Offline_SDK_Windows_Cpp_V6.0\face-sdk\output\face_sdk\x64
D:\Baidu_Face_Offline_SDK_Windows_Cpp_V6.0\face-sdk-demo\third_party\zlib\windows\zlib\x64
D:\Opencv440\build\x64\vc15\lib
添加lib库
face_sdk.lib
zip.lib
同时将官方提供的源码文件,拷贝到自己的工程中,先做一下删掉冗余文件吧~
修改文件face_file_util.h,文件开头添加,同时拷贝新工程中
#pragma warning(disable:4996);
将opencv_world440.dll 、将D:\Baidu_Face_Offline_SDK_Windows_Cpp_V6.0\face-sdk-demo\windows\face_demo\x64\Release\*.dll都移动到可执行文件目录
将demo中模型拷贝到源码路径同时把官方的license.zip也拷贝到新工程中 detect目录下
align_rgb_float32_paddle.encrypted
detect_nir_int8_paddle.encrypted
silent_live_rgb_float32_paddle.encrypted
License.zip
因为模型的加载在 新工程源码代码test_detect_rgb.h、新工程源码代码test_align_rgb_accurate.h、新工程源码代码test_silent_live_rgb.h中
然后指定一下地址模型地址、 添加一个图片地址 face_consts.h
const std::string models_dir =
const std::string rgb_img_path =
然后新工程测试活体检测demo就完成了,其它无用已经删掉
face-demo ---info--- loading rgb detect ability, model path: F:\sxj\20210630\ConsoleApplication2\detec标签:info,59,VS2019,demo,face,---,rgb,API,sdk From: https://blog.51cto.com/u_12504263/5719209
encrypted
face-demo ---info--- load detect rgb ability finished.
face-demo ---info--- loading accurate align rgb ability, model path: F:\sxj\20210630\ConsoleApplicatio
32_paddle.encrypted
Fused graph 0
face-demo ---info--- load accurate align rgb ability finished.
face-demo ---info--- loading rgb live ability, model path: F:\sxj\20210630\ConsoleApplication2\silent_
addle.encrypted
Fused graph 0
face-demo ---info--- load rgb live ability finished.
rgb_img_path=G:\q.jpg
face-demo ---info--- frame 1 -----------------------------------------------------
face-demo ---info--- rgb silent live test -- face 1:
face-demo ---info--- liveness value: 0.911451
F:\sxj\20210630\ConsoleApplication2\x64\Release\ConsoleApplication2.exe (进程 23568)已退出,代码为 0。