12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using bbiwarg.Recognition.FingerRecognition;
- using bbiwarg.Recognition.PalmRecognition;
- using bbiwarg.Recognition.Tracking;
- using bbiwarg.Utility;
- using Emgu.CV;
- using Emgu.CV.Structure;
- namespace bbiwarg.Recognition.TouchRecognition
- {
- class TouchEvent : TrackableObject
- {
- public Vector2D AbsolutePosition { get; private set; }
- public Vector2D RelativePosition { get; private set; }
- public Image<Gray, byte> TouchMask { get; private set; }
- public Finger Finger { get; private set; }
- public Palm Palm { get; private set; }
- public TouchEvent(Vector2D absolutePosition, Image<Gray, byte> touchMask, Finger finger, Palm palm)
- {
- AbsolutePosition = absolutePosition;
- RelativePosition = palm.getRelativePosition(absolutePosition);
- TouchMask = touchMask;
- Finger = finger;
- Palm = palm;
- finger.TouchEvent = this;
- }
- public float getTouchValue()
- {
- int touchPixels = TouchMask.CountNonzero()[0];
- int numPixels = TouchMask.Width * TouchMask.Height;
- float touchValue = touchPixels / (float)numPixels;
- return touchValue;
- }
- }
- }
|