zouyu
2025-09-26 3fbbfcc8f509c352c58dc8a126220b49b72ed5a0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package com.xindao.ocr.smartjavaai.model.plate;
 
import ai.djl.inference.Predictor;
import ai.djl.modality.cv.Image;
import cn.smartjavaai.common.entity.R;
import com.xindao.ocr.smartjavaai.config.PlateRecModelConfig;
import com.xindao.ocr.smartjavaai.entity.PlateInfo;
import com.xindao.ocr.smartjavaai.entity.PlateResult;
import org.apache.commons.pool2.impl.GenericObjectPool;
 
import java.awt.image.BufferedImage;
import java.io.InputStream;
import java.util.List;
 
/**
 * 车牌识别模型
 * @author dwj
 */
public interface PlateRecModel extends AutoCloseable{
 
    /**
     * 加载模型
     * @param config
     */
    void loadModel(PlateRecModelConfig config); // 加载模型
 
    /**
     * 车牌识别
     * @param imagePath 图片路径
     * @return
     */
    default R<List<PlateInfo>> recognize(String imagePath) {
        throw new UnsupportedOperationException("默认不支持该功能");
    }
 
 
    /**
     * 车牌识别
     * @param inputStream
     * @return
     */
    default R<List<PlateInfo>> recognize(InputStream inputStream) {
        throw new UnsupportedOperationException("默认不支持该功能");
    }
 
 
    /**
     * 车牌识别
     * @param base64Image
     * @return
     */
    default R<List<PlateInfo>> recognizeBase64(String base64Image){
        throw new UnsupportedOperationException("默认不支持该功能");
    }
 
 
    /**
     * 车牌识别
     * @param image BufferedImage
     * @return
     */
    default R<List<PlateInfo>> recognize(BufferedImage image) {
        throw new UnsupportedOperationException("默认不支持该功能");
    }
 
 
    /**
     * 车牌识别
     * @param imageData 图片字节数组
     * @return
     */
    default R<List<PlateInfo>> recognize(byte[] imageData) {
        throw new UnsupportedOperationException("默认不支持该功能");
    }
 
    /**
     * 车牌识别
     * @param image DJL Image
     * @return
     */
    default R<List<PlateInfo>> recognize(Image image){
        throw new UnsupportedOperationException("默认不支持该功能");
    }
 
    /**
     * 识别裁剪后的图片
     * @return
     */
    default PlateResult recognizeCropped(Image image){
        throw new UnsupportedOperationException("默认不支持该功能");
    }
 
 
    /**
     * 检测并绘制结果
     * @param imagePath 图片输入路径(包含文件名称)
     * @param outputPath 图片输出路径(包含文件名称)
     */
    default R<Void> recognizeAndDraw(String imagePath, String outputPath) {
        throw new UnsupportedOperationException("默认不支持该功能");
    }
 
    /**
     * 检测并绘制结果
     * @param sourceImage
     * @return
     */
    default R<BufferedImage> recognizeAndDraw(BufferedImage sourceImage){
        throw new UnsupportedOperationException("默认不支持该功能");
    }
 
    default GenericObjectPool<Predictor<Image, PlateResult>> getPool() {
        throw new UnsupportedOperationException("默认不支持该功能");
    }
 
}