This commit is contained in:
2025-11-07 14:27:05 +08:00
parent 86b44282ea
commit 864eb1462f
4 changed files with 14 additions and 11 deletions

View File

@ -42,6 +42,7 @@ public class BaiDuFace {
private static final String FACE_COMPARE_URL = "https://aip.baidubce.com/rest/2.0/face/v3/match?access_token=%s"; private static final String FACE_COMPARE_URL = "https://aip.baidubce.com/rest/2.0/face/v3/match?access_token=%s";
/** /**
* 人脸识别+人脸检测 * 人脸识别+人脸检测
* *
@ -147,7 +148,6 @@ public class BaiDuFace {
} }
} }
/** /**
* 人脸对比(计算人脸相似度) * 人脸对比(计算人脸相似度)
* *

View File

@ -13,16 +13,18 @@ import org.springframework.stereotype.Component;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import java.awt.*; import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream; import java.io.*;
import java.io.ByteArrayOutputStream; import java.net.*;
import java.io.IOException; import java.nio.file.Files;
import java.net.FileNameMap; import java.util.ArrayList;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLConnection;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
/** /**
* @author lilemy * @author lilemy
* @date 2025/7/21 10:56 * @date 2025/7/21 10:56
@ -34,6 +36,7 @@ public class RecognizerManager {
@Resource @Resource
private RecognizerProperties recognizerProperties; private RecognizerProperties recognizerProperties;
/** /**
* 识别图片 * 识别图片
* *
@ -65,7 +68,7 @@ public class RecognizerManager {
* @param targets 识别结果 * @param targets 识别结果
* @return 绘制后的图片 * @return 绘制后的图片
*/ */
public RecognizeImageStreamResult drawImageToStream(String imgUrl, List<RecognizeTargetVo> targets) throws IOException, URISyntaxException { public static RecognizeImageStreamResult drawImageToStream(String imgUrl, List<RecognizeTargetVo> targets) throws IOException, URISyntaxException {
// 1. 加载图片 // 1. 加载图片
URI uri = new URI(imgUrl); URI uri = new URI(imgUrl);
BufferedImage image = ImageIO.read(uri.toURL()); BufferedImage image = ImageIO.read(uri.toURL());

View File

@ -50,7 +50,7 @@ public class RecognizerUtils {
.body(JSONUtil.toJsonStr(paramMap)) .body(JSONUtil.toJsonStr(paramMap))
.execute()) { .execute()) {
if (!response.isOk()) { if (!response.isOk()) {
log.error("{}{}", errorMsg, response.getStatus()); log.error("{}{}:路径为- {}", errorMsg, response.getStatus(), capUrl);
throw new ServiceException(errorMsg + response.getStatus()); throw new ServiceException(errorMsg + response.getStatus());
} }
String body = response.body(); String body = response.body();

View File

@ -13,7 +13,7 @@ import java.util.stream.Collectors;
@Getter @Getter
public enum RecognizerTypeEnum { public enum RecognizerTypeEnum {
// WEARING_ALL("穿戴安全帽反光衣", "wearingall", "1"), // WEARING_ALL("穿戴安全帽反光衣", "wearingall", "1"),
// NO_EQUIPMENT("没穿安全帽反光衣", "noequipment", "2"), // NO_EQUIPMENT("没穿安全帽反光衣", "noequipment", "2"),
NO_HELMET("未戴安全帽", "nohelmet", "3"), NO_HELMET("未戴安全帽", "nohelmet", "3"),
NO_VEST("未穿反光衣", "novest", "4"), NO_VEST("未穿反光衣", "novest", "4"),