Browse Source

-added reset to trackers
-constants for tuio-server

Alexander Hendrich 10 years ago
parent
commit
8c93f89104

+ 4 - 0
bbiwarg/Constants.cs

@@ -19,6 +19,10 @@ namespace bbiwarg
         public static readonly int OutputNumImages = 5;
         public static readonly int OutputNumImagesPerRow = 3;
         public static readonly float OutputScaleFactor = 1f; // output window size is scaled by this factor (from necessary size for images)
+        
+        // TUIO
+        public static readonly String TuioIP = "127.0.0.1";
+        public static readonly int TuioPort = 3333;
 
         // confidence image
         public static readonly int ConfidenceImageMinThreshold = 500;

+ 8 - 8
bbiwarg/Recognition/FingerRecognition/FingerTracker.cs

@@ -26,14 +26,13 @@ namespace bbiwarg.Recognition.FingerRecognition
 
         public FingerTracker()
         {
-            FingerHistories = new List<FingerHistory>();
-            Fingers = new List<Finger>();
+            reset();
         }
 
-        ~FingerTracker() {
-            foreach (FingerHistory fh in FingerHistories) {
-                FingerHistory.setIDUnused(fh.ID);
-            }
+        public void reset()
+        {
+            FingerHistories = new List<FingerHistory>();
+            Fingers = new List<Finger>();
         }
 
         public void updateTrackedFingers(List<Finger> detectedFingers, OutputImage outputImage)
@@ -95,7 +94,7 @@ namespace bbiwarg.Recognition.FingerRecognition
             //add null finger to TrackedFingers that haven't found a match in this frame (status tracked->lost)
             foreach (FingerHistory fh in unasignedFingerHistories)
             {
-                if (fh.CurrentState != TrackingState.Lost) 
+                if (fh.CurrentState != TrackingState.Lost)
                     Logger.log("Finger #" + fh.ID + " lost", Logger.LogSubject.FingerTracker);
                 fh.addFinger(null);
             }
@@ -165,7 +164,8 @@ namespace bbiwarg.Recognition.FingerRecognition
             }
         }
 
-        private void drawFingerIDs(OutputImage outputImage) {
+        private void drawFingerIDs(OutputImage outputImage)
+        {
             foreach (FingerHistory fh in FingerHistories)
             {
                 if (fh.CurrentFinger != null)

+ 4 - 0
bbiwarg/Recognition/TouchRecognition/TouchTracker.cs

@@ -18,6 +18,10 @@ namespace bbiwarg.Recognition.TouchRecognition
 
         public TouchTracker()
         {
+            reset();
+        }
+
+        public void reset() {
             framesUntilTracked = Constants.TouchEventNumFramesUntilTracked;
             detectedTouchEvents = new List<TouchEvent>[framesUntilTracked];
 

+ 7 - 6
bbiwarg/VideoHandle.cs

@@ -69,11 +69,12 @@ namespace bbiwarg
         public void start()
         {
             palmDetector = new PalmDetector();
-            server = new TuioServer("127.0.0.1", 3333);
+            server = new TuioServer(Constants.TuioIP, Constants.TuioPort);
 
             inputProvider.init();
             inputProvider.start();
             inputProvider.updateFrame();
+            initTrackers();
             processFrameUpdate();
         }
 
@@ -118,9 +119,9 @@ namespace bbiwarg
             videoFrame++;
         }
 
-        public List<PalmTouchEvent> getPalmTouchEvents()
-        {
-            return palmTouchDetector.PalmTouchEvents;
+        private void initTrackers() {
+            touchTracker = new TouchTracker();
+            fingerTracker = new FingerTracker();
         }
 
         private void processFrameUpdate()
@@ -130,8 +131,8 @@ namespace bbiwarg
 
             if (newStarted) {
                 //initialize trackers
-                touchTracker = new TouchTracker();
-                fingerTracker = new FingerTracker();
+                touchTracker.reset();
+                fingerTracker.reset();
             }
 
             //read data from inputProvider