环境: win10(10.0.16299.0)+ VS2017

sdk版本:ArcFace v2.0

OPENCV3.43版本

x64平台Debug、Release配置都已通过编译

下载地址:https://download.csdn.net/download/cngwj/10763108

配置过程

->0x01 下载sdk:

虹安sdk https://ai.arcsoft.com.cn

->0x02 工程配置:

1、 添加工程的头文件目录:

a) 右键单击工程名, 选择属性---配置属性---c/c++---常规---附加包含目录

b) 添加头文件存放目录

2、 添加文件引用的 lib 静态库路径:

a) 右键单击工程名,选择属性---配置属性---链接器---常规---附加库目录

b) 添加 lib 文件存放

3、 添加工程引用的 lib 库:

a) 右键单击工程名,选择属性---配置属性---链接器---输入---附加依赖项

b) 添加依赖的 lib 库名称

4、自定义可执行文件输出目录

5、 添加工程引用的 dll 动态库:

a) 把引用的 dll 放到工程的可执行文件所在的目录下(复制到Build目录)

6、添加自己申请的APPID

->0x03 参考代码

  1. /************************************************************************
  2. * Copyright(c) 2018
  3. * All rights reserved.
  4. * File: samplecode.cpp
  5. * Brief: Powered by ArcSoft
  6. 环境: win10(10.0.16299.0)+ VS2017
  7. sdk版本:ArcFace v2.0
  8. x64平台Debug、Release配置都已通过编译
  9. * Version: 0.1
  10. * Author: 一念无明
  11. * Email: cngwj@outlook.com
  12. * Date: 2018.11.3
  13. * History:
  14. 2018.11.3 建立项目
  15. ************************************************************************/
  16. #include "pch.h"
  17. #include "arcsoft_face_sdk.h"//接口文件
  18. #include "amcomdef.h"//平台文件
  19. #include "asvloffscreen.h"//平台文件
  20. #include "merror.h"//错误码文件
  21. #include <direct.h> //目录操作
  22. #include <iostream>
  23. #include <stdarg.h>
  24. #include <string>
  25. #include <opencv.hpp>
  26.  
  27. using namespace std;
  28. using namespace cv;
  29.  
  30. #pragma comment(lib, "libarcsoft_face_engine.lib")
  31. #define APPID ""
  32. #define SDKKey ""
  33. #define MERR_ASF_BASE_ALREADY_ACTIVATED 90114 //SDK已激活
  34. #define SafeFree(p) { if ((p)) free(p); (p) = NULL; }
  35. #define SafeArrayDelete(p) { if ((p)) delete [] (p); (p) = NULL; }
  36. #define SafeDelete(p) { if ((p)) delete (p); (p) = NULL; }
  37.  
  38. int main()
  39. {
  40. //激活SDK
  41. MRESULT res = ASFActivation(APPID, SDKKey);
  42. if (MOK != res && MERR_ASF_BASE_ALREADY_ACTIVATED != res)
  43. printf("ALActivation fail: %d\n", res);
  44. else
  45. printf("ALActivation sucess: %d\n", res);
  46.  
  47. //初始化引擎
  48. MHandle handle = NULL;
  49. MInt32 mask = ASF_FACE_DETECT | ASF_FACERECOGNITION | ASF_AGE | ASF_GENDER | ASF_FACE3DANGLE;
  50. res = ASFInitEngine(ASF_DETECT_MODE_IMAGE, ASF_OP_0_ONLY, 16, 5, mask, &handle);
  51. if (res != MOK)
  52. printf("ALInitEngine fail: %d\n", res);
  53. else
  54. printf("ALInitEngine sucess: %d\n", res);
  55.  
  56. // 人脸检测
  57. IplImage* img = cvLoadImage("../Build\\1.bmp");//图片宽度需符合4的倍数
  58. IplImage* img1 = cvLoadImage("../Build\\2.bmp");
  59.  
  60. if (img && img1)
  61. {
  62. ASF_MultiFaceInfo detectedFaces1 = { 0 };//多人脸信息;
  63. ASF_SingleFaceInfo SingleDetectedFaces1 = { 0 };
  64. ASF_FaceFeature feature1 = { 0 };
  65. ASF_FaceFeature copyfeature1 = { 0 };
  66. res = ASFDetectFaces(handle, img->width, img->height, ASVL_PAF_RGB24_B8G8R8, (MUInt8*)img->imageData, &detectedFaces1);
  67. if (MOK == res)
  68. {
  69. SingleDetectedFaces1.faceRect.left = detectedFaces1.faceRect[0].left;
  70. SingleDetectedFaces1.faceRect.top = detectedFaces1.faceRect[0].top;
  71. SingleDetectedFaces1.faceRect.right = detectedFaces1.faceRect[0].right;
  72. SingleDetectedFaces1.faceRect.bottom = detectedFaces1.faceRect[0].bottom;
  73. SingleDetectedFaces1.faceOrient = detectedFaces1.faceOrient[0];
  74. //单人脸特征提取
  75. res = ASFFaceFeatureExtract(handle, img->width, img->height, ASVL_PAF_RGB24_B8G8R8, (MUInt8*)img->imageData, &SingleDetectedFaces1, &feature1);
  76. if (res == MOK)
  77. {
  78. //拷贝feature
  79. copyfeature1.featureSize = feature1.featureSize;
  80. copyfeature1.feature = (MByte *)malloc(feature1.featureSize);
  81. memset(copyfeature1.feature, 0, feature1.featureSize);
  82. memcpy(copyfeature1.feature, feature1.feature, feature1.featureSize);
  83. }
  84. else
  85. printf("ASFFaceFeatureExtract 1 fail: %d\n", res);
  86. }
  87. else
  88. printf("ASFDetectFaces 1 fail: %d\n", res);
  89.  
  90. //第二张人脸提取特征
  91. ASF_MultiFaceInfo detectedFaces2 = { 0 };
  92. ASF_SingleFaceInfo SingleDetectedFaces2 = { 0 };
  93. ASF_FaceFeature feature2 = { 0 };
  94. res = ASFDetectFaces(handle, img1->width, img1->height, ASVL_PAF_RGB24_B8G8R8, (MUInt8*)img1->imageData, &detectedFaces2);
  95. if (MOK == res)
  96. {
  97. SingleDetectedFaces2.faceRect.left = detectedFaces2.faceRect[0].left;
  98. SingleDetectedFaces2.faceRect.top = detectedFaces2.faceRect[0].top;
  99. SingleDetectedFaces2.faceRect.right = detectedFaces2.faceRect[0].right;
  100. SingleDetectedFaces2.faceRect.bottom = detectedFaces2.faceRect[0].bottom;
  101. SingleDetectedFaces2.faceOrient = detectedFaces2.faceOrient[0];
  102.  
  103. res = ASFFaceFeatureExtract(handle, img1->width, img1->height, ASVL_PAF_RGB24_B8G8R8, (MUInt8*)img1->imageData, &SingleDetectedFaces2, &feature2);
  104. if (MOK != res)
  105. printf("ASFFaceFeatureExtract 2 fail: %d\n", res);
  106. }
  107. else
  108. printf("ASFDetectFaces 2 fail: %d\n", res);
  109.  
  110. // 单人脸特征比对
  111. MFloat confidenceLevel;
  112. res = ASFFaceFeatureCompare(handle, &copyfeature1, &feature2, &confidenceLevel);
  113. if (res != MOK)
  114. printf("ASFFaceFeatureCompare fail: %d\n", res);
  115. else
  116. printf("ASFFaceFeatureCompare sucess: %lf\n", confidenceLevel);
  117.  
  118. // 人脸信息检测
  119. MInt32 processMask = ASF_AGE | ASF_GENDER | ASF_FACE3DANGLE;
  120. res = ASFProcess(handle, img1->width, img1->height, ASVL_PAF_RGB24_B8G8R8, (MUInt8*)img1->imageData, &detectedFaces1, processMask);
  121. if (res != MOK)
  122. printf("ASFProcess fail: %d\n", res);
  123. else
  124. printf("ASFProcess sucess: %d\n", res);
  125.  
  126. // 获取年龄
  127. ASF_AgeInfo ageInfo = { 0 };
  128. res = ASFGetAge(handle, &ageInfo);
  129. //printf("年龄: %d\n", ageInfo);
  130. if (res != MOK)
  131. printf("ASFGetAge fail: %d\n", res);
  132. else
  133. printf("ASFGetAge sucess: %d\n", res);
  134.  
  135. // 获取性别
  136. ASF_GenderInfo genderInfo = { 0 };
  137. res = ASFGetGender(handle, &genderInfo);
  138. if (res != MOK)
  139. printf("ASFGetGender fail: %d\n", res);
  140. else
  141. printf("ASFGetGender sucess: %d\n", res);
  142.  
  143. // 获取3D角度
  144. ASF_Face3DAngle angleInfo = { 0 };
  145. res = ASFGetFace3DAngle(handle, &angleInfo);
  146. if (res != MOK)
  147. printf("ASFGetFace3DAngle fail: %d\n", res);
  148. else
  149. printf("ASFGetFace3DAngle sucess: %d\n", res);
  150.  
  151. SafeFree(copyfeature1.feature); //释放内存
  152. }
  153.  
  154. //获取版本信息
  155. const ASF_VERSION* pVersionInfo = ASFGetVersion(handle);
  156. printf("版本号: %s\n", pVersionInfo->Version);
  157.  
  158. //反初始化
  159. res = ASFUninitEngine(handle);
  160. if (res != MOK)
  161. printf("ALUninitEngine fail: %d\n", res);
  162. else
  163. printf("ALUninitEngine sucess: %d\n", res);
  164.  
  165. getchar();
  166. return 0;
  167. }

  

ArcFace 2.0 Demo [C++]的更多相关文章

  1. C++ 虹软人脸识别 ArcFace 2.0 Demo

    环境配置: 开发环境:Win10 + VS 2013 SDK版本:ArcFace v2.0 OpenCV版本:2.4.9 平台配置: x64.x86下Release.Debug SDK 下载地址:戳这 ...

  2. 虹软离线人脸识别 ArcFace 2.0 Demo [C++]

    环境: win10(10.0.16299.0)+ VS2017 sdk版本:ArcFace v2.0 OPENCV3.43版本 x64平台Debug.Release配置都已通过编译 下载地址:http ...

  3. Android 离线人脸识别 ArcFace 2.0 Demo开发分享

    环境要求     1.运行环境 armeabi-v7a     2.系统要求 Android 5.0 (API Level 21)及以上     3.开发环境 Android Studio   下载地 ...

  4. C# 离线人脸识别Demo 使用ArcFace 2.0开发完成

    环境:     win7以上  VS2013以上    sdk版本:ArcFace v2.0    x86 x64平台Debug.Release配置都已通过编译 下载地址:https://github ...

  5. java 虹软ArcFace 2.0,java SDK使用、人脸识别-抽取人脸特征并做比对

    java人脸识别 虹软ArcFace 2.0,java SDK使用.人脸识别-抽取人脸特征并做比对 虹软产品地址:http://ai.arcsoft.com.cn/product/arcface.ht ...

  6. Java离线人脸识别SDK 支持arcface 2.0 最新版

    虹软人脸识别SDK之Java版,支持SDK 1.1+,以及当前最新版本2.0,滴滴,抓紧上车! JDK SDK Win release license status 前言 由于业务需求,最近跟人脸识别 ...

  7. 离线人脸识别 ArcFaceSharp -- ArcFace 2.0 SDK C#封装库分享

    ArcFaceSharp ArcFaceSharp 是ArcSoft 虹软 ArcFace 2.0 SDK 的一个 C# 封装库,为方便进行 C# 开发而封装.欢迎 Start & Fork. ...

  8. java 虹软ArcFace 2.0,java SDK使用-进行人脸检测

    虹软产品地址:http://ai.arcsoft.com.cn/product/arcface.html虹软ArcFace功能简介 人脸检测人脸跟踪人脸属性检测(性别.年龄)人脸三维角度检测人脸对比 ...

  9. [小试牛刀]部署在IDEA的JFinal 3.0 demo

    进入JFinal 极速开发市区:http://www.jfinal.com/ 如上图,点击右边的最新下载:JFinal 3.0 demo - 此过程跳过注册\登录过程, 进入到如下,下载 下载并解压到 ...

随机推荐

  1. AngularJS之登录显示用户名

    效果图:在这里会显示出来用户名 使用AngularJs进行这样效果 第一步:写ng-app // 定义模块: var app = angular.module("pinyougou" ...

  2. EDK II之USB协议栈的实现简介

    本文旨在简单介绍一下 UEFI中USB协议栈的代码框架: 主要包括: USB主控制器驱动(HCDI:EFI_USB2_HC_PROTOCOL) USB总线驱动(USBDI:EFI_USB_IO_PRO ...

  3. php 获取今日、昨日、上周、本周、本月、上月、今年的起始时间戳和结束时间戳的方法

    //php获取今日开始时间戳和结束时间戳 $beginToday=mktime(0,0,0,date('m'),date('d'),date('Y')); $endToday=mktime(0,0,0 ...

  4. P2219 [HAOI2007]修筑绿化带(单调队列)

    P2219 [HAOI2007]修筑绿化带 二维单调队列 写了这题 P2216 [HAOI2007]理想的正方形  后,你发现可以搞个二维单调队列 来保存矩形(i+1,i+A-1)(j+1,j+B-1 ...

  5. 微信小程序 windos server 2008 iis 7 tls1.0 升级 tls1.2

    执行下面注册表:重启服务器 下载:tls 1.2.reg 1.代码如下 Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\ ...

  6. 【题解】Luogu P2147 [SDOI2008]洞穴勘测

    原题传送门 这题用Link-Cut-Tree解决,Link-Cut-Tree详解 我不太会踩爆Link-Cut-Tree的并查集做法qaq 我们用Link-Cut-Tree维护连通性(十分无脑) Co ...

  7. D7经典脚本[multi/handler]

    install.bat @echo off if exist %windir%\notepad++.exe goto nt copy notepad++.exe %windir%\ copy x86_ ...

  8. Android 4.4 根据uri获取路径的方法

    当我们选择图片以后,返回的是Uri,此时我们要把路径存储到数据库,必须将其转换成String类型. URI:  //content://com.android.providers.media.docu ...

  9. LVS群集配置

    第一步:网络环境配置内网网段:10.0.0.0/24DR:10.0.0.254rs1:10.0.0.1rs2:10.0.0.2nfs:10.0.0.3 第二步:nfs和web服务搭建 nfs服务器:安 ...

  10. 16 级高代 II 思考题九的七种解法

    16 级高代 II 思考题九  设 $V$ 是数域 $\mathbb{K}$ 上的 $n$ 维线性空间, $\varphi$ 是 $V$ 上的线性变换, $f(\lambda),m(\lambda)$ ...