private void Awake() { if (sInstance == null) { sInstance = this; } else { Destroy(this); } m_LeftDetection = new DetectionHand(); m_RightDetection = new DetectionHand(); m_LeapService = FindObjectOfType <LeapServiceProvider>(); bool[] leftBools = LeftActivationFingers.GetAsArray(); bool[] rightBools = RightActivationFingers.GetAsArray(); for (int i = 0; i < leftBools.Length; i++) { EFinger SelectedFinger = EFinger.eThumb + i; if (leftBools[i]) { m_LeftFingerCollisions.Add(SelectedFinger, CreateCollisionSphere()); } if (rightBools[i]) { m_RightFingerCollisions.Add(SelectedFinger, CreateCollisionSphere()); } } }
public override bool Detected() { if (!DetectionManager.Get().IsHandSet(m_Hand)) { return(false); } m_DetectHand = DetectionManager.Get().GetHand(m_Hand); bool bExtended = false; for (int i = 0; i < (int)EFinger.ePinky; i++) { EFinger finger = EFinger.eThumb + i; if (m_DetectHand.GetFinger(finger).IsExtended()) { if (finger == m_Finger) { bExtended = true; } else { if (m_OthersClosed) { return(false); } } } } return(bExtended); }
//Check whether user has a manipualted object in hand or not //if not //we can not invoke the HandUI public void PlayForward() { if (DetectionManager.Get().m_ManipulatedObject != null) { PlayTween(Direction.Forward); } }
public override bool Detected() { if (DetectionManager.Get().IsHandSet(m_Hand) && m_CoolDownLeft <= 0.0f) { EDirection swipeDir = EDirection.eRight; if (IsSwiping(ref swipeDir)) { if (swipeDir == EDirection.eLeft) { swipeLeft = true; if (gapLeft == false) { timeLeft = timeGap; gapLeft = true; } } if (swipeLeft && timeLeft > 0.1f && timeLeft < 0.5f) { gapLeft = false; if (swipeDir == EDirection.eRight) { swipeLeft = false; m_CoolDownLeft = m_CooldownTime; return(true); } } } } return(false); }
public Tracker(GTCommands commands) { this.commands = commands; detectionManager = new DetectionManager(); calibration = new Calibration.Calibration(); recalibration = new Recalibration(); eyeMovement = new Classifier(); exponentialSmoother = new ExponentialSmoother(20, 0, (int)Math.Ceiling(GTSettings.Current.Processing.SmoothLevel / 5.0)); visualization = new Visualization(); server = new UDPServer(); gazeDataRaw = new GTGazeData(); gazeDataSmoothed = new GTGazeData(); processingDone = true; timerCalibrationDelay = new DispatcherTimer(); timerCalibrationDelay.Interval = TimeSpan.FromMilliseconds(calibrationDelayMilliseconds); timerCalibrationDelay.Tick += TimerCalibrationTick; logGaze = new Logger(); logGaze.Server = server; // Used to send messages back to client (log start/stop etc.) logGaze.IsEnabled = GTSettings.Current.FileSettings.LoggingEnabled; recalibration.RecalibrationAvailable += new Recalibration.RecalibrationAvailableHandler(recalibration_RecalibrationAvailable); //recalibration.OnRecalibrationAvailable +=new Recalibration.RecalibrationAvailable(recalibration_OnRecalibrationAvailable); GTSettings.Current.Processing.PropertyChanged += ProcessingSettingsPropertyChanged; timerCalibrationDelay.Tick += TimerCalibrationTick; CameraControl.Instance.FrameCaptureComplete += Camera_FrameCaptureComplete; }
void Update() { m_Scalar = referenceModel.localScale.x / 20f; if (m_Scalar < 2) { m_Scalar = 2.0f; } if (m_Scalar > 6) { m_Scalar = 6.0f; } if (m_bTranslating && DetectionManager.Get().IsHandSet(m_Hand)) { Vector3 newPos = GetPosition(); Vector3 ChangeInDistance = newPos - m_LastPos; m_object.transform.position += ChangeInDistance * m_Scalar; m_LastPos = newPos; } }
void Update() { if (m_object == null) { return; } if (m_object.transform.localScale.x <= 0.1f) { m_object.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); } if (m_bResizing && DetectionManager.Get().IsBothHandsSet()) { float fNewDistance = GetDistance(); float fChange = fNewDistance - m_fLastDist; m_object.transform.localScale += new Vector3(fChange, fChange, fChange) * m_Scalar; if (m_object.transform.localScale.x < 0) { m_object.transform.localScale = new Vector3(0, 0, 0); } m_fLastDist = fNewDistance; } }
public override bool Detected() { DetectionManager.DetectionHand specifiedHand = DetectionManager.Get().GetHand(m_Hand); if (!DetectionManager.Get().IsHandSet(m_Hand)) { return(false); } for (int i = 0; i < 5; i++) { EFinger type = EFinger.eThumb + i; if (type != EFinger.eIndex) { if (specifiedHand.GetFinger(type).IsExtended()) { return(false); } } } bool bIndexExtended = specifiedHand.GetFinger(EFinger.eIndex).IsExtended(); return(bIndexExtended); }
public override bool Detected() { DetectionManager.DetectionHand detectHand = DetectionManager.Get().GetHand(m_Hand); if (detectHand.IsSet()) { if (detectHand.GetFinger(EFinger.eThumb).IsExtended()) { for (int i = (int)EFinger.eThumb; i <= (int)EFinger.ePinky; i++) { EFinger finger = EFinger.eThumb + i; if (finger != EFinger.eThumb && finger != EFinger.eUnknown) { if (detectHand.GetFinger(finger).IsExtended()) { return(false); } } } return(true); } } return(false); }
//Get the current hand direction EDirection GetClosestDirection(ref bool a_bDetected) { DetectionManager.DetectionHand detectionHand = DetectionManager.Get().GetHand(m_Hand); if (!detectionHand.IsSet()) { a_bDetected = false; return(EDirection.eDownwards); } Vector3 handDirection = detectionHand.GetHandAxis(m_HandAxis); float currentDistance = float.MaxValue; EDirection currentDir = EDirection.eUpwards; foreach (EDirection dir in m_DirectionMap.Keys) { float newDistance = Vector3.Distance(handDirection, m_DirectionMap[dir]); if (newDistance < currentDistance) { currentDistance = newDistance; currentDir = dir; a_bDetected = true; } } return(currentDir); }
float GetDistance() { Vector3 pos1 = DetectionManager.Get().GetHand(EHand.eLeftHand).GetFinger(EFinger.eIndex).GetTipPosition(); Vector3 pos2 = DetectionManager.Get().GetHand(EHand.eRightHand).GetFinger(EFinger.eIndex).GetTipPosition(); return(Vector3.Distance(pos1, pos2)); }
public override bool JustifiesRequirement(EHand Hand, GestureRequirementData RequirementData) { DetectionManager.DetectionHand SelectedHand = DetectionManager.Get().GetHand(Hand); if (SelectedHand.IsSet()) { Vector3 FingerDirection = SelectedHand.GetFinger(RequirementData.m_FingerValue).GetFingerDirection(); DetectionManager.DetectionFinger SelectedFinger = SelectedHand.GetFinger(RequirementData.m_FingerValue); Vector3 Bone1Dir = SelectedFinger.GetBoneDirection(ESpecificBone.eBone0); Vector3 Bone2Dir = SelectedFinger.GetBoneDirection(ESpecificBone.eBone1); Vector3 Bone3Dir = SelectedFinger.GetBoneDirection(ESpecificBone.eBone2); float boneDot; if (RequirementData.m_FingerValue == EFinger.eThumb) { boneDot = Mathf.Clamp(Vector3.Dot(Bone2Dir, Bone3Dir), 0.0f, 1.0f); } else { boneDot = Mathf.Clamp(Vector3.Dot(Bone1Dir, Bone3Dir), 0.0f, 1.0f); } float percentage = Mathf.Lerp(1.0f, 0.0f, boneDot); if (percentage > RequirementData.m_FloatValue) { return(true); } } return(false); }
void Update() { if (!DetectionManager.Get().IsHandSet(EHand.eRightHand)) { m_Renderer.SetPosition(0, new Vector3(0, 0, 0)); m_Renderer.SetPosition(1, new Vector3(0, 0, 0)); return; } if (m_bActive || m_bOnlyOn) { DetectionManager.DetectionFinger finger = DetectionManager.Get().GetHand(EHand.eRightHand).GetFinger(EFinger.eIndex); Vector3 startPos = finger.GetTipPosition(); Vector3 direction = finger.GetFingerDirection(); Vector3 endPos = startPos + direction * m_Distance; m_Renderer.SetPosition(0, startPos); m_Renderer.SetPosition(1, endPos); } else { m_Renderer.SetPosition(0, new Vector3(0, 0, 0)); m_Renderer.SetPosition(1, new Vector3(0, 0, 0)); } }
public override bool Detected() { if (DetectionManager.Get().IsHandSet(m_Hand)) { return(DetectionManager.Get().GetHand(m_Hand).IsClosed(m_Strength)); } return(false); }
public Vector3 GetHandAxis(EHand a_Hand) { if (DetectionManager.Get().IsHandSet(m_Hand)) { return(DetectionManager.Get().GetHand(a_Hand).GetHandAxis(EHandAxis.eFingerDirection)); } return(Vector3.zero); }
Vector3 GetPosition() { if (DetectionManager.Get().IsHandSet(m_Hand)) { return(DetectionManager.Get().GetHand(m_Hand).GetFinger(m_Finger).GetTipPosition()); } return(Vector3.zero); }
public override bool Detected() { if (DetectionManager.Get().IsHandSet(m_Hand)) { return(DetectionManager.Get().GetHand(m_Hand).IsPinching()); } return(false); }
public override bool JustifiesRequirement(EHand Hand, GestureRequirementData RequirementData) { if (DetectionManager.Get().IsHandSet(Hand)) { return(DetectionManager.Get().GetHand(Hand).IsPinching()); } return(false); }
Vector3 GetHandPosition(EHand a_Hand) { if (DetectionManager.Get().IsHandSet(m_Hand)) { return(DetectionManager.Get().GetHand(a_Hand).GetRelativeHandPosition()); } return(Vector3.zero); }
public override bool Detected() { if (DetectionManager.Get().IsHandSet(m_Hand)) { bt.send("FistGusture is detected."); return(DetectionManager.Get().GetHand(m_Hand).IsClosed(m_ClosedPercentage)); } return(false); }
public override bool Detected() { if (DetectionManager.Get().IsHandSet(m_Hand)) { int currentNumFingers = DetectionManager.Get().GetHand(m_Hand).NumberOfFingersExtended(); bt.send(currentNumFingers.ToString() + " NumberGusture is detected."); return(currentNumFingers == m_Number); } return(false); }
private Tracker(GTCommands commands) { log.Info("Constructing Tracker..."); this.commands = commands; detectionManager = new DetectionManager(); calibration = new Calibration.Calibration(); recalibration = new Recalibration(); eyeMovement = new Classifier(); exponentialSmoother = new ExponentialSmoother(Settings.Instance.EyeMovement.SmoothNumberOfSamples, 0, (int)Math.Ceiling(Settings.Instance.EyeMovement.SmoothLevel / 5.0)); visualization = new Visualization(); server = new UDPServer(); gazeDataRaw = new GTGazeData(); gazeDataSmoothed = new GTGazeData(); gazeDazaExtended = new GTExtendedData(); processingDone = true; timerCalibrationDelay = new DispatcherTimer(); timerCalibrationDelay.Interval = TimeSpan.FromMilliseconds(calibrationDelayMilliseconds); timerCalibrationDelay.Tick += TimerCalibrationTick; logGaze = new Logger(); logGaze.Server = server; // Used to send messages back to client (log start/stop etc.) log.Info("Looking up LoggingEnabled in FileSettings"); logGaze.IsEnabled = Settings.Instance.FileSettings.LoggingEnabled; log.Info("Setting RecalibrationAvailableHandler"); recalibration.RecalibrationAvailable += new Recalibration.RecalibrationAvailableHandler(recalibration_RecalibrationAvailable); //recalibration.OnRecalibrationAvailable +=new Recalibration.RecalibrationAvailable(recalibration_OnRecalibrationAvailable); Settings.Instance.Processing.PropertyChanged += ProcessingSettingsPropertyChanged; timerCalibrationDelay.Tick += TimerCalibrationTick; if (GTHardware.Camera.Instance.Device != null) { log.Info("Setting GTHardware device OnImage EventHandler"); GTHardware.Camera.Instance.Device.OnImage += new EventHandler <GTHardware.Cameras.ImageEventArgs>(Device_OnImage); } string sDate = DateTime.Now.ToString(); sDate = sDate.Replace(" ", ""); sDate = sDate.Replace("/", ""); sDate = sDate.Replace(":", ""); log.Info("Completed constructing Tracker"); fileName2 = "c:\\temp\\log" + sDate + ".csv"; appendToFile(fileName2, "TimeStamp;GazeX;GazeY;DiameterLeftPupil;DiameterRightPupil"); /*fileName = "c:\\temp\\log" + sDate + ".arff"; * appendToFile(fileName, "@relation 'logeye'"); * appendToFile(fileName, "@attribute TimeStamp real"); * appendToFile(fileName, "@attribute GazeX real"); * appendToFile(fileName, "@attribute GazeY real"); * appendToFile(fileName, "@attribute DiameterLeftPupil real"); * appendToFile(fileName, "@attribute DiameterRightPupil real"); * appendToFile(fileName, "@data");*/ }
public override bool Detected() { DetectionManager.DetectionHand detectHand = DetectionManager.Get().GetHand(m_Hand); if (detectHand.IsSet()) { return(detectHand.CheckWithDetails(m_GestureDetail)); } return(false); }
public override bool Detected() { if (DetectionManager.Get().IsHandSet(m_Hand)) { int currentNumFingers = DetectionManager.Get().GetHand(m_Hand).NumberOfFingersExtended(); return(currentNumFingers == m_Number); } return(false); }
public override bool Detected() { if (DetectionManager.Get().IsBothHandsSet() && DetectionManager.Get().AreBothHandsVisible()) { bool bLeftHandPinching = DetectionManager.Get().GetHand(EHand.eLeftHand).IsPinching(); bool bRightHandPinching = DetectionManager.Get().GetHand(EHand.eRightHand).IsPinching(); return(bLeftHandPinching && bRightHandPinching); } return(false); }
void Start() { m_StatusManager = FindObjectOfType <StatusManager>(); m_AzureFaceDetection = FindObjectOfType <AzureFaceDetection>(); m_CaptureManager = FindObjectOfType <CaptureManager>(); m_DetectionManager = GetComponent <DetectionManager>(); m_PhotosToRegister = new List <Texture2D>(); m_AzureFaceDetection.OnFacesAddedToPerson += Train; m_AzureFaceDetection.OnTrainingSuccess = null; m_AzureFaceDetection.OnTrainingSuccess += DetectAgain; }
void Update() { if (m_bTranslating && DetectionManager.Get().IsHandSet(m_Hand)) { Vector3 newPos = GetPosition(); Vector3 ChangeInDistance = newPos - m_LastPos; m_object.transform.position += ChangeInDistance * m_Scalar; m_LastPos = newPos; } }
public override bool JustifiesRequirement(EHand Hand, GestureRequirementData RequirementData) { DetectionManager.DetectionHand SelectedHand = DetectionManager.Get().GetHand(Hand); if (SelectedHand.IsSet()) { if (RequirementData.m_BoolValue == SelectedHand.GetFinger(RequirementData.m_FingerValue).IsExtended()) { return(true); } } return(false); }
public override bool Detected() { DetectionManager.DetectionHand detectHand = DetectionManager.Get().GetHand(m_Hand); EFinger indexFinger = EFinger.eThumb + 1; if (detectHand.IsSet()) { if (detectHand.CheckWithDetails(m_GestureDetail)) { var rot = detectHand.GetRotation(); if (timeBegin == false) { timeElapsed = timeReset; timeBegin = true; } //Debug.DrawRay(detectHand.GetFinger(indexFinger).GetTipPosition(), detectHand.GetFinger(indexFinger).GetFingerDirection() * 3.0f, Color.white); //Debug.DrawRay(DetectionManager.Get().GetHand(m_Hand).GetHandPosition(), detectionHand.GetHandAxis(m_HandAxis) * 1000, Color.red); //Debug.Log(stayTime); if (rot.x > 0.25f && m_CoolDownLeft <= 0.0f && timeElapsed >= 3.5f && timeElapsed <= 8.0f && timeBegin) { m_CoolDownLeft = m_CooldownTime; GameObject projectile = Instantiate(prefab) as GameObject; var spawn = detectHand.GetFinger(indexFinger).GetTipPosition(); projectile.transform.position = spawn; Rigidbody rb = projectile.GetComponent <Rigidbody>(); //var di = detectHand.GetFinger(indexFinger).GetFingerDirection(); //di.y -= 0.6f; // di.z += 0.3f; //di.x += 0.2f; //rb.AddForce(Camera.main.transform.forward * 20f, ForceMode.VelocityChange); rb.velocity = Vector3.forward * 8; timeBegin = false; } return(true); } } return(false); }
public override bool Detected() { if (DetectionManager.Get().IsHandSet(m_Hand)) { DetectionManager.DetectionHand hand = DetectionManager.Get().GetHand(m_Hand); return(hand.IsFingerExtended(EFinger.eIndex) && hand.IsFingerExtended(EFinger.eMiddle) && !hand.IsFingerExtended(EFinger.eThumb) && !hand.IsFingerExtended(EFinger.eRing) && !hand.IsFingerExtended(EFinger.ePinky)); } return(false); }