新增目标检测功能

This commit is contained in:
dengwenjie
2025-04-13 20:33:15 +08:00
parent 4eb02c6d87
commit 241b816e7f
56 changed files with 3300 additions and 1993 deletions

View File

@@ -0,0 +1,21 @@
package cn.smartjavaai.common.utils;
import java.io.File;
/**
* 文件操作工具类
* @author dwj
* @date 2025/4/4
*/
public class FileUtils {
/**
* 检查文件是否存在
* @param filePath
* @return
*/
public static boolean isFileExists(String filePath) {
File file = new File(filePath);
return file.exists() && !file.isDirectory(); // 确保是文件且存在
}
}

View File

@@ -1,8 +1,12 @@
package cn.smartjavaai.common.utils;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
//import java.awt.image.ColorConvertOp;
import java.awt.image.ComponentSampleModel;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
/**
@@ -74,4 +78,18 @@ public class ImageUtils {
return image;
}
/**
* 检查图像是否有效
* @param image
* @return
*/
public static boolean isImageValid(BufferedImage image) {
// 检查是否为 null 或尺寸异常如宽高为0
return image != null && image.getWidth() > 0 && image.getHeight() > 0;
}
}