-
Notifications
You must be signed in to change notification settings - Fork 5
/
ZoneScorer.java
49 lines (34 loc) · 866 Bytes
/
ZoneScorer.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
package org.genericsystem.cv;
import java.util.List;
import org.opencv.core.Mat;
public class ZoneScorer {
private final Zone zone;
public ZoneScorer(Zone zone) {
this.zone = zone;
}
public Zone getZone() {
return zone;
}
public static class SupervisedZoneScorer extends ZoneScorer {
public SupervisedZoneScorer(Zone zone) {
super(zone);
}
}
public static class UnsupervisedZoneScorer extends ZoneScorer {
private final Scores scores = new Scores();
public UnsupervisedZoneScorer(Zone zone, List<Mat> imgs) {
super(zone);
for (Mat img : imgs) {
String s = Ocr.doWork(new Mat(img, getZone().getRect()).clone());
s = s.replace("\n", "").trim();
scores.put(s);
}
}
public double getBestScore() {
return scores.getBestScore();
}
public String getBestText() {
return scores.getBestText();
}
}
}