From 99cceb77bb109ad8f25106a6c1e51e694abfc248 Mon Sep 17 00:00:00 2001 From: Alexander Munch-Hansen Date: Tue, 23 Apr 2019 13:32:57 +0200 Subject: [PATCH] More snaz --- AR-3/Assets/python_test.cs | 48 +++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/AR-3/Assets/python_test.cs b/AR-3/Assets/python_test.cs index 7c97ef2..36ab277 100644 --- a/AR-3/Assets/python_test.cs +++ b/AR-3/Assets/python_test.cs @@ -131,17 +131,21 @@ public class python_test : MonoBehaviour Imgproc.warpPerspective(camImgCopy, outputMat, homography, new Size(baselineWidth, baselineHeight)); - foreach (var row in homographyAndState.board) { - foreach (var lel in row) { - print(lel); - } - } - //List points = new List(); MatOfPoint2f points = new MatOfPoint2f(); points.alloc(16); + + for (int i = 0; i < 64; i++) + { + int x = ((i+1) % 8) * 165; + int y = (int)(i/8); + + + } + + int cur_level = 0; int index = 0; for (int x = 0; x < 8; x++) @@ -150,22 +154,27 @@ public class python_test : MonoBehaviour foreach (int y in new List { 150, 315 }) { - //points.put(index, 0, cur_level, y); - //index += 1; - Imgproc.circle(outputMat, new Point(cur_level, y), 50, new Scalar(255, 0, 0), -1); + points.put(index, 0, cur_level, y); + index += 1; + //Imgproc.circle(outputMat, new Point(cur_level, y), 50, new Scalar(255, 0, 0), -1); } - } + } + + MatOfPoint2f dstPoints = new MatOfPoint2f(); - //Core.perspectiveTransform(points, transformedPoints, homography.inv()); - - - //for (int i = 0; i < 16; i++) - //{ - // Imgproc.circle(loadedImage, transformedPoints.get(i, 0), 5, new Scalar(255, 0, 0), -1); - //} - + Core.perspectiveTransform(points, dstPoints, homography.inv()); + + List transformedPoints = dstPoints.toList(); + foreach (Point point in transformedPoints) + { + Imgproc.circle(loadedImage, point, 10, new Scalar(255, 0, 0), -1); + } + + MatDisplay.DisplayMat(loadedImage, MatDisplaySettings.FULL_BACKGROUND); + displayWarped = true; + /* if (displayWarped) { camImgCopy = loadedImage.clone(); @@ -179,7 +188,8 @@ public class python_test : MonoBehaviour displayWarped = true; MatDisplay.DisplayMat(outputMat, MatDisplaySettings.FULL_BACKGROUND); - } + } + */ }