|
@@ -36,32 +36,43 @@ namespace bbiwarg.Utility
|
|
|
}
|
|
|
|
|
|
public void addCalibrationPoints(Vector2D pointA, Vector2D pointB) {
|
|
|
- calibrationPointsA.Add(pointA);
|
|
|
- calibrationPointsB.Add(pointB);
|
|
|
+ calibrationPointsA.Add(sizeA.getRelativePoint(pointA));
|
|
|
+ calibrationPointsB.Add(sizeB.getRelativePoint(pointB));
|
|
|
|
|
|
if (calibrationPointsA.Count == numPointsForCalibration)
|
|
|
calibrate();
|
|
|
}
|
|
|
|
|
|
public Vector2D projectPoint(Vector2D pointA) {
|
|
|
- PointF[] pointfsB = new PointF[1] {pointA};
|
|
|
+ PointF[] pointfsB = new PointF[1] {sizeA.getRelativePoint(pointA)};
|
|
|
homography.ProjectPoints(pointfsB);
|
|
|
- return new Vector2D(pointfsB[0]);
|
|
|
+ return sizeB.getAbsolutePoint(new Vector2D(pointfsB[0]));
|
|
|
}
|
|
|
|
|
|
private void calibrate() {
|
|
|
homography = CameraCalibration.FindHomography(calibrationPointsA.ToArray(), calibrationPointsB.ToArray(), Emgu.CV.CvEnum.HOMOGRAPHY_METHOD.DEFAULT, 0.995);
|
|
|
+
|
|
|
calibrationPointsA.Clear();
|
|
|
calibrationPointsB.Clear();
|
|
|
IsCalibrated = true;
|
|
|
|
|
|
- Console.WriteLine("HOMOGRAPHY:");
|
|
|
- for (int r = 0; r < homography.Size.Height; r++) {
|
|
|
- for (int c = 0; c < homography.Size.Width; c++) {
|
|
|
- Console.Write(homography.Data[r, c] + "\t");
|
|
|
+ exportHomography();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void exportHomography() {
|
|
|
+ String[] fileData = new String[homography.Size.Height];
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ for (int r = 0; r < homography.Size.Height; r++)
|
|
|
+ {
|
|
|
+ for (int c = 0; c < homography.Size.Width; c++)
|
|
|
+ {
|
|
|
+ sb.Append(homography.Data[r, c]);
|
|
|
+ sb.Append(" ");
|
|
|
}
|
|
|
- Console.WriteLine();
|
|
|
+ fileData[r] = sb.ToString();
|
|
|
+ sb.Clear();
|
|
|
}
|
|
|
+ System.IO.File.WriteAllLines(Parameters.HomographyFileName, fileData);
|
|
|
}
|
|
|
}
|
|
|
}
|