|
@@ -18,14 +18,16 @@ namespace bbiwarg.Graphics
|
|
|
private IInputProvider inputProvider;
|
|
|
private IVideoHandle videoHandle;
|
|
|
private ForeFingerDetection foreFingerDetection;
|
|
|
-
|
|
|
- private uint imageBufferId, pointBufferId;
|
|
|
+ private PalmDetection palmDetection;
|
|
|
+
|
|
|
+ private uint imageBufferId, pointBufferId, quadBufferId;
|
|
|
|
|
|
public Output(IInputProvider inputProvider, IVideoHandle videoHandle)
|
|
|
{
|
|
|
this.inputProvider = inputProvider;
|
|
|
this.videoHandle = videoHandle;
|
|
|
this.foreFingerDetection = new ForeFingerDetection(videoHandle);
|
|
|
+ this.palmDetection = new PalmDetection(inputProvider, videoHandle);
|
|
|
}
|
|
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
@@ -66,7 +68,7 @@ namespace bbiwarg.Graphics
|
|
|
GL.VertexPointer(3, VertexPointerType.Float, 3 * sizeof(float) + 4 * sizeof(byte), IntPtr.Zero);
|
|
|
GL.ColorPointer(4, ColorPointerType.UnsignedByte, 3 * sizeof(float) + 4 * sizeof(byte), 3 * sizeof(float));
|
|
|
|
|
|
- GL.PointSize(3.0f);
|
|
|
+ GL.PointSize(2.0f);
|
|
|
GL.DrawArrays(PrimitiveType.Points, 0, videoHandle.getWidth() * videoHandle.getHeight());
|
|
|
|
|
|
// draw points
|
|
@@ -140,6 +142,59 @@ namespace bbiwarg.Graphics
|
|
|
GL.PointSize(10f);
|
|
|
GL.DrawArrays(PrimitiveType.Points, 0, pointData.Length / (4 + 3));
|
|
|
|
|
|
+ // draw quads
|
|
|
+ float[] quadData = new float[4 * (4 + 3) * 1];
|
|
|
+
|
|
|
+ Palm palm = palmDetection.getPalm(1);
|
|
|
+ Vector ul = palm.getUpperLeft();
|
|
|
+ Vector ur = palm.getUpperRight();
|
|
|
+ Vector lr = palm.getLowerRight();
|
|
|
+ Vector ll = palm.getLowerLeft();
|
|
|
+
|
|
|
+ quadData[0] = ul.x();
|
|
|
+ quadData[1] = ul.y();
|
|
|
+ quadData[2] = -ul.z();
|
|
|
+
|
|
|
+ quadData[3] = y.R / 255.0f;
|
|
|
+ quadData[4] = y.G / 255.0f;
|
|
|
+ quadData[5] = y.B / 255.0f;
|
|
|
+ quadData[6] = 0.5f;
|
|
|
+
|
|
|
+ quadData[7] = ur.x();
|
|
|
+ quadData[8] = ur.y();
|
|
|
+ quadData[9] = -ur.z();
|
|
|
+
|
|
|
+ quadData[10] = y.R / 255.0f;
|
|
|
+ quadData[11] = y.G / 255.0f;
|
|
|
+ quadData[12] = y.B / 255.0f;
|
|
|
+ quadData[13] = 0.5f;
|
|
|
+
|
|
|
+ quadData[14] = lr.x();
|
|
|
+ quadData[15] = lr.y();
|
|
|
+ quadData[16] = -lr.z();
|
|
|
+
|
|
|
+ quadData[17] = y.R / 255.0f;
|
|
|
+ quadData[18] = y.G / 255.0f;
|
|
|
+ quadData[19] = y.B / 255.0f;
|
|
|
+ quadData[20] = 0.5f;
|
|
|
+
|
|
|
+ quadData[21] = ll.x();
|
|
|
+ quadData[22] = ll.y();
|
|
|
+ quadData[23] = -ll.z();
|
|
|
+
|
|
|
+ quadData[24] = y.R / 255.0f;
|
|
|
+ quadData[25] = y.G / 255.0f;
|
|
|
+ quadData[26] = y.B / 255.0f;
|
|
|
+ quadData[27] = 0.5f;
|
|
|
+
|
|
|
+ GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
|
|
|
+ GL.BindBuffer(BufferTarget.ArrayBuffer, quadBufferId);
|
|
|
+ GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(quadData.Length * sizeof(float)), quadData, BufferUsageHint.DynamicDraw);
|
|
|
+ GL.VertexPointer(3, VertexPointerType.Float, (4 + 3) * sizeof(float), IntPtr.Zero);
|
|
|
+ GL.ColorPointer(4, ColorPointerType.Float, (4 + 3) * sizeof(float), 3 * sizeof(float));
|
|
|
+
|
|
|
+ GL.DrawArrays(PrimitiveType.Quads, 0, quadData.Length / (4 + 3));
|
|
|
+
|
|
|
sw.Stop();
|
|
|
Console.WriteLine(sw.ElapsedMilliseconds);
|
|
|
|
|
@@ -159,6 +214,7 @@ namespace bbiwarg.Graphics
|
|
|
{
|
|
|
GL.GenBuffers(1, out imageBufferId);
|
|
|
GL.GenBuffers(1, out pointBufferId);
|
|
|
+ GL.GenBuffers(1, out quadBufferId);
|
|
|
|
|
|
GL.BindBuffer(BufferTarget.ArrayBuffer, imageBufferId);
|
|
|
GL.BufferData(BufferTarget.ArrayBuffer,
|