mirror of
https://github.com/geekwenjie/SmartJavaAI.git
synced 2026-09-19 08:59:19 +00:00
新增目标检测功能
This commit is contained in:
@@ -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(); // 确保是文件且存在
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user