springboot 集成虹软
时间: 2023-11-17 12:01:49 浏览: 134
在Spring Boot中集成虹软需要进行以下步骤:
1. 在虹软官网上免费申请并下载所需的libarcsoft_face.dll(so)、libarcsoft_face_engine.dll(so)、libarcsoft_face_engine_jni.dll(so)、app-id、sdk-key等文件。
2. 将下载的文件放置在项目的指定目录下。
3. 在pom.xml文件中添加虹软依赖。
4. 在Spring Boot的配置文件中配置虹软相关参数。
5. 在代码中调用虹软提供的API进行人脸识别等操作。
下面是一个简单的示例代码,用于在Spring Boot中调用虹软API进行人脸识别:
```java
@Service
public class FaceRecognitionService {
@Value("${arcsoft.app-id}")
private String appId;
@Value("${arcsoft.sdk-key}")
private String sdkKey; @Value("${arcsoft.lib-path}")
private String libPath;
private FaceEngine faceEngine;
@PostConstruct
public void init() {
faceEngine = new FaceEngine(libPath);
int activeCode = faceEngine.activeOnline(appId, sdkKey);
if (activeCode != ErrorInfo.MOK.getValue() && activeCode != ErrorInfo.MERR_ASF_ALREADY_ACTIVATED.getValue()) {
throw new RuntimeException("虹软人脸识别引擎激活失败,错误码:" + activeCode);
}
}
public List<FaceInfo> detectFaces(byte[] imageData) {
ImageInfo imageInfo = new ImageInfo();
imageInfo.setWidth(640); imageInfo.setHeight(480);
imageInfo.setImageFormat(ImageFormat.CP_PAF_BGR24);
imageInfo.setImageData(imageData);
List<FaceInfo> faceInfoList = new ArrayList<>();
int detectCode = faceEngine.detectFaces(imageInfo.getImageData(), imageInfo.getWidth(), imageInfo.getHeight(), imageInfo.getImageFormat(), faceInfoList);
if (detectCode != ErrorInfo.MOK.getValue()) {
throw new RuntimeException("人脸检测失败,错误码:" + detectCode);
}
return faceInfoList;
}
}
```
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)