Nemmeste 16 point

This commit is contained in:
Alexander Munch-Hansen 2019-03-04 18:30:38 +01:00
parent 858f280824
commit 452d8690dd

View File

@ -38,6 +38,8 @@ public class homo_draw : MonoBehaviour
public int DarknessThreshold; public int DarknessThreshold;
private Mat drawingMat;
void Start() void Start()
{ {
@ -59,6 +61,8 @@ public class homo_draw : MonoBehaviour
planeOutText = new Texture2D(width, height, TextureFormat.RGBA32, false); planeOutText = new Texture2D(width, height, TextureFormat.RGBA32, false);
} }
void Update() void Update()
@ -74,6 +78,8 @@ public class homo_draw : MonoBehaviour
if (camImageMat == null) if (camImageMat == null)
{ {
camImageMat = new Mat(camImg.Height, camImg.Width, CvType.CV_8UC4); camImageMat = new Mat(camImg.Height, camImg.Width, CvType.CV_8UC4);
drawingMat = new Mat(camImageMat.rows(), camImageMat.cols(), CvType.CV_8UC4, new Scalar(0, 0, 0, 0));
} }
camImageMat.put(0, 0, camImg.Pixels); camImageMat.put(0, 0, camImg.Pixels);
} }
@ -167,6 +173,11 @@ public class homo_draw : MonoBehaviour
var g = output.get(390, 45)[1]; var g = output.get(390, 45)[1];
var b = output.get(390, 45)[2]; var b = output.get(390, 45)[2];
var c_r = output.get(215, 45)[0];
var c_g = output.get(215, 45)[1];
var c_b = output.get(215, 45)[2];
Mat yetAnotherClone = camImgCopy.clone(); Mat yetAnotherClone = camImgCopy.clone();
@ -186,14 +197,7 @@ public class homo_draw : MonoBehaviour
if (nicePoint != null) if (nicePoint != null)
{ {
print("Finger Found"); print("Finger Found");
Mat circleMat = new Mat(output.rows(), output.cols(), CvType.CV_8UC4, new Scalar(0,0,0,0)); Imgproc.circle(drawingMat, nicePoint, 5, new Scalar(c_r, c_g, c_b, 255), -1);
Imgproc.circle(circleMat, nicePoint, 30, new Scalar(255, 0, 0, 255));
Mat circleClone = circleMat.clone();
Imgproc.warpPerspective(circleMat, circleClone, homo.inv(), circleClone.size());
Core.addWeighted(camImageMat, 0.95f, circleClone, 0.7f, 0.0f, yetAnotherClone);
} }
@ -204,6 +208,12 @@ public class homo_draw : MonoBehaviour
} }
Mat circleClone = drawingMat.clone();
Imgproc.warpPerspective(drawingMat, circleClone, homo.inv(), circleClone.size());
Core.addWeighted(camImageMat, 0.95f, circleClone, 0.7f, 0.0f, yetAnotherClone);
//Display the Mat that includes video feed and debug points //Display the Mat that includes video feed and debug points
@ -219,9 +229,9 @@ public class homo_draw : MonoBehaviour
Point LocateFinger(Mat fingerMat) Point LocateFinger(Mat fingerMat)
{ {
for (int i = 0; i < height; i++) for (int i = 70; i < height-30; i++)
{ {
for (int j = 0; j < width; j++) for (int j = 85; j < width-30; j++)
{ {
if (fingerMat.get(i, j)[0] == 255) if (fingerMat.get(i, j)[0] == 255)
{ {