shikeying
2024-01-11 3b67e947e36133e2a40eb2737b15ea375e157ea0
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
package com.walker.openocr;
 
/**
 * 数据块,从OCR服务获取的最小文本单元,包括:坐标位置、内容、分值。
 * @author 时克英
 * @date 2022-08-30
 */
public class TextBlock {
 
    private String text;
    // 文本开始位置
    private float[] startPosition;
    // 文本结束位置
    private float[] endPosition;
 
    // 置信度(分值)
    private float score;
 
    public TextBlock(){}
 
    public TextBlock(String text, float[] start, float[] end, float score){
        this.text = text;
        this.startPosition = start;
        this.endPosition = end;
        this.score = score;
    }
 
    public String getText() {
        return text;
    }
 
    public TextBlock setText(String text) {
        this.text = text;
        return this;
    }
 
    public float[] getStartPosition() {
        return startPosition;
    }
 
    public TextBlock setStartPosition(float[] startPosition) {
        this.startPosition = startPosition;
        return this;
    }
 
    public float[] getEndPosition() {
        return endPosition;
    }
 
    public TextBlock setEndPosition(float[] endPosition) {
        this.endPosition = endPosition;
        return this;
    }
 
    public float getScore() {
        return score;
    }
 
    public TextBlock setScore(float score) {
        this.score = score;
        return this;
    }
 
    @Override
    public String toString(){
        return new StringBuilder("[text=").append(this.text)
                .append(", start=").append(this.startPosition[0]).append(",").append(this.startPosition[1])
                .append(", end=").append(this.endPosition[0]).append(",").append(this.endPosition[1])
                .append(", score=").append(this.score)
                .append("]").toString();
    }
}