소스 검색

removed inputProvider from Output, Output now only relies on VideoHandle

Alexander Hendrich 11 년 전
부모
커밋
ee1ce2329c
4개의 변경된 파일42개의 추가작업 그리고 29개의 파일을 삭제
  1. 4 2
      bbiwarg/DataSource/IVideoHandle.cs
  2. 33 14
      bbiwarg/DataSource/VideoHandle.cs
  3. 4 12
      bbiwarg/Graphics/Output.cs
  4. 1 1
      bbiwarg/Main/OutputTest.cs

+ 4 - 2
bbiwarg/DataSource/IVideoHandle.cs

@@ -28,11 +28,13 @@ namespace bbiwarg.DataSource
 
         // TODO: implement properly
         void createVertexArray(IntPtr vertexBuffer);
-        //convert2Dto3D(float x, float y, int depth)
+        Vector pixel2VertexPosition(Vector pixelPosition);
 
+        DetectionStatus[] getFingerStatus(uint handIndex);
+        Vector[] getFingerTipPositions3D(uint handIndex);
         Vector getPalmPosition2D(uint handIndex);
         Vector getPalmPosition3D(uint handIndex);
-        Vector pixel2VertexPosition(Vector pixelPosition);
+        Vector getForearmPosition3D(uint handIndex);
         int getWidth();
         int getHeight();
     }

+ 33 - 14
bbiwarg/DataSource/VideoHandle.cs

@@ -38,9 +38,24 @@ namespace bbiwarg.DataSource
 
         public void nextFrame() 
         {
-            inputProvider.releaseFrame();
-            inputProvider.updateFrame();
-            createImageData();
+            if (inputProvider.isActive())
+            {
+                inputProvider.releaseFrame();
+                inputProvider.updateFrame();
+                createImageData();
+            }
+            else {
+                inputProvider.stop();
+            }
+        }
+
+        public int getWidth()
+        {
+            return depthImage.getWidth();
+        }
+        public int getHeight()
+        {
+            return depthImage.getHeight();
         }
 
         private void createImageData() 
@@ -77,18 +92,31 @@ namespace bbiwarg.DataSource
             return colorImage.getColor(xInColorImage, yInColorImage);
         }
 
+        public DetectionStatus[] getFingerStatus(uint handIndex)
+        {
+            return inputProvider.getFingerStatus(handIndex);
+        }
+
+        public Vector[] getFingerTipPositions3D(uint handIndex)
+        {
+            return inputProvider.getFingerTipPositions3D(handIndex);
+        }
+
         public Vector getPalmPosition2D(uint handIndex)
         {
-            //improved palm recognition or just return the value provided by inputprovider
             return inputProvider.getPalmPosition2D(handIndex);
         }
 
         public Vector getPalmPosition3D(uint handIndex)
         {
-            //improved palm recognition or just return the value provided by inputprovider
             return inputProvider.getPalmPosition3D(handIndex);
         }
 
+        public Vector getForearmPosition3D(uint handIndex)
+        {
+            return inputProvider.getForearmPosition3D(handIndex);
+        }
+
         // TODO
         public void createVertexArray(IntPtr vertexBuffer)
         {
@@ -156,14 +184,5 @@ namespace bbiwarg.DataSource
             }
 
         }
-
-        public int getWidth()
-        {
-            return depthImage.getWidth();
-        }
-        public int getHeight()
-        {
-            return depthImage.getHeight();
-        }
     }
 }

+ 4 - 12
bbiwarg/Graphics/Output.cs

@@ -15,15 +15,13 @@ namespace bbiwarg.Graphics
 {
     class Output : GameWindow
     {
-        private IInputProvider inputProvider;
         private IVideoHandle videoHandle;
         private ForeFingerDetection foreFingerDetection;
         
         private uint imageBufferId, pointBufferId;
 
-        public Output(IInputProvider inputProvider, IVideoHandle videoHandle)
+        public Output(IVideoHandle videoHandle)
         {
-            this.inputProvider = inputProvider;
             this.videoHandle = videoHandle;
             this.foreFingerDetection = new ForeFingerDetection(videoHandle);
         }
@@ -39,12 +37,6 @@ namespace bbiwarg.Graphics
 
         protected override void OnRenderFrame(FrameEventArgs e)
         {
-            if (!inputProvider.isActive())
-            {
-                inputProvider.stop();
-                return;
-            }
-
             base.OnRenderFrame(e);
             GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
             Matrix4 modelview = Matrix4.LookAt(Vector3.Zero, -Vector3.UnitZ, Vector3.UnitY);
@@ -72,7 +64,7 @@ namespace bbiwarg.Graphics
             // draw points
             float[] pointData;
             
-            DetectionStatus[] fingerStatus = inputProvider.getFingerStatus(1);
+            DetectionStatus[] fingerStatus = videoHandle.getFingerStatus(1);
             int numFingersDetected = 0;
             for (int i = 0; i < fingerStatus.Length; ++i)
             {
@@ -84,7 +76,7 @@ namespace bbiwarg.Graphics
             Color y = Color.Yellow;
             Vector palmPosition = videoHandle.getPalmPosition3D(1);
             Vector foreFingerPosition = videoHandle.pixel2VertexPosition(foreFingerDetection.getForeFingerPosition3D(1));
-            Vector foreArmPosition = inputProvider.getForearmPosition3D(1);
+            Vector foreArmPosition = videoHandle.getForearmPosition3D(1);
 
             pointData[0] = palmPosition[0];
             pointData[1] = palmPosition[1];
@@ -106,7 +98,7 @@ namespace bbiwarg.Graphics
 
 
             int index = 14;
-            Vector[] fingerPositions = inputProvider.getFingerTipPositions3D(1);
+            Vector[] fingerPositions = videoHandle.getFingerTipPositions3D(1);
             for (int i = 0; i < fingerStatus.Length; ++i)
             {
                 if (fingerStatus[i] == DetectionStatus.Detected || fingerStatus[i] == DetectionStatus.Tracked)

+ 1 - 1
bbiwarg/Main/OutputTest.cs

@@ -15,7 +15,7 @@ namespace bbiwarg.Main
             IInputProvider inputProvider = new IisuInputProvider("..\\..\\videos\\1.skv");
             IVideoHandle videoHandle = new VideoHandle(inputProvider);
 
-            Output output = new Output(inputProvider, videoHandle);
+            Output output = new Output(videoHandle);
             output.Run(30);
         }
     }