|
@@ -10,6 +10,7 @@ using System.Drawing;
|
|
|
|
|
|
using bbiwarg.Detectors.Fingers;
|
|
using bbiwarg.Detectors.Fingers;
|
|
using bbiwarg.Utility;
|
|
using bbiwarg.Utility;
|
|
|
|
+using bbiwarg.Detectors.Touch;
|
|
|
|
|
|
namespace bbiwarg.Images
|
|
namespace bbiwarg.Images
|
|
{
|
|
{
|
|
@@ -18,6 +19,8 @@ namespace bbiwarg.Images
|
|
DepthImage depthImage;
|
|
DepthImage depthImage;
|
|
EdgeImage edgeImage;
|
|
EdgeImage edgeImage;
|
|
|
|
|
|
|
|
+ TouchDetector touchDetector;
|
|
|
|
+
|
|
private Image<Gray, Byte> handImage;
|
|
private Image<Gray, Byte> handImage;
|
|
private Image<Gray, Byte> pointingHandMask;
|
|
private Image<Gray, Byte> pointingHandMask;
|
|
private Image<Gray, Byte> outputImage;
|
|
private Image<Gray, Byte> outputImage;
|
|
@@ -32,11 +35,13 @@ namespace bbiwarg.Images
|
|
|
|
|
|
private int width, height;
|
|
private int width, height;
|
|
|
|
|
|
- public PalmImage(DepthImage depthImage, EdgeImage edgeImage, FingerDetector fingerDetector)
|
|
|
|
|
|
+ public PalmImage(DepthImage depthImage, EdgeImage edgeImage, FingerDetector fingerDetector, TouchDetector touchDetector)
|
|
{
|
|
{
|
|
this.depthImage = depthImage;
|
|
this.depthImage = depthImage;
|
|
this.edgeImage = edgeImage;
|
|
this.edgeImage = edgeImage;
|
|
|
|
|
|
|
|
+ this.touchDetector = touchDetector;
|
|
|
|
+
|
|
handImage = depthImage.getImage().Convert<Byte>(delegate(short s) { return (s == depthImage.getMaxDepth()) ? (byte) 0 : (byte) 1; });
|
|
handImage = depthImage.getImage().Convert<Byte>(delegate(short s) { return (s == depthImage.getMaxDepth()) ? (byte) 0 : (byte) 1; });
|
|
width = depthImage.getWidth();
|
|
width = depthImage.getWidth();
|
|
height = depthImage.getHeight();
|
|
height = depthImage.getHeight();
|
|
@@ -261,6 +266,23 @@ namespace bbiwarg.Images
|
|
for (int i = 0; i < 4; ++i)
|
|
for (int i = 0; i < 4; ++i)
|
|
outputImage.Draw(new LineSegment2DF(vertices[i], vertices[(i + 1) % 4]), new Gray(1), 1);
|
|
outputImage.Draw(new LineSegment2DF(vertices[i], vertices[(i + 1) % 4]), new Gray(1), 1);
|
|
|
|
|
|
|
|
+ Vector2D origin = new Vector2D(vertices[1]);
|
|
|
|
+
|
|
|
|
+ Matrix<float> tmp = new Matrix<float>(new float[,] {{vertices[0].X - origin.X, vertices[2].X - origin.X}, {vertices[0].Y - origin.Y, vertices[2].Y - origin.Y}});
|
|
|
|
+ Matrix<float> T = new Matrix<float>(2, 2);
|
|
|
|
+ CvInvoke.cvInvert(tmp.Ptr, T.Ptr, Emgu.CV.CvEnum.SOLVE_METHOD.CV_LU);
|
|
|
|
+
|
|
|
|
+ foreach (TouchEvent e in touchDetector.getTouchEvents())
|
|
|
|
+ {
|
|
|
|
+ Vector2D point = new Vector2D(e.getX(), e.getY());
|
|
|
|
+ Matrix<float> res = T.Mul(new Matrix<float>(new float[,] { { point.X - origin.X }, { point.Y - origin.Y } }));
|
|
|
|
+ Vector2D resVector = new Vector2D(res.Data[0, 0], res.Data[1, 0]);
|
|
|
|
+
|
|
|
|
+ Console.WriteLine("touch at " + resVector);
|
|
|
|
+ outputImage.Draw(new Cross2DF(point, 3, 3), new Gray(1), 1);
|
|
|
|
+ }
|
|
|
|
+ Console.WriteLine();
|
|
|
|
+
|
|
outputImage.Draw(wristLine, new Gray(1), 1);
|
|
outputImage.Draw(wristLine, new Gray(1), 1);
|
|
outputImage.Draw(thumbLine, new Gray(1), 1);
|
|
outputImage.Draw(thumbLine, new Gray(1), 1);
|
|
}
|
|
}
|