-
Notifications
You must be signed in to change notification settings - Fork 5
/
DocField.java
79 lines (61 loc) · 1.79 KB
/
DocField.java
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
package org.genericsystem.cv.retriever;
import org.genericsystem.cv.Img;
import org.genericsystem.cv.utils.ModelTools;
import org.genericsystem.reinforcer.tools.GSRect;
import org.opencv.core.Core;
import org.opencv.core.Point;
import org.opencv.core.Scalar;
import org.opencv.imgproc.Imgproc;
public class DocField extends AbstractField {
private int num;
private String uid;
public DocField() {
super();
}
public DocField(int num, GSRect rect) {
super(rect);
this.num = num;
this.uid = ModelTools.generateZoneUID(rect);
}
public void writeNum(Img img, String text, double fontScale, Scalar color, int thickness) {
Imgproc.putText(img.getSrc(), text, new Point(rect.tl().getX(), rect.br().getY()), Core.FONT_HERSHEY_PLAIN, fontScale, color, thickness);
}
public void annotateImage(Img annotated, double fontScale, Scalar color, int thickness) {
drawRect(annotated, color, thickness);
writeNum(annotated, String.valueOf(num), fontScale, color, thickness);
}
// Getters
public int getNum() {
return num;
}
public String getUid() {
return uid;
}
// The private setters are needed by Jackson to serialize/de-serialize the JSON objects
protected void setRect(GSRect rect) {
updateRect(rect);
this.uid = ModelTools.generateZoneUID(rect);
}
protected void setNum(int num) {
this.num = num;
}
protected void setUid(String uid) {
this.uid = uid;
}
// protected void setLabels(Map<String, Integer> labels) {
// this.labels = labels;
// }
//
// protected void setConsolidated(String consolidated) {
// this.consolidated = consolidated;
// }
protected void setConfidence(double confidence) {
this.confidence = confidence;
}
protected void setAttempts(long attempts) {
this.attempts = attempts;
}
protected void setLabelsSize(int size) {
// Do nothing
}
}