-
Notifications
You must be signed in to change notification settings - Fork 5
/
Deperspectiver.java
38 lines (28 loc) · 1.2 KB
/
Deperspectiver.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
package org.genericsystem.cv.application;
import org.genericsystem.cv.Kalman;
import org.genericsystem.cv.application.Calibrated.AngleCalibrated;
import org.opencv.core.Mat;
public class Deperspectiver {
private AngleCalibrated calibrated0 = new AngleCalibrated(0, Math.PI / 2);
private Kalman kalmanZ = new Kalman();
private AngleCalibrated[] calibratedVps;
public Mat doWork(SuperFrameImg superFrame, double f, double[] pp, boolean textsEnabledMode, Lines lines) {
if (textsEnabledMode)
lines.lines.addAll(superFrame.findTextOrientationLines());
if (lines.size() > 4) {
calibrated0 = superFrame.findVanishingPoint(lines, calibrated0);
calibratedVps = superFrame.findOtherVps(calibrated0, lines);
double[] predictionZ = kalmanZ.predict();
kalmanZ.correct(calibratedVps[2].uncalibrate(pp, f));
calibratedVps[2] = new AngleCalibrated(new double[] { predictionZ[0], predictionZ[1], 1.0 }, pp, f);
calibratedVps[1] = calibratedVps[0].getOrthoFromVps(calibratedVps[2]);
return superFrame.findHomography(calibratedVps);
} else {
System.out.println("Not enough lines : " + lines.size());
return null;
}
}
public AngleCalibrated[] getCalibratedVps() {
return calibratedVps;
}
}