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
package com.xindao.ocr.smartjavaai.entity;
 
import ai.djl.ndarray.NDArray;
/**
 * 旋转检测框
 */
public class RotatedBox implements Comparable<RotatedBox> {
    private NDArray box;
    private String text;
 
    public RotatedBox(NDArray box, String text) {
        this.box = box;
        this.text = text;
    }
 
    /**
     * 将左上角 Y 坐标升序排序
     *
     * @param o
     * @return
     */
    @Override
    public int compareTo(RotatedBox o) {
        NDArray lowBox = this.getBox();
        NDArray highBox = o.getBox();
        float lowY = lowBox.toFloatArray()[1];
        float highY = highBox.toFloatArray()[1];
        return (lowY < highY) ? -1 : 1;
    }
 
    public NDArray getBox() {
        return box;
    }
 
    public void setBox(NDArray box) {
        this.box = box;
    }
 
    public String getText() {
        return text;
    }
 
    public void setText(String text) {
        this.text = text;
    }
}