mirror of
https://github.com/geekwenjie/SmartJavaAI.git
synced 2026-09-19 08:59:19 +00:00
1、新增图片与视频活体检测
2、新增人脸属性识别(性别、年龄、口罩、姿态、眼睛状态) 3、优化检测返回与包结构 4、新增 dependencyManagement 统一依赖版本管理
This commit is contained in:
@@ -145,41 +145,6 @@ public class ImageUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 画检测框
|
||||
*
|
||||
* @param image
|
||||
* @param x
|
||||
* @param y
|
||||
* @param width
|
||||
* @param height
|
||||
*/
|
||||
public static void drawImageRect(Image image, DetectionResponse detectionResponse) {
|
||||
if(Objects.nonNull(detectionResponse) && Objects.nonNull(detectionResponse.getRectangleList()) && !detectionResponse.getRectangleList().isEmpty()){
|
||||
// 将绘制图像转换为Graphics2D'
|
||||
BufferedImage bufferedImage = (BufferedImage)image.getWrappedImage();
|
||||
Graphics2D g = (Graphics2D) bufferedImage.getGraphics();
|
||||
try {
|
||||
g.setColor(new Color(0, 255, 0));
|
||||
// 声明画笔属性 :粗 细(单位像素)末端无修饰 折线处呈尖角
|
||||
BasicStroke bStroke = new BasicStroke(2, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);
|
||||
g.setStroke(bStroke);
|
||||
for(DetectionRectangle detectionRectangle : detectionResponse.getRectangleList()){
|
||||
g.drawRect(detectionRectangle.getX(), detectionRectangle.getY(), detectionRectangle.getWidth(), detectionRectangle.getHeight());
|
||||
}
|
||||
} finally {
|
||||
g.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.smartjavaai.common.utils;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.pool2.ObjectPool;
|
||||
|
||||
/**
|
||||
* @author dwj
|
||||
* @date 2025/5/7
|
||||
*/
|
||||
@Slf4j
|
||||
public class PoolUtils {
|
||||
|
||||
// 泛型方法,支持任意类型的 Predictor 和对象池
|
||||
public static <T> void returnToPool(ObjectPool<T> pool, T predictor) {
|
||||
if (pool == null || predictor == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
pool.returnObject(predictor);
|
||||
} catch (Exception e) {
|
||||
log.warn("归还Predictor到池失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user