ArcFace 2.0 Demo [C++]
环境: 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 参考代码
/************************************************************************
* Copyright(c) 2018
* All rights reserved.
* File: samplecode.cpp
* Brief: Powered by ArcSoft
环境: win10(10.0.16299.0)+ VS2017
sdk版本:ArcFace v2.0
x64平台Debug、Release配置都已通过编译
* Version: 0.1
* Author: 一念无明
* Email: cngwj@outlook.com
* Date: 2018.11.3
* History:
2018.11.3 建立项目
************************************************************************/
#include "pch.h"
#include "arcsoft_face_sdk.h"//接口文件
#include "amcomdef.h"//平台文件
#include "asvloffscreen.h"//平台文件
#include "merror.h"//错误码文件
#include <direct.h> //目录操作
#include <iostream>
#include <stdarg.h>
#include <string>
#include <opencv.hpp> using namespace std;
using namespace cv; #pragma comment(lib, "libarcsoft_face_engine.lib")
#define APPID ""
#define SDKKey ""
#define MERR_ASF_BASE_ALREADY_ACTIVATED 90114 //SDK已激活
#define SafeFree(p) { if ((p)) free(p); (p) = NULL; }
#define SafeArrayDelete(p) { if ((p)) delete [] (p); (p) = NULL; }
#define SafeDelete(p) { if ((p)) delete (p); (p) = NULL; } int main()
{
//激活SDK
MRESULT res = ASFActivation(APPID, SDKKey);
if (MOK != res && MERR_ASF_BASE_ALREADY_ACTIVATED != res)
printf("ALActivation fail: %d\n", res);
else
printf("ALActivation sucess: %d\n", res); //初始化引擎
MHandle handle = NULL;
MInt32 mask = ASF_FACE_DETECT | ASF_FACERECOGNITION | ASF_AGE | ASF_GENDER | ASF_FACE3DANGLE;
res = ASFInitEngine(ASF_DETECT_MODE_IMAGE, ASF_OP_0_ONLY, 16, 5, mask, &handle);
if (res != MOK)
printf("ALInitEngine fail: %d\n", res);
else
printf("ALInitEngine sucess: %d\n", res); // 人脸检测
IplImage* img = cvLoadImage("../Build\\1.bmp");//图片宽度需符合4的倍数
IplImage* img1 = cvLoadImage("../Build\\2.bmp"); if (img && img1)
{
ASF_MultiFaceInfo detectedFaces1 = { 0 };//多人脸信息;
ASF_SingleFaceInfo SingleDetectedFaces1 = { 0 };
ASF_FaceFeature feature1 = { 0 };
ASF_FaceFeature copyfeature1 = { 0 };
res = ASFDetectFaces(handle, img->width, img->height, ASVL_PAF_RGB24_B8G8R8, (MUInt8*)img->imageData, &detectedFaces1);
if (MOK == res)
{
SingleDetectedFaces1.faceRect.left = detectedFaces1.faceRect[0].left;
SingleDetectedFaces1.faceRect.top = detectedFaces1.faceRect[0].top;
SingleDetectedFaces1.faceRect.right = detectedFaces1.faceRect[0].right;
SingleDetectedFaces1.faceRect.bottom = detectedFaces1.faceRect[0].bottom;
SingleDetectedFaces1.faceOrient = detectedFaces1.faceOrient[0];
//单人脸特征提取
res = ASFFaceFeatureExtract(handle, img->width, img->height, ASVL_PAF_RGB24_B8G8R8, (MUInt8*)img->imageData, &SingleDetectedFaces1, &feature1);
if (res == MOK)
{
//拷贝feature
copyfeature1.featureSize = feature1.featureSize;
copyfeature1.feature = (MByte *)malloc(feature1.featureSize);
memset(copyfeature1.feature, 0, feature1.featureSize);
memcpy(copyfeature1.feature, feature1.feature, feature1.featureSize);
}
else
printf("ASFFaceFeatureExtract 1 fail: %d\n", res);
}
else
printf("ASFDetectFaces 1 fail: %d\n", res); //第二张人脸提取特征
ASF_MultiFaceInfo detectedFaces2 = { 0 };
ASF_SingleFaceInfo SingleDetectedFaces2 = { 0 };
ASF_FaceFeature feature2 = { 0 };
res = ASFDetectFaces(handle, img1->width, img1->height, ASVL_PAF_RGB24_B8G8R8, (MUInt8*)img1->imageData, &detectedFaces2);
if (MOK == res)
{
SingleDetectedFaces2.faceRect.left = detectedFaces2.faceRect[0].left;
SingleDetectedFaces2.faceRect.top = detectedFaces2.faceRect[0].top;
SingleDetectedFaces2.faceRect.right = detectedFaces2.faceRect[0].right;
SingleDetectedFaces2.faceRect.bottom = detectedFaces2.faceRect[0].bottom;
SingleDetectedFaces2.faceOrient = detectedFaces2.faceOrient[0]; res = ASFFaceFeatureExtract(handle, img1->width, img1->height, ASVL_PAF_RGB24_B8G8R8, (MUInt8*)img1->imageData, &SingleDetectedFaces2, &feature2);
if (MOK != res)
printf("ASFFaceFeatureExtract 2 fail: %d\n", res);
}
else
printf("ASFDetectFaces 2 fail: %d\n", res); // 单人脸特征比对
MFloat confidenceLevel;
res = ASFFaceFeatureCompare(handle, ©feature1, &feature2, &confidenceLevel);
if (res != MOK)
printf("ASFFaceFeatureCompare fail: %d\n", res);
else
printf("ASFFaceFeatureCompare sucess: %lf\n", confidenceLevel); // 人脸信息检测
MInt32 processMask = ASF_AGE | ASF_GENDER | ASF_FACE3DANGLE;
res = ASFProcess(handle, img1->width, img1->height, ASVL_PAF_RGB24_B8G8R8, (MUInt8*)img1->imageData, &detectedFaces1, processMask);
if (res != MOK)
printf("ASFProcess fail: %d\n", res);
else
printf("ASFProcess sucess: %d\n", res); // 获取年龄
ASF_AgeInfo ageInfo = { 0 };
res = ASFGetAge(handle, &ageInfo);
//printf("年龄: %d\n", ageInfo);
if (res != MOK)
printf("ASFGetAge fail: %d\n", res);
else
printf("ASFGetAge sucess: %d\n", res); // 获取性别
ASF_GenderInfo genderInfo = { 0 };
res = ASFGetGender(handle, &genderInfo);
if (res != MOK)
printf("ASFGetGender fail: %d\n", res);
else
printf("ASFGetGender sucess: %d\n", res); // 获取3D角度
ASF_Face3DAngle angleInfo = { 0 };
res = ASFGetFace3DAngle(handle, &angleInfo);
if (res != MOK)
printf("ASFGetFace3DAngle fail: %d\n", res);
else
printf("ASFGetFace3DAngle sucess: %d\n", res); SafeFree(copyfeature1.feature); //释放内存
} //获取版本信息
const ASF_VERSION* pVersionInfo = ASFGetVersion(handle);
printf("版本号: %s\n", pVersionInfo->Version); //反初始化
res = ASFUninitEngine(handle);
if (res != MOK)
printf("ALUninitEngine fail: %d\n", res);
else
printf("ALUninitEngine sucess: %d\n", res); getchar();
return 0;
}
ArcFace 2.0 Demo [C++]的更多相关文章
- C++ 虹软人脸识别 ArcFace 2.0 Demo
环境配置: 开发环境:Win10 + VS 2013 SDK版本:ArcFace v2.0 OpenCV版本:2.4.9 平台配置: x64.x86下Release.Debug SDK 下载地址:戳这 ...
- 虹软离线人脸识别 ArcFace 2.0 Demo [C++]
环境: win10(10.0.16299.0)+ VS2017 sdk版本:ArcFace v2.0 OPENCV3.43版本 x64平台Debug.Release配置都已通过编译 下载地址:http ...
- Android 离线人脸识别 ArcFace 2.0 Demo开发分享
环境要求 1.运行环境 armeabi-v7a 2.系统要求 Android 5.0 (API Level 21)及以上 3.开发环境 Android Studio 下载地 ...
- C# 离线人脸识别Demo 使用ArcFace 2.0开发完成
环境: win7以上 VS2013以上 sdk版本:ArcFace v2.0 x86 x64平台Debug.Release配置都已通过编译 下载地址:https://github ...
- java 虹软ArcFace 2.0,java SDK使用、人脸识别-抽取人脸特征并做比对
java人脸识别 虹软ArcFace 2.0,java SDK使用.人脸识别-抽取人脸特征并做比对 虹软产品地址:http://ai.arcsoft.com.cn/product/arcface.ht ...
- Java离线人脸识别SDK 支持arcface 2.0 最新版
虹软人脸识别SDK之Java版,支持SDK 1.1+,以及当前最新版本2.0,滴滴,抓紧上车! JDK SDK Win release license status 前言 由于业务需求,最近跟人脸识别 ...
- 离线人脸识别 ArcFaceSharp -- ArcFace 2.0 SDK C#封装库分享
ArcFaceSharp ArcFaceSharp 是ArcSoft 虹软 ArcFace 2.0 SDK 的一个 C# 封装库,为方便进行 C# 开发而封装.欢迎 Start & Fork. ...
- java 虹软ArcFace 2.0,java SDK使用-进行人脸检测
虹软产品地址:http://ai.arcsoft.com.cn/product/arcface.html虹软ArcFace功能简介 人脸检测人脸跟踪人脸属性检测(性别.年龄)人脸三维角度检测人脸对比 ...
- [小试牛刀]部署在IDEA的JFinal 3.0 demo
进入JFinal 极速开发市区:http://www.jfinal.com/ 如上图,点击右边的最新下载:JFinal 3.0 demo - 此过程跳过注册\登录过程, 进入到如下,下载 下载并解压到 ...
随机推荐
- 给PXC集群加密
MySQL的复制时明文的,不管是集群的复制还是IST/SST,直接通过抓包就可以抓取数据. 生成证书 直接使用 mysql_ssl_rsa_setup mysql_ssl_rsa_setup --da ...
- P1501 [国家集训队]Tree II(LCT)
P1501 [国家集训队]Tree II 看着维护吧2333333 操作和维护区间加.乘线段树挺像的 进行修改操作时不要忘记吧每个点的点权$v[i]$也处理掉 还有就是$51061^2=2607225 ...
- neutron 的 quota design
发现, cinder, nova 制实现了, CountableResource. 只有nuetron实现了 TrackedResource 和 CountableResource. I read u ...
- 2018-2019-2 《网络对抗技术》Exp0 Kali安装 Week1 20165211
目录 软件和镜像下载 虚拟机软件 Kali系统的下载 Kali系统安装 网络配置 设置共享文件夹和剪切板 安装VMware增强工具 设置共享文件夹 设置共享剪切板 更新软件源 软件和镜像下载 虚拟机软 ...
- 尚硅谷面试第一季-07Spring Bean的作用域之间有什么区别
目录结构: 关键性代码: beans.xml <!-- ★bean的作用域 可以通过scope属性来指定bean的作用域 -singleton:默认值.当IOC容器一创建就会创建bean的实例, ...
- xlrd、xlwt 操作excel表格详解
转自:https://www.cnblogs.com/jiablogs/p/9141414.html python操作excel主要用到xlrd和xlwt这两个库,即xlrd是读excel,xlwt是 ...
- ODAC(V9.5.15) 学习笔记(四)TMemDataSet (3)
3.其他 名称 类型 说明 GetBlob TBlob 按照字段名获取当前数据集中某个Blob类型的字段值,并以TBlob对象形式返回 Prepared Boolean 检查Query的SQL是否已准 ...
- js 根据对象属性对数组进行按字母排序
$scope.input.sort(compare('ticked','name')); var compare = function(ticked, name){ return function(a ...
- Linux电源管理(五)thermal【转】
本文转载自:https://blog.csdn.net/zhouhuacai/article/details/78172267 版权声明:本文为博主原创文章,未经博主允许不得转载. https: ...
- 螺旋折线(可能是最简单的找规律)【蓝桥杯2018 C/C++ B组】
标题:螺旋折线 如图p1.png所示的螺旋折线经过平面上所有整点恰好一次. 对于整点(X, Y),我们定义它到原点的距离dis(X, Y)是从原点到(X, Y)的螺旋折线段的长度. 例如dis(0 ...