# arcsoft-face-pro
**Repository Path**: qiling/arcsoft-face-pro
## Basic Information
- **Project Name**: arcsoft-face-pro
- **Description**: 虹软人脸识别离线SDK人脸检测、比对Web服务
- **Primary Language**: Java
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 5
- **Created**: 2025-05-20
- **Last Updated**: 2025-05-20
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# 虹软人脸识别离线SDK人脸检测、比对Web服务
### 介绍
* 使用虹软人脸识别离线SDK实现的一个人脸检测、比对Web服务。
* 使用【 [Apache Commons Pool2](https://commons.apache.org/proper/commons-pool/) 】连接池实现多线程调用。
### 注意
* 此项目集成的是虹软人脸识别Windows(X86)离线SDK免费版,人脸引擎库下载起1年到期,到期后需要重新下载人脸引擎库覆盖到【 [lib-path](src/main/resources/application.yml) 】目录。
* 使用其他平台的版本(如:Windows(X64)、Linux64),需要下载相应平台的人脸引擎库。
* Java JRE运行环境需要使用相应平台的版本。
* 使用人脸识别增值版付费版,需要设置【 [face.config.active-key](src/main/resources/application.yml) 】与【[pom.xml](pom.xml)】中更换【 [arcsoft-sdk-face-3.0.0.0.jar](lib/arcsoft-sdk-face-3.0.0.0.jar) 】文件。
~~~
com.arcsoft.face
arcsoft-sdk-face
3.0.0.0
jar
system
${basedir}/lib/arcsoft-sdk-face-3.0.0.0.jar
~~~
* 免费版与付费版中的区别是激活方法中多了一个参数。
~~~
FaceEngine faceEngine=new FaceEngine();
//免费版
faceEngine.activeOnline(String appId, String sdkKey);
//付费版
faceEngine.activeOnline(String appId, String sdkKey, String activeKey);
~~~
### 配置
~~~
face:
config:
face-max-threads: 10 #人脸引擎线程个数,-1使用Java虚拟机可用的处理器数(创建人脸引擎的数量)
face-max-wait: 5s #获取连接池中人脸引擎的最大等待时间
face-threshold: 0.8 #人脸比对阈值(范围0~1 推荐阈值0.8)
support-liveness: false #是否人脸活体检测(为True时进行生活照活体检测)
liveness-rgb-threshold: 0.5 #RGB活体阈值(默认0.5)
liveness-ir-threshold: 0.7 #IR活体阈值(默认0.7)
app-id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx #通过虹软网站获取
sdk-key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx #通过虹软网站获取
active-key: xxxx-xxxx-xxxx-xxxx #通过虹软网站获取
lib-path: D:/Workspace/idea/ifacebox-arcsoft-face-pro/lib/win32-x86 #人脸引擎库存放路径
~~~
### 负载均衡
* Springboot启动时如果创建人脸引擎的数量过多,人脸引擎会返回内存不足的错误。
* 解决方法启动多个Springboot服务,使用Nginx配置负载均衡。
**注:此问题出现在使用32位版本的JRE与人脸引擎库,建议在64位操作系统上使用64位版本的JRE与人脸引擎库更加稳定。**
~~~
upstream arcsoft-face-pro {
server localhost:9526;
server localhost:9527;
}
server {
listen 9528;
server_name localhost;
location / {
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://arcsoft-face-pro;
}
proxy_connect_timeout 10s;
proxy_read_timeout 10s;
proxy_send_timeout 10s;
}
~~~
### 测试工具
[WebFaceTests.java](src/test/java/com/ifacebox/arcsoft/face/WebFaceTests.java)

### 接口描述
* 人脸检测、比对在线接口。
#### 通讯协议说明
~~~
Accept:application/json
Content-Type:application/json;charset=UTF-8
~~~
#### 消息报文定义
* 人脸比对、检测 http://127.0.0.1:8528/ScFaceWeb/face/compare
~~~
{
image1 : "base64",// 证件照
image2 : "base64"// 生活照
}
~~~
~~~
{
success : true,// 是否成功
msg : "成功",// 失败信息
data : {
score : 0.8,// 人脸比分范围(0~1)
score_limit : 0.8,// 比分阈值
face : [ {
x : 0,
y : 0,
width : 80,
heigth : 80
} ]// 人脸位置,如果有多张人脸,尺寸最大为参与比对的人脸
}
}
~~~
* 人脸检测 http://127.0.0.1:8528/ScFaceWeb/face/detection
~~~
{
image : "base64"// 生活照
}
~~~
~~~
{
success : true,// 是否成功
msg : "成功",// 失败信息
data : {
face : [ {
x : 0,
y : 0,
width : 80,
heigth : 80
} ]// 人脸位置
}
}
~~~