|
@@ -57,7 +57,8 @@ namespace bbiwarg.Utility
|
|
|
/// <param name="sizeA">size of the image the original points are in</param>
|
|
|
/// <param name="sizeB">size of the image the projected points are in</param>
|
|
|
/// <param name="numPointsForCalibration">number of points used for the calibration</param>
|
|
|
- public Projection2DTo2D(ImageSize sizeA, ImageSize sizeB, int numPointsForCalibration = 4) {
|
|
|
+ public Projection2DTo2D(ImageSize sizeA, ImageSize sizeB, int numPointsForCalibration = 4)
|
|
|
+ {
|
|
|
this.sizeA = sizeA;
|
|
|
this.sizeB = sizeB;
|
|
|
this.numPointsForCalibration = numPointsForCalibration;
|
|
@@ -68,7 +69,8 @@ namespace bbiwarg.Utility
|
|
|
/// <summary>
|
|
|
/// Resets the calibration.
|
|
|
/// </summary>
|
|
|
- public void reset() {
|
|
|
+ public void reset()
|
|
|
+ {
|
|
|
homography = null;
|
|
|
IsCalibrated = false;
|
|
|
calibrationPointsA = new List<PointF>();
|
|
@@ -80,7 +82,8 @@ namespace bbiwarg.Utility
|
|
|
/// </summary>
|
|
|
/// <param name="pointA">point in the first image</param>
|
|
|
/// <param name="pointB">point in the second image</param>
|
|
|
- public void addCalibrationPoints(Vector2D pointA, Vector2D pointB) {
|
|
|
+ public void addCalibrationPoints(Vector2D pointA, Vector2D pointB)
|
|
|
+ {
|
|
|
calibrationPointsA.Add(sizeA.getRelativePoint(pointA));
|
|
|
calibrationPointsB.Add(sizeB.getRelativePoint(pointB));
|
|
|
|
|
@@ -93,8 +96,9 @@ namespace bbiwarg.Utility
|
|
|
/// </summary>
|
|
|
/// <param name="pointA">the point to project</param>
|
|
|
/// <returns>projected point</returns>
|
|
|
- public Vector2D projectPoint(Vector2D pointA) {
|
|
|
- PointF[] pointfsB = new PointF[1] {sizeA.getRelativePoint(pointA)};
|
|
|
+ public Vector2D projectPoint(Vector2D pointA)
|
|
|
+ {
|
|
|
+ PointF[] pointfsB = new PointF[1] { sizeA.getRelativePoint(pointA) };
|
|
|
homography.ProjectPoints(pointfsB);
|
|
|
return sizeB.getAbsolutePoint(new Vector2D(pointfsB[0]));
|
|
|
}
|
|
@@ -102,9 +106,10 @@ namespace bbiwarg.Utility
|
|
|
/// <summary>
|
|
|
/// Computes the homography from the lists of calibration points.
|
|
|
/// </summary>
|
|
|
- private void calibrate() {
|
|
|
+ private void calibrate()
|
|
|
+ {
|
|
|
homography = CameraCalibration.FindHomography(calibrationPointsA.ToArray(), calibrationPointsB.ToArray(), Emgu.CV.CvEnum.HOMOGRAPHY_METHOD.DEFAULT, 0.995);
|
|
|
-
|
|
|
+
|
|
|
calibrationPointsA.Clear();
|
|
|
calibrationPointsB.Clear();
|
|
|
IsCalibrated = true;
|
|
@@ -115,7 +120,8 @@ namespace bbiwarg.Utility
|
|
|
/// <summary>
|
|
|
/// Writes the homography to a file.
|
|
|
/// </summary>
|
|
|
- private void exportHomography() {
|
|
|
+ private void exportHomography()
|
|
|
+ {
|
|
|
String[] fileData = new String[homography.Size.Height];
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
for (int r = 0; r < homography.Size.Height; r++)
|