|
@@ -8,19 +8,55 @@ using bbiwarg.Utility;
|
|
|
|
|
|
namespace bbiwarg.Recognition.TouchRecognition
|
|
namespace bbiwarg.Recognition.TouchRecognition
|
|
{
|
|
{
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// signature of the touchEvent event
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="sender">the event sender</param>
|
|
|
|
+ /// <param name="e">the touch event</param>
|
|
public delegate void TouchEventHandler(object sender, TouchEvent e);
|
|
public delegate void TouchEventHandler(object sender, TouchEvent e);
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Represents a touch that is tracked for several frames
|
|
|
|
+ /// </summary>
|
|
public class TrackedTouch : TrackedObject<Touch>
|
|
public class TrackedTouch : TrackedObject<Touch>
|
|
{
|
|
{
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// the kalman filter for the absolute position prediction
|
|
|
|
+ /// </summary>
|
|
private Kalman2DPositionFilter absolutePositionKalman;
|
|
private Kalman2DPositionFilter absolutePositionKalman;
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// the prediction of the absolute position
|
|
|
|
+ /// </summary>
|
|
public Vector2D AbsolutePositionPrediction { get { return absolutePositionKalman.getPrediction(); } }
|
|
public Vector2D AbsolutePositionPrediction { get { return absolutePositionKalman.getPrediction(); } }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// the optimized touch (using the predicted absolute position)
|
|
|
|
+ /// </summary>
|
|
public Touch OptimizedTouch { get; private set; }
|
|
public Touch OptimizedTouch { get; private set; }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// indicates if the touch is currently active
|
|
|
|
+ /// </summary>
|
|
public bool IsTouchActive { get; private set; }
|
|
public bool IsTouchActive { get; private set; }
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// the track ID of the touching finger
|
|
|
|
+ /// </summary>
|
|
public int FingerID { get; private set; }
|
|
public int FingerID { get; private set; }
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// the event which is fired, if a touchEvent occurs
|
|
|
|
+ /// </summary>
|
|
public event TouchEventHandler TouchEvent;
|
|
public event TouchEventHandler TouchEvent;
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Initializes a new instance of the TrackedTouch class.
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="id">The track ID.</param>
|
|
|
|
+ /// <param name="detectedTouch">The detected touch.</param>
|
|
|
|
+ /// <param name="numFramesDetectedUntilTracked">The number of consecutive frames detected until the touch is considered to be tracked (touchDown).</param>
|
|
|
|
+ /// <param name="numFramesLostUntilDeleted">The number of consecutive frames lost until the touch is deleted (touchUp).</param>
|
|
public TrackedTouch(int id, Touch detectedTouch, int numFramesDetectedUntilTracked, int numFramesLostUntilDeleted)
|
|
public TrackedTouch(int id, Touch detectedTouch, int numFramesDetectedUntilTracked, int numFramesLostUntilDeleted)
|
|
: base(id, detectedTouch, numFramesDetectedUntilTracked, numFramesLostUntilDeleted)
|
|
: base(id, detectedTouch, numFramesDetectedUntilTracked, numFramesLostUntilDeleted)
|
|
{
|
|
{
|
|
@@ -33,6 +69,10 @@ namespace bbiwarg.Recognition.TouchRecognition
|
|
logStateChange();
|
|
logStateChange();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Updates the tracked touch, logs the state change, updates the optimized touch and the absolute position predicton and triggers touch events.
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="detectedTouch">the detected touch</param>
|
|
public override void updateFrame(Touch detectedTouch)
|
|
public override void updateFrame(Touch detectedTouch)
|
|
{
|
|
{
|
|
base.updateFrame(detectedTouch);
|
|
base.updateFrame(detectedTouch);
|
|
@@ -59,17 +99,27 @@ namespace bbiwarg.Recognition.TouchRecognition
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Updates the optimized touch using the absolute position prediction
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="detectedTouch">the detected touch</param>
|
|
private void updateOptimizedTouch(Touch detectedTouch)
|
|
private void updateOptimizedTouch(Touch detectedTouch)
|
|
{
|
|
{
|
|
OptimizedTouch = new Touch(AbsolutePositionPrediction, detectedTouch.Finger, detectedTouch.Palm);
|
|
OptimizedTouch = new Touch(AbsolutePositionPrediction, detectedTouch.Finger, detectedTouch.Palm);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// logs the state change
|
|
|
|
+ /// </summary>
|
|
private void logStateChange()
|
|
private void logStateChange()
|
|
{
|
|
{
|
|
String stateAsString = CurrentState.ToString().ToLower();
|
|
String stateAsString = CurrentState.ToString().ToLower();
|
|
Logger.log(String.Format("Touch #{0} {1}", this.ID, stateAsString), LogSubject.TouchTracker);
|
|
Logger.log(String.Format("Touch #{0} {1}", this.ID, stateAsString), LogSubject.TouchTracker);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Fires a touch event with type = down
|
|
|
|
+ /// </summary>
|
|
private void TriggerTouchDown()
|
|
private void TriggerTouchDown()
|
|
{
|
|
{
|
|
if (TouchEvent != null)
|
|
if (TouchEvent != null)
|
|
@@ -79,6 +129,9 @@ namespace bbiwarg.Recognition.TouchRecognition
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Fires a touch event with type = move
|
|
|
|
+ /// </summary>
|
|
private void TriggerTouchMove()
|
|
private void TriggerTouchMove()
|
|
{
|
|
{
|
|
if (TouchEvent != null)
|
|
if (TouchEvent != null)
|
|
@@ -87,6 +140,9 @@ namespace bbiwarg.Recognition.TouchRecognition
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// Fires a touch event with type = up
|
|
|
|
+ /// </summary>
|
|
private void TriggerTouchUp()
|
|
private void TriggerTouchUp()
|
|
{
|
|
{
|
|
if (TouchEvent != null)
|
|
if (TouchEvent != null)
|