123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- using BBIWARG.Recognition.Tracking;
- using BBIWARG.Utility;
- using System;
- namespace BBIWARG.Recognition.PalmRecognition
- {
-
-
-
- internal class TrackedPalm : TrackedObject<Palm>
- {
-
-
-
- private Kalman2DPositionFilter fingersLowerKalman;
-
-
-
- private Kalman2DPositionFilter fingersUpperKalman;
-
-
-
- private Kalman2DPositionFilter wristLowerKalman;
-
-
-
- private Kalman2DPositionFilter wristUpperKalman;
-
-
-
- public Vector2D FingersLowerPrediction { get { return fingersLowerKalman.getPrediction(); } }
-
-
-
- public Vector2D FingersUpperPrediction { get { return fingersUpperKalman.getPrediction(); } }
-
-
-
- public Palm OptimizedPalm { get; private set; }
-
-
-
- public Vector2D WristLowerPrediction { get { return wristLowerKalman.getPrediction(); } }
-
-
-
- public Vector2D WristUpperPrediction { get { return wristUpperKalman.getPrediction(); } }
-
-
-
-
-
-
-
- public TrackedPalm(int id, Palm detectedPalm, int numFramesDetectedUntilTracked, int numFramesLostUntilDeleted)
- : base(id, detectedPalm, numFramesDetectedUntilTracked, numFramesLostUntilDeleted)
- {
- wristUpperKalman = new Kalman2DPositionFilter(Parameters.PalmmXX, Parameters.PalmmXY, Parameters.PalmmYY);
- wristLowerKalman = new Kalman2DPositionFilter(Parameters.PalmmXX, Parameters.PalmmXY, Parameters.PalmmYY);
- fingersUpperKalman = new Kalman2DPositionFilter(Parameters.PalmmXX, Parameters.PalmmXY, Parameters.PalmmYY);
- fingersLowerKalman = new Kalman2DPositionFilter(Parameters.PalmmXX, Parameters.PalmmXY, Parameters.PalmmYY);
- wristUpperKalman.setInitialPosition(detectedPalm.WristUpper);
- wristLowerKalman.setInitialPosition(detectedPalm.WristLower);
- fingersUpperKalman.setInitialPosition(detectedPalm.FingersUpper);
- fingersLowerKalman.setInitialPosition(detectedPalm.FingersLower);
- updateOptimizedPalm(detectedPalm);
- logStateChange();
- }
-
-
-
-
- public override void updateFrame(Palm detectedPalm)
- {
- base.updateFrame(detectedPalm);
- if (NumFramesInCurrentState == 1)
- logStateChange();
- if (detectedPalm != null)
- {
- wristUpperKalman.getCorrectedPosition(detectedPalm.WristUpper);
- wristLowerKalman.getCorrectedPosition(detectedPalm.WristLower);
- fingersUpperKalman.getCorrectedPosition(detectedPalm.FingersUpper);
- fingersLowerKalman.getCorrectedPosition(detectedPalm.FingersLower);
- updateOptimizedPalm(detectedPalm);
- }
- }
-
-
-
- private void logStateChange()
- {
- String stateAsString = CurrentState.ToString().ToLower();
- Logger.log(String.Format("Palm #{0} {1}", this.ID, stateAsString), LogSubject.PalmTracker);
- }
-
-
-
-
- private void updateOptimizedPalm(Palm detectedPalm)
- {
- OptimizedPalm = new Palm(detectedPalm.Hand, detectedPalm.ThumbDefect, detectedPalm.HandSide, WristUpperPrediction, FingersUpperPrediction, FingersLowerPrediction, WristLowerPrediction);
- OptimizedPalm.setTracked(ID);
- }
- }
- }
|