public class ImageUtils extends Object
| 构造器和说明 |
|---|
ImageUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static BufferedImage |
bgrToBufferedImage(byte[] data,
int width,
int height) |
static void |
drawImageRect(BufferedImage image,
int x,
int y,
int width,
int height)
画检测框
|
static void |
drawImageRect(BufferedImage image,
ai.djl.ndarray.NDArray box)
画检测框(有倾斜角)
|
static void |
drawImageRect(ai.djl.modality.cv.Image image,
int x,
int y,
int width,
int height)
画检测框
|
static void |
drawImageRectWithText(BufferedImage image,
DetectionRectangle box,
String text,
Color color)
画检测框(有倾斜角)和文本
|
static void |
drawImageRectWithText(BufferedImage image,
ai.djl.ndarray.NDArray box,
String text)
画检测框(有倾斜角)和文本
|
static void |
drawImageText(BufferedImage image,
String text,
int x,
int y)
显示文字
|
static void |
drawText(Graphics2D g,
String text,
int x,
int y,
int stroke,
int padding) |
static byte[] |
getMatrixBGR(BufferedImage image)
对图像解码返回BGR格式矩阵数据
|
static boolean |
isAllImageSizeEqual(List<ai.djl.modality.cv.Image> images)
判断所有图片尺寸是否一致
|
static boolean |
isBGR3Byte(BufferedImage image)
推断图像是否为BGR格式
|
static boolean |
isImageValid(BufferedImage image)
检查图像是否有效
|
static List<File> |
listImageFiles(String folderPath)
列出文件夹下的所有图片文件
List all image files under the folder
|
static void |
putTextWithBackground(org.opencv.core.Mat image,
String text,
org.opencv.core.Point origin,
org.opencv.core.Scalar textColor,
org.opencv.core.Scalar backgroundColor,
int padding)
在图像上绘制带白色背景、黑色文字的文本
|
static List<ai.djl.modality.cv.Image> |
readImagesFromFolder(String folderPath)
读取指定目录下所有图片,返回 List
|
static int[] |
rectXYXY(ai.djl.modality.cv.output.Rectangle rect,
int width,
int height)
计算左上角,右下角坐标 (x0,y0,x1,y1)
Get absolute coordinations
|
static void |
saveBoundingBoxImage(ai.djl.modality.cv.Image img,
ai.djl.modality.cv.output.DetectedObjects detection,
String name,
String path)
保存图片,含检测框
|
static void |
saveImage(BufferedImage img,
String path)
保存BufferedImage图片
|
static void |
saveImage(BufferedImage img,
String name,
String path)
保存BufferedImage图片
|
static void |
saveImage(ai.djl.modality.cv.Image img,
String name,
String path)
保存DJL图片
|
public static boolean isBGR3Byte(BufferedImage image)
public static byte[] getMatrixBGR(BufferedImage image)
image - public static BufferedImage bgrToBufferedImage(byte[] data, int width, int height)
public static boolean isImageValid(BufferedImage image)
image - public static void drawImageRect(BufferedImage image, int x, int y, int width, int height)
image - x - y - width - height - public static void drawImageRect(ai.djl.modality.cv.Image image,
int x,
int y,
int width,
int height)
image - x - y - width - height - public static void saveImage(BufferedImage img, String name, String path)
img - name - path - public static void saveImage(BufferedImage img, String path)
img - path - public static void saveImage(ai.djl.modality.cv.Image img,
String name,
String path)
img - name - path - public static void saveBoundingBoxImage(ai.djl.modality.cv.Image img,
ai.djl.modality.cv.output.DetectedObjects detection,
String name,
String path)
throws IOException
img - detection - name - path - IOExceptionpublic static void drawImageRect(BufferedImage image, ai.djl.ndarray.NDArray box)
image - box - public static void drawImageRectWithText(BufferedImage image, ai.djl.ndarray.NDArray box, String text)
image - box - text - public static void drawImageText(BufferedImage image, String text, int x, int y)
image - text - x - y - public static void drawImageRectWithText(BufferedImage image, DetectionRectangle box, String text, Color color)
image - box - text - public static void drawText(Graphics2D g, String text, int x, int y, int stroke, int padding)
public static int[] rectXYXY(ai.djl.modality.cv.output.Rectangle rect,
int width,
int height)
rect - width - height - public static List<File> listImageFiles(String folderPath)
folderPath - public static List<ai.djl.modality.cv.Image> readImagesFromFolder(String folderPath) throws IOException
folderPath - 图片文件夹路径IOExceptionpublic static boolean isAllImageSizeEqual(List<ai.djl.modality.cv.Image> images)
images - 图片列表public static void putTextWithBackground(org.opencv.core.Mat image,
String text,
org.opencv.core.Point origin,
org.opencv.core.Scalar textColor,
org.opencv.core.Scalar backgroundColor,
int padding)
Copyright © 2025. All rights reserved.