1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using BBIWARG.Recognition.Tracking;
- using BBIWARG.Utility;
- using System;
- namespace BBIWARG.Recognition.HandRecognition
- {
-
-
-
- internal class TrackedHand : TrackedObject<Hand>
- {
-
-
-
- private Kalman2DPositionFilter centroidKalman;
-
-
-
- public Vector2D CentroidPrediction { get { return centroidKalman.getPrediction(); } }
-
-
-
-
-
-
-
- public TrackedHand(int id, Hand detectedHand, int numFramesDetectedUntilTracked, int numFramesLostUntilDeleted)
- : base(id, detectedHand, numFramesDetectedUntilTracked, numFramesLostUntilDeleted)
- {
- centroidKalman = new Kalman2DPositionFilter(Parameters.HandmXX, Parameters.HandmXY, Parameters.HandmYY);
- centroidKalman.setInitialPosition(detectedHand.Centroid);
- logStateChange();
- }
-
-
-
-
- public override void updateFrame(Hand detectedHand)
- {
- base.updateFrame(detectedHand);
- if (NumFramesInCurrentState == 1)
- logStateChange();
- if (detectedHand != null)
- centroidKalman.getCorrectedPosition(detectedHand.Centroid);
- }
-
-
-
- private void logStateChange()
- {
- String stateAsString = CurrentState.ToString().ToLower();
- Logger.log(String.Format("Hand #{0} {1}", this.ID, stateAsString), LogSubject.HandTracker);
- }
- }
- }
|