// Recursively get tracking states
        public static IEnumerable<TrackingState> GetTrackingStates
            (this ITrackable item, TrackingState? trackingState = null,
            ObjectVisitationHelper visitationHelper = null)
        {
            // Prevent endless recursion
            ObjectVisitationHelper.EnsureCreated(ref visitationHelper);
            if (!visitationHelper.TryVisit(item)) yield break;

            foreach (var navProp in item.GetNavigationProperties())
            {
                foreach (var refProp in navProp.AsReferenceProperty())
                {
                    foreach (var state in refProp.EntityReference.GetTrackingStates(visitationHelper: visitationHelper))
                    {
                        if (trackingState == null || state == trackingState)
                            yield return state;
                    }
                }

                foreach (var colProp in navProp.AsCollectionProperty())
                {
                    foreach (ITrackable child in colProp.EntityCollection)
                    {
                        foreach (var state in child.GetTrackingStates(visitationHelper: visitationHelper))
                        {
                            if (trackingState == null || state == trackingState)
                                yield return state;
                        }
                    }
                }
            }
            yield return item.TrackingState;
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomBody"/> class.
        /// </summary>
        public CustomBody()
        {
            _clippedEdges = FrameEdges.None;

            _handLeftConfidence = TrackingConfidence.Low;
            _handLeftState = HandState.Unknown;
            _handRightConfidence = TrackingConfidence.Low;
            _handRightState = HandState.Unknown;
            _isDisposed = false;
            _isRestricted = false;
            _isTracked = false;

            _joints = new Dictionary<JointType, IJoint>();
            _jointOrientations = new Dictionary<JointType, IJointOrientation>();
            foreach (var jointType in CustomJointType.AllJoints)
            {
                _joints.Add(jointType, new CustomJoint(jointType));
                _jointOrientations.Add(jointType, new CustomJointOrientation(jointType));
            }

            _lean = new PointF();

            _leanTrackingState = TrackingState.NotTracked;
            _trackingId = ulong.MaxValue;
            _hasMappedDepthPositions = false;
            _hasMappedColorPositions = false;
        }
        // Recursively set tracking state
        public static void SetTrackingState(this ITrackable item,
            TrackingState state, ObjectVisitationHelper visitationHelper = null)
        {
            // Prevent endless recursion
            ObjectVisitationHelper.EnsureCreated(ref visitationHelper);
            if (!visitationHelper.TryVisit(item)) return;

            foreach (var navProp in item.GetNavigationProperties())
            {
                foreach (var refProp in navProp.AsReferenceProperty())
                {
                    refProp.EntityReference.SetTrackingState(state, visitationHelper);
                    refProp.EntityReference.TrackingState = state;
                }

                foreach (var colProp in navProp.AsCollectionProperty())
                {
                    foreach (ITrackable child in colProp.EntityCollection)
                    {
                        child.SetTrackingState(state, visitationHelper);
                        child.TrackingState = state;
                    }
                }
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Create a new <c>CustomJoint</c> object based on the supplied
 /// <c>JointType</c> value.
 /// </summary>
 public CustomJoint(JointType type)
 {
     _jointType = type;
     _position = new CameraSpacePoint();
     _depthPosition = new DepthSpacePoint();
     _colorPosition = new ColorSpacePoint();
     _trackingState = TrackingState.NotTracked;
 }
		public void Setup()
		{
			var originalList = new List<NotifyingStringClass> { new NotifyingStringClass() };
			this.trackingObservableCollection = new TrackingObservableCollection<NotifyingStringClass>(originalList);

			this.trackingObservableCollection.TrackingObservableCollectionChanged += (sender, eventArgs) =>
				{
					this.trackingState = eventArgs.TrackingState;
				};
		}
 private void MyDataFrameReadyEventHandler(object sender, DataFrameReadyEventArgs e)
 {
     using (DataFrame dataFrame = e.OpenFrame() as DataFrame)
     {
         if (dataFrame != null)
         {
             lastEngineState = dataFrame.Skeletons[0].TrackingState;
         }
     }
 }
 private void MyDataFrameReady(object sender, DataFrameReadyEventArgs e)
 {
     using (var dataFrame = e.OpenFrame() as DataFrame)
     {
         if (dataFrame != null)
         {
             state = dataFrame.Skeletons[0].TrackingState;
             mySkeleton = dataFrame.Skeletons[0].Joints;
         }
     }
 }
Esempio n. 8
0
        public AnalyticsForm()
        {
            lineChart.Parent = this.chartPanel;
            InitializeComponent();

            state = TrackingState.None;
            analyticsListBox.SelectedValueChanged +=new EventHandler(analyticsListBox_SelectedValueChanged);

            PopulateColorsList();

            this.FormClosed += new FormClosedEventHandler(AnalyticsForm_FormClosed);
        }
Esempio n. 9
0
    /// <summary>
    /// TODO:
    /// </summary>
    /// <param name="Parent"></param>
    /// <param name="Localvec"></param>
    public Bone(Bone Parent, Vector3f Localvec, TrackingState ts)
    {
        if (Parent != null)
        {
            this.Parent = Parent;
            this.LocalVec = Localvec;
        }
        else
        {
            this.GlobalVec = LocalVec;
        }
        this.trackingstate = ts;

    }
Esempio n. 10
0
 /// <summary>
 /// Constructs a body adapter from a kinect sdk body
 /// </summary>
 /// <param name="body">Body from Kinect SDK</param>
 public KinectBody(Microsoft.Kinect.Body body)
 {
     this.clippedEdges = body.ClippedEdges;
     this.handLeftConfidence = body.HandLeftConfidence;
     this.handLeftState = body.HandLeftState;
     this.handRightConfidence = body.HandRightConfidence;
     this.handRightState = body.HandRightState;
     this.isRestricted = body.IsRestricted;
     this.isTracked = body.IsTracked;
     this.jointOrientations = body.JointOrientations;
     this.joints = body.Joints;
     this.lean = body.Lean;
     this.leanTrackingState = body.LeanTrackingState;
     this.trackingId = body.TrackingId;
 }
    private void MyDataFrameReadyEventHandler(object sender, DataFrameReadyEventArgs e)
    {
        using (DataFrame dataFrame = e.OpenFrame() as DataFrame)
        {
            if (dataFrame != null)
            {
                Skeleton skl = dataFrame.Skeletons[0];
                trackingState = skl.TrackingState;

                if (SdkManager.IsDebugRun)
                {
                    FrameId = dataFrame.FrameKey.FrameNumberKey;
                    Debug.Log ("Skeleton frame: " + FrameId + ", state: " + skl.TrackingState + ", proximity: " + skl.Proximity.SkeletonProximity);
                }
            }
        }
    }
        protected async override Task OnToolActivateAsync(bool active) {
            _trackingMouseMove = TrackingState.NotTracking;
            if (_pointSymbol == null)
                _pointSymbol = await Module1.CreatePointSymbolAsync();
            //_lastLocations.Clear();
            _lastLocation = null;
            _workingLocation = null;

            if (!Module1.MessageShown) {
                if (!Module1.AreThereAnyLineLayers()) {
                    MessageBox.Show("You need to add at least one line featurelayer to the map.",
                        this.Caption);
                }
                else {
                    MessageBox.Show("Click on any line feature and hold the mouse down to move the graphic. " +
                                "The graphic will track the mouse along the selected line feature.",
                    this.Caption);
                    Module1.MessageShown = true;
                }
            }
        }
Esempio n. 13
0
        private static void ApplyChangesOnCollectionProperties(TrackingState stateFilter, bool includeState,
                                                               EntityNavigationProperty navProp, EntityCollectionProperty <IList> colProp,
                                                               DbContext context, ITrackable item, ObjectVisitationHelper visitationHelper, TrackingState?state = null)
        {
            // Apply changes to 1-M and M-M properties filtering by tracking state
            var count = colProp.EntityCollection.Count;

            for (int i = count - 1; i > -1; i--)
            {
                var trackableChild = colProp.EntityCollection[i] as ITrackable;
                if (trackableChild != null)
                {
                    bool condition = includeState
                        ? trackableChild.TrackingState == stateFilter
                        : trackableChild.TrackingState != stateFilter;
                    if (condition)
                    {
                        context.ApplyChanges(trackableChild, item, visitationHelper, navProp.Property.Name, state);
                    }
                }
            }
        }
Esempio n. 14
0
    // Update is called once per frame
    private void Update()
    {
        Debug.Log(",rG:" + rState.CurrentGesture + ",rD:" + rState.CurrentDirection);
        Debug.Log(",lG" + lState.CurrentGesture + ",lD" + lState.CurrentDirection);
        var rHandState = InputSources.Instance.hands.GetHandState(rHand.Handedness, 0.1f);
        var lHandState = InputSources.Instance.hands.GetHandState(lHand.Handedness, 0.1f);

        rState = DetectTracking(rHand, rHandState, rState);
        lState = DetectTracking(lHand, lHandState, lState);

        _hand.Tracking = HandCoach.HandVisibilityEnum.None;
        if (rState.CurrentGesture == TargetRightGesture &&
            (rState.CurrentDirection & TargetRightDirection) == TargetRightDirection)
        {
            _hand.Tracking = HandCoach.HandVisibilityEnum.Right;
        }
        if (lState.CurrentGesture == TargetLeftGesture &&
            (lState.CurrentDirection & TargetLeftDirection) == TargetLeftDirection)
        {
            _hand.Tracking = _hand.Tracking | HandCoach.HandVisibilityEnum.Left;
        }
    }
Esempio n. 15
0
    /// <summary>
    /// Gets the head pose at the current time or predicted at the given time.
    /// </summary>
    public OVRPose GetHeadPose(double predictionTime = 0d)
    {
#if !UNITY_ANDROID || UNITY_EDITOR
        double abs_time_plus_pred = Hmd.GetTimeInSeconds() + predictionTime;

        TrackingState state = OVRManager.capiHmd.GetTrackingState(abs_time_plus_pred);

        return(state.HeadPose.ThePose.ToPose());
#else
        float px = 0, py = 0, pz = 0, ow = 0, ox = 0, oy = 0, oz = 0;

        double atTime = Time.time + predictionTime;
        OVR_GetCameraPositionOrientation(ref px, ref py, ref pz,
                                         ref ox, ref oy, ref oz, ref ow, atTime);

        return(new OVRPose
        {
            position = new Vector3(px, py, -pz),
            orientation = new Quaternion(-ox, -oy, oz, ow),
        });
#endif
    }
    void Update()
    {
        if (!startTrackerDone)
        {
            TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_IMAGE);
            startTrackerDone = true;
        }

        DisableAllTrackables();

        TrackingState  state          = TrackerManager.GetInstance().UpdateTrackingState();
        TrackingResult trackingResult = state.GetTrackingResult();

        cameraBackgroundBehaviour.UpdateCameraBackgroundImage(state);

        for (int i = 0; i < trackingResult.GetCount(); i++)
        {
            Trackable trackable = trackingResult.GetTrackable(i);
            imageTrackablesMap[trackable.GetName()].OnTrackSuccess(
                trackable.GetId(), trackable.GetName(), trackable.GetPose());
        }
    }
Esempio n. 17
0
        void FixedUpdate()
        {
            TrackingState trackingState = TrackerManager.GetInstance().UpdateTrackingState();

            if (trackingState == null)
            {
                return;
            }
            cameraBackgroundBehaviour.UpdateCameraBackgroundImage(trackingState);

            TrackingResult trackingResult = trackingState.GetTrackingResult();

            // state flag
            bool arCodeTracked = trackingResult.GetCount() > 0;

            // events flags (state changing)
            bool arCodeFound = arCode == null && arCodeTracked;
            bool arCodeLost = arCode != null && !arCodeTracked;
            // Debug.Log("tracked + " + arCodeFound);

            // update
            if (arCodeTracked)
            {
                arCode = trackingResult.GetTrackable(0);
                arCodeUpdate.Invoke(arCode.GetPose());
            }

            // call events handlers
            if (arCodeFound)
            {
                this.arCodeFound.Invoke();
            }
            else if (arCodeLost)
            {
                Debug.Log("LOST");
                arCode = null;
                this.arCodeLost.Invoke();
            }
        }
Esempio n. 18
0
    void Update()
    {
        DisableAllTrackables();

        TrackingState state = TrackerManager.GetInstance().UpdateTrackingState();

        if (state == null)
        {
            return;
        }

        TrackedImage image = state.GetImage();

        cameraBackgroundBehaviour.UpdateCameraBackgroundImage(state);

        TrackingResult trackingResult = state.GetTrackingResult();

        if (trackingResult.GetCount() > 0)
        {
            Trackable trackable = trackingResult.GetTrackable(0);
            if (cloudTrackablesMap.ContainsKey(trackable.GetCloudName()))
            {
                foreach (var cloudTrackable in cloudTrackablesMap[trackable.GetCloudName()])
                {
                    cloudTrackable.OnTrackSuccess(trackable.GetId(), trackable.GetName(), trackable.GetPose());
                }
            }
            else
            {
                if (cloudTrackablesMap.ContainsKey("_MaxstCloud_"))
                {
                    foreach (var cloudTrackable in cloudTrackablesMap["_MaxstCloud_"])
                    {
                        cloudTrackable.OnTrackSuccess(trackable.GetId(), trackable.GetName(), trackable.GetPose());
                    }
                }
            }
        }
    }
Esempio n. 19
0
    void Update()
    {
        DisableAllTrackables();

        TrackingState state = TrackerManager.GetInstance().UpdateTrackingState();

        if (state == null)
        {
            return;
        }

        cameraBackgroundBehaviour.UpdateCameraBackgroundImage(state);

        TrackingResult trackingResult = state.GetTrackingResult();

        for (int i = 0; i < trackingResult.GetCount(); i++)
        {
            Trackable trackable = trackingResult.GetTrackable(i);
            imageTrackablesMap[trackable.GetName()].OnTrackSuccess(
                trackable.GetId(), trackable.GetName(), trackable.GetPose());
        }
    }
Esempio n. 20
0
        /// <summary>
        /// Entry point of pipeline processing, decides whether calibrate or track
        /// </summary>
        public void Update(TrackingState trackingStateOfGame)
        {
            if (TrackingCanceled)
            {
                return;
            }

            if (!IsTracking)
            {
                try
                {
                    Calibration();
                    IsTracking = true;
                }
                catch (Exception e)
                {
                    TrackingCanceled = true;
                    if (e is TimeoutException)
                    {
                        SendResultMessageToUserThread(new TrackingError(ProgramLocalization.CalibrationNoDataArrived));
                    }
                    else if (e is CalibrationException)
                    {
                        if (!string.IsNullOrEmpty(e.Message))
                        {
                            SendResultMessageToUserThread(new TrackingError(e.Message));
                        }
                    }
                    else
                    {
                        SendResultMessageToUserThread(new TrackingError(ProgramLocalization.CalibrationThrewException));
                    }
                }
            }
            else
            {
                Tracking(trackingStateOfGame);
            }
        }
Esempio n. 21
0
    void Update()
    {
        TrackingState state = TrackerManager.GetInstance().UpdateTrackingState();

        if (state == null)
        {
            return;
        }

        cameraBackgroundBehaviour.UpdateCameraBackgroundImage(state);

        string codeScanResult = state.GetCodeScanResult();

        if (!codeScanResult.Equals("") && codeScanResult.Length > 0)
        {
            Dictionary <string, string> resultAsDicionary =
                new JsonReader(codeScanResult).Deserialize <Dictionary <string, string> >();

            codeFormatText.text = "Format : " + resultAsDicionary["Format"];
            codeValueText.text  = "Value : " + resultAsDicionary["Value"];
        }
    }
        /// <summary>
        /// Performs averaging of currently saved states
        /// </summary>
        /// <param name="trackingState">Arrived state</param>
        /// <returns>Averaged result</returns>
        private TrackingState Averaging(TrackingState trackingState)
        {
            AveragingQueue.Enqueue(new TimestampObject <TrackingState>(trackingState));

            var now = DateTime.Now;

            // discard all states older than x seconds
            var temp = AveragingQueue.ToList();

            temp.RemoveAll(x => Math.Abs((now - x.Timestamp).Seconds) > 2);

            AveragingQueue = new Queue <TimestampObject <TrackingState> >(temp);

            // don't average if there aren't enough samples
            if (AveragingQueue.Count <= 3)
            {
                return(null);
            }

            // choose most common tracking state
            List <Tuple <TrackingState, int> > aggregation = new List <Tuple <TrackingState, int> >();

            foreach (var state in AveragingQueue)
            {
                if (aggregation.Any(x => x.Item1.IsEquivalentTo(state.StoredObject)))
                {
                    var old = aggregation.Single(x => x.Item1.IsEquivalentTo(state.StoredObject));
                    aggregation.Remove(old);
                    aggregation.Add(new Tuple <TrackingState, int>(old.Item1, old.Item2 + 1));
                }
                else
                {
                    aggregation.Add(new Tuple <TrackingState, int>(state.StoredObject, 1));
                }
            }

            return(aggregation.OrderByDescending(x => x.Item2).First().Item1);
        }
    void Update()
    {
        if (Input.GetKey(KeyCode.Escape))
        {
            SceneStackManager.Instance.LoadPrevious();
        }

        StartCamera();

        if (!startTrackerDone)
        {
            TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_SLAM);
            startTrackerDone = true;
        }

        EnableChildrenRenderer(false);

        Debug.Log(TrackerManager.GetInstance().GetGuideInfo().GetInitializingProgress().ToString());


        TrackingState  state          = TrackerManager.GetInstance().UpdateTrackingState();
        TrackingResult trackingResult = state.GetTrackingResult();

        if (trackingResult.GetCount() == 0)
        {
            return;
        }

        EnableChildrenRenderer(true);

        Trackable trackable = trackingResult.GetTrackable(0);

        Matrix4x4 poseMatrix = trackable.GetPose();

        transform.position   = MatrixUtils.PositionFromMatrix(poseMatrix);
        transform.rotation   = MatrixUtils.QuaternionFromMatrix(poseMatrix);
        transform.localScale = MatrixUtils.ScaleFromMatrix(poseMatrix);
    }
Esempio n. 24
0
        public static TrackableId AddOrUpdate(
            TrackableId planeId,
            TrackableId?subsumedById,
            Pose pose,
            Vector2[] boundaryPoints,
            TrackingState trackingState,
            PlaneAlignment?alignment,
            PlaneClassification?classification,
            Vector3?center,
            Vector2?size)
        {
            lock (stateLock)
            {
                if (boundaryPoints == null)
                {
                    throw new ArgumentNullException("boundaryPoints");
                }

                if (planeId == TrackableId.invalidId)
                {
                    planeId = NativeApi.NewTrackableId();
                }

                if (!datas.ContainsKey(planeId))
                {
                    datas[planeId] = trackingState;
                }

                SetPlaneData(planeId, pose, boundaryPoints, alignment, classification, center, size);

                if (subsumedById.HasValue)
                {
                    OnSubsumedPlane(planeId, subsumedById.Value);
                }

                return(planeId);
            }
        }
        /// <summary>
        /// Update the source input from the device.
        /// </summary>
        /// <param name="inputDevice">The InputDevice retrieved from the platform.</param>
        /// <returns>Whether position or rotation was successfully updated.</returns>
        public bool UpdateSourceData(InputDevice inputDevice)
        {
            using (UpdateSourceDataPerfMarker.Auto())
            {
                TrackingState lastState = TrackingState;
                LastControllerPose = CurrentControllerPose;

                // Check for position and rotation.
                bool isPositionAvailable = inputDevice.TryGetFeatureValue(CommonUsages.devicePosition, out Vector3 position);
                bool isRotationAvailable = inputDevice.TryGetFeatureValue(CommonUsages.deviceRotation, out Quaternion rotation);

                if (isPositionAvailable || isRotationAvailable)
                {
                    IsPositionAvailable   = isPositionAvailable;
                    IsPositionApproximate = false;
                    IsRotationAvailable   = isRotationAvailable;

                    // Devices are considered tracked if we receive position OR rotation data from the sensors.
                    TrackingState = (IsPositionAvailable || IsRotationAvailable) ? TrackingState.Tracked : TrackingState.NotTracked;

                    CurrentControllerPosition = MixedRealityPlayspace.TransformPoint(position);
                    CurrentControllerRotation = MixedRealityPlayspace.Rotation * rotation;

                    CurrentControllerPose.Position = CurrentControllerPosition;
                    CurrentControllerPose.Rotation = CurrentControllerRotation;

                    // Raise input system events if it is enabled.
                    if (lastState != TrackingState)
                    {
                        CoreServices.InputSystem?.RaiseSourceTrackingStateChanged(InputSource, this, TrackingState);
                    }

                    return(true);
                }

                return(false);
            }
        }
Esempio n. 26
0
        public void MovementHotKeyDown()
        {
            if (movement != Movement.HOTKEY || state == TrackingState.ERROR || state == TrackingState.PAUSED)
            {
                return;
            }

            if (!movementHotKeyDown)
            {
                if (!dragging)
                {
                    if (mode == Mode.EYEX_AND_EVIACAM)
                    {
                        SendKeys.Send("{F11}"); // trigger eViacam to start tracking
                    }
                    warp.RefreshTracking();
                    state = TrackingState.STARTING;
                    updatedAtLeastOnce = false;
                }
            }

            movementHotKeyDown = true;
        }
        public void MergeChanges_Should_Set_Properties_For_Added_Order_With_Null_Customer()
        {
            // Arrange
            var database  = new MockNorthwind();
            var origOrder = new Order
            {
                OrderDate  = DateTime.Parse("1996-07-04"),
                CustomerId = "ALFKI"
            };
            var changeTracker = new ChangeTrackingCollection <Order>(true)
            {
                origOrder
            };
            TrackingState origTrackingState = origOrder.TrackingState;
            var           addedOrder        = AddOrders(database, origOrder)[0];

            // Act
            changeTracker.MergeChanges(addedOrder);

            // Assert
            Assert.Equal(TrackingState.Added, origTrackingState);
            Assert.Equal(TrackingState.Unchanged, origOrder.TrackingState);
        }
Esempio n. 28
0
 internal Body(
     Joint[] jointData,
     Guid entityId,
     bool isTracked,
     HandState leftHandState,
     TrackingConfidence leftHandConfidence,
     HandState rightHandState,
     TrackingConfidence rightHandConfidence,
     Vector2 lean,
     TrackingState leanState,
     FrameEdges clippedEdges)
 {
     Joints            = new EnumDictionary <Joint>(jointData);
     IsTracked         = isTracked;
     EntityId          = entityId;
     HandStateLeft     = leftHandState;
     ConfidenceLeft    = leftHandConfidence;
     HandStateRight    = rightHandState;
     ConfidenceRight   = rightHandConfidence;
     Lean              = lean;
     LeanTrackingState = leanState;
     ClippedEdges      = clippedEdges;
 }
        protected override Task HandleMouseDownAsync(MapViewMouseButtonEventArgs e)
        {
            //Select a line feature and place the initial graphic. Clear out any
            //previously placed graphic
            return(QueuedTask.Run(() => {
                var mapPoint = this.ActiveMapView.ClientToMap(e.ClientPoint);
                var lineFeature = Module1.SelectLineFeature(mapPoint);

                if (lineFeature != null)
                {
                    var nearest = GeometryEngine.Instance.NearestPoint(lineFeature, mapPoint);
                    lock (_lock) {
                        _workingLocation = null;
                        _lineFeature = lineFeature;
                        if (_graphic != null)
                        {
                            _graphic.Dispose();
                        }
                        _graphic = this.AddOverlay(nearest.Point, _pointSymbol.MakeSymbolReference());
                        _trackingMouseMove = TrackingState.CanTrack;
                    }
                }
                else
                {
                    lock (_lock) {
                        _workingLocation = null;
                        _lineFeature = null;
                        if (_graphic != null)
                        {
                            _graphic.Dispose();
                        }
                        _graphic = null;
                        _trackingMouseMove = TrackingState.NotTracking;
                    }
                }
            }));
        }
Esempio n. 30
0
        /// <summary>
        /// Draws a body
        /// </summary>
        /// <param name="joints">joints to draw</param>
        /// <param name="jointPoints">translated positions of joints to draw</param>
        /// <param name="drawingContext">drawing context to draw to</param>
        /// <param name="drawingPen">specifies color to draw a specific body</param>
        private void DrawBody(IDictionary <JointType, Joint> joints, IDictionary <JointType, Point> jointPoints, DrawingContext drawingContext, Pen drawingPen)
        {
            // Draw the bones
            foreach (var bone in this.bones)
            {
                if (bone.Item2.ToString().Contains("Right") || bone.Item1.ToString().Contains("Right"))
                {
                    this.DrawBone(joints, jointPoints, bone.Item1, bone.Item2, drawingContext, new Pen(Brushes.WhiteSmoke, 6));
                }
                else
                {
                    this.DrawBone(joints, jointPoints, bone.Item1, bone.Item2, drawingContext, drawingPen);
                }
            }

            // Draw the joints
            foreach (JointType jointType in joints.Keys)
            {
                Brush drawBrush = null;

                TrackingState trackingState = joints[jointType].TrackingState;

                if (trackingState == TrackingState.Tracked)
                {
                    drawBrush = this.trackedJointBrush;
                }
                else if (trackingState == TrackingState.Inferred)
                {
                    drawBrush = this.inferredJointBrush;
                }

                if (drawBrush != null)
                {
                    drawingContext.DrawEllipse(drawBrush, null, jointPoints[jointType], JointThickness, JointThickness);
                }
            }
        }
Esempio n. 31
0
    void Update()
    {
        if (instantTrackable == null)
        {
            return;
        }

        StartCamera();

        if (!startTrackerDone)
        {
            TrackerManager.GetInstance().StartTracker(TrackerManager.TRACKER_TYPE_INSTANT);
            SensorDevice.GetInstance().Start();
            startTrackerDone = true;
        }

        TrackingState  state          = TrackerManager.GetInstance().UpdateTrackingState();
        TrackingResult trackingResult = state.GetTrackingResult();

        if (trackingResult.GetCount() == 0)
        {
            instantTrackable.OnTrackFail();
            return;
        }

        Trackable trackable = trackingResult.GetTrackable(0);

        planMatrix = trackable.GetPose();
        Matrix4x4 poseMatrix = trackable.GetPose() * Matrix4x4.Translate(touchSumPosition);

        instantTrackable.OnTrackSuccess(trackable.GetId(), trackable.GetName(), poseMatrix);

        if (Input.touchCount > 0 && !rotationController.getRotationState() && !zoomInOut.getScaleState())
        {
            UpdateTouchDelta(Input.GetTouch(0).position);
        }
    }
Esempio n. 32
0
			protected override void OnUpdateFrame(FrameEventArgs e)
			{
				base.OnUpdateFrame(e);

				//get the time the frame will be displayed on the oculus
				double displayMidpoint = OvrDLL.ovr_GetPredictedDisplayTime(session, 0);
				//get the predicted position of the device at that time
				TrackingState ts = OvrDLL.ovr_GetTrackingState(session, displayMidpoint, true);
				//calculate eye poses
				Vector3[] eyeOffsets = new Vector3[2] { eyes[0].desc.HmdToEyeOffset, eyes[1].desc.HmdToEyeOffset };
				Posef[] eyePoses = new Posef[2];
				OvrDLL.ovr_CalcEyePoses(ts.HeadPose.ThePose, eyeOffsets, eyePoses);

				//get the orientation of the hmd if it was tracked
				if (ts.StatusFlags.HasFlag(StatusBits.OrientationTracked))
				{
					eyes[0].pose.Orientation = eyePoses[0].Orientation;
					eyes[1].pose.Orientation = eyePoses[1].Orientation;
				}
				else
				{
					eyes[0].pose.Orientation = Quaternion.Identity;
					eyes[1].pose.Orientation = Quaternion.Identity;
				}

				//get the position of the hmd if it was tracked
				if (ts.StatusFlags.HasFlag(StatusBits.PositionTracked))
				{
					eyes[0].pose.Position = eyePoses[0].Position;
					eyes[1].pose.Position = eyePoses[1].Position;
				}
				else
				{
					eyes[0].pose.Position = Vector3.Zero;
					eyes[1].pose.Position = Vector3.Zero;
				}
			}
Esempio n. 33
0
    public override void Update()
    {
        base.Update();

        DisableAllTrackables();

        TrackingState state = TrackerManager.GetInstance().UpdateTrackingState();

        if (state == null)
        {
            return;
        }

        cameraBackgroundBehaviour.UpdateCameraBackgroundImage(state);
        TrackingResult trackingResult = state.GetTrackingResult();

        string recognizedID = null;

        for (int i = 0; i < trackingResult.GetCount(); i++)
        {
            Trackable trackable = trackingResult.GetTrackable(i);
            int       markerId  = -1;
            if (int.TryParse(trackable.GetName(), out markerId))
            {
                if (markerTrackableMap.ContainsKey(markerId))
                {
                    markerTrackableMap[markerId].OnTrackSuccess(
                        trackable.GetId(), trackable.GetName(), trackable.GetPose());

                    recognizedID += trackable.GetId().ToString() + ", ";
                }
            }
        }

        Debug.Log("Recognized Marker id : " + recognizedID);
    }
Esempio n. 34
0
        private void TrackingImplementation(TrackingState trackingStateOfGame)
        {
            var data = Buffer.TryTake();

            if (data == null)
            {
                return;
            }

            UserParameters = UserParametersFactory.GetShallowCopy();
            var inputData = new InputData(data, UserParameters, trackingStateOfGame);

            var planeData      = PlaneLocalization.Track(inputData);
            var chessboardData = ChessboardLocalization.Track(planeData);
            var figuresData    = FiguresLocalization.Track(chessboardData);

            SendResultMessageToUserThread(
                new ResultMessage(
                    figuresData.ResultData.VisualisationBitmap.HorizontalFlip(),
                    figuresData.ResultData.TrackingState,
                    figuresData.ResultData.SceneDisrupted,
                    figuresData.ResultData.PointCountsOverFields)
                );
        }
Esempio n. 35
0
 public static void Reset()
 {
     timestampNs             = null;
     averageBrightness       = null;
     averageColorTemperature = null;
     colorCorrection         = null;
     projectionMatrix        = null;
     displayMatrix           = null;
     trackingState           = TrackingState.Tracking;
     properties = null;
     averageIntensityInLumens  = null;
     exposureDuration          = null;
     exposureOffset            = null;
     mainLightIntensityLumens  = null;
     mainLightColor            = null;
     mainLightDirection        = null;
     ambientSphericalHarmonics = null;
     cameraGrain       = null;
     noiseIntensity    = null;
     permissionGranted = true;
     screenSize        = null;
     screenOrientation = null;
     SetTextures(null, null);
 }
        private void HandleDataEvent(DataFrameReadyEventArgs dataFrameReadyEventArgs)
        {
            using (var dataFrame = dataFrameReadyEventArgs.OpenFrame() as DataFrame)
            {
                if (dataFrame != null) // Making sure it's really DataFrame
                {
                    StringBuilder text = new StringBuilder();
                    Skeleton      skel = dataFrame.Skeletons[0];
                    if (dataFrame.Skeletons[0] != null)
                    {
                        var           joints = dataFrame.Skeletons[0].Joints; // Possibly several Skeletons, we'll use the first
                        TrackingState state  = dataFrame.Skeletons[0].TrackingState;
                        // We only want to display a tracked Skeleton
                        if (state == TrackingState.Tracked)
                        {
                            // Serialize skeleton
                            string json = new JavaScriptSerializer().Serialize(dataFrame.Skeletons[0]);

                            SendData(json);
                        }
                    }
                }
            }
        }
Esempio n. 37
0
        private void Tracking(TrackingState trackingStateOfGame)
        {
            PipelineSlowdown();

            Semaphore.Wait();

            LastReleasedTrackingTask = DateTime.Now;

            Task.Run(() =>
            {
                try
                {
                    TrackingImplementation(trackingStateOfGame);
                }
                catch (Exception)
                {
                    // ignored
                }
                finally
                {
                    Semaphore.Release();
                }
            });
        }
Esempio n. 38
0
        private void Update()
        {
            if (deviceTrackingStateText != null &&
                SpatialCoordinateSystemManager.IsInitialized &&
                SpatialCoordinateSystemManager.Instance.TrackingState != cachedTrackingState)
            {
                cachedTrackingState = SpatialCoordinateSystemManager.Instance.TrackingState;
                if (!promptDictionary.TryGetValue(cachedTrackingState, out var stateText))
                {
                    Debug.LogError($"Tracking state not supported by DeviceTrackingStateVisual promptDictionary: {cachedTrackingState}");
                    stateText = promptDictionary[TrackingState.Unknown];
                }

                deviceTrackingStateText.text = $"{deviceTrackingPrompt} {stateText}";

                if (!colorDictionary.TryGetValue(cachedTrackingState, out var stateColor))
                {
                    Debug.LogError($"Tracking state not supported by DeviceTrackingStateVisual colorDictionary: {cachedTrackingState}");
                    stateColor = colorDictionary[TrackingState.Unknown];
                }

                deviceTrackingStateText.color = stateColor;
            }
        }
Esempio n. 39
0
 public void PauseHotKeyDown()
 {
     log.Debug("Pause key down");
     if (pauseMode)
     {
         pauseMode = false;
         if (state != TrackingState.ERROR)
         {
             warp.RefreshTracking();
             log.Debug("State change to starting");
             state = TrackingState.STARTING;
             updatedAtLeastOnce = false;
         }
     }
     else
     {
         pauseMode = true;
         if (state == TrackingState.STARTING || state == TrackingState.RUNNING)
         {
             log.Debug("State change to paused");
             state = TrackingState.PAUSED;
         }
     }
 }
        public Data(double leftHandX, double leftHandY, TrackingState lhTS,
            double rightHandX, double rightHandY, TrackingState rhTS,
            double leftElbowX, double leftElbowY, TrackingState leTS,
            double rightElbowX, double rightElbowY, TrackingState reTS,            
            GestureType gestureType)
        {
            LeftHandX = leftHandX;
            LeftHandY = leftHandY;
            LHTS = lhTS;

            RightHandX = rightHandX;
            RightHandY = rightHandY;
            RHTS = rhTS;

            LeftElbowX = leftElbowX;
            LeftElbowY = leftElbowY;
            LETS = leTS;

            RightElbowX = rightElbowX;
            RightElbowY = rightElbowY;
            RETS = reTS;

            GestureType = gestureType;
        }
 void UpdatePose(TrackingState trackingState)
 {
     if (trackingState == TrackingState.Tracking)
     {
         Quaternion q;
         Vector3    position;
         SonarLib.GetCameraWorldPose(out q, out position);
         if (lastTrackingsState == TrackingState.Tracking)
         {
             q            = Quaternion.Slerp(q, lastQ, rotationSmooth);
             position     = Vector3.Slerp(position, lastPosition, positionSmooth);
             lastQ        = q;
             lastPosition = position;
         }
         else
         {
             q        = lastQ;
             position = lastPosition;
         }
         transform.localRotation = q;
         transform.localPosition = position;
     }
     lastTrackingsState = trackingState;
 }
Esempio n. 42
0
 private void Update()
 {
     if (RayHitToPlayer())
     {
         nowTrackingState = TrackingState.APPROACHING;
         Vector2 hereVec2 = transform.position;
         Vector2 destVec2 = dest.position;
         if (Vector2.Distance(hereVec2, destVec2) <= behaveRange)
         {
             nowTrackingState = TrackingState.BEHAVING;
         }
     }
     else
     {
         nowTrackingState = TrackingState.ROAMING;
     }
     if (nowTrackingState != preTrackingState)
     {
         stateToExitDict[preTrackingState]();
         stateToInitDict[nowTrackingState]();
     }
     stateToUpdateDict[nowTrackingState]();
     preTrackingState = nowTrackingState;
 }
Esempio n. 43
0
        void maximized()
        {
            WinSys.GetWindowPlacement( windowHandle, ref windowInformation);

            // Ok, if we're not maximized anymore.
            if ( (windowInformation.flags & WinSys.SW_SHOWMAXIMIZED) == 0
              && (windowInformation.flags & WinSys.SW_MAXIMIZE) == 0)
            {
                currentState = TrackingState.TrackingMove;
            }
            else
            {   // we still have to handle the case
                // when another window is front of us
                // and vim is briggen back to foreground.
                WinSys.GetWindowRect(thisHandle, ref thisWindowSize);
                WinSys.SetWindowPos( thisHandle
                            , windowHandle
                            , thisWindowSize.Left
                            , thisWindowSize.Top
                            , thisWindowSize.Right - thisWindowSize.Left
                            , thisWindowSize.Bottom - thisWindowSize.Top
                            , 0);

            }
        }
 protected override void OnToolMouseUp(MapViewMouseButtonEventArgs e) {
     lock (_lock) {
         _trackingMouseMove = TrackingState.NotTracking;
         _lineFeature = null;
     }
 }
Esempio n. 45
0
        /// <summary>
        /// Update the joint position based on the referenced <c>IJoint</c>.
        /// </summary>
        public virtual void Update(IJoint joint)
        {
            if (this.JointType != joint.JointType)
                throw new Exception("Cannot Update with Joint of a different Type");

            _position = joint.Position;
            _depthPosition = new DepthSpacePoint();
            _colorPosition = new ColorSpacePoint();
            _trackingState = joint.TrackingState;
        }
Esempio n. 46
0
 private NTrackingState ResolveTrackingState(TrackingState state) {
   switch (state) {
     case TrackingState.Tracked: return NTrackingState.Tracked;
     case TrackingState.Inferred: return NTrackingState.Inferred;
     case TrackingState.NotTracked: return NTrackingState.NotTracked;
   }
   return NTrackingState.NotTracked;
 }
Esempio n. 47
0
 private KinectBase.TrackingState convertTrackingState(TrackingState trackingState)
 {
     //Both enums are numbered the same, so we can do a straight cast
     return (KinectBase.TrackingState)trackingState;
 }
Esempio n. 48
0
        //These methods do the actual calculations of the points
        private void RecalculateAllVariables()
        {
            rightGrab = RecalculateHandGrab(JointType.HandRight);
            leftGrab = RecalculateHandGrab(JointType.HandLeft);
            skeletonPosition = RecalculatePosition();
            skeletonTrackingState = RecalculateSkeletonTrackingState();
            mergedSkeleton = new SkeletonData();

            for (int i = 0; i < mergedSkeleton.Count; i++)
            {
                Joint tempJoint = new Joint();
                tempJoint.JointType = mergedSkeleton[i].JointType;
                tempJoint.Confidence = RecalculateJointConfidence(mergedSkeleton[i].JointType);
                tempJoint.Orientation = RecalculateJointOrientation(mergedSkeleton[i].JointType);
                tempJoint.Position = RecalculateJointPosition(mergedSkeleton[i].JointType);
                tempJoint.TrackingState = RecalculateJointTrackingState(mergedSkeleton[i].JointType);
                mergedSkeleton[i] = tempJoint;
            }

            needsUpdate = false;
        }
Esempio n. 49
0
        /// <summary>
        /// In this method, we wait till the window has finished it's animation
        /// of maximization to tackle ourselves nearby, without changing the
        /// maximization state.
        /// </summary>
        void waitingMaximization()
        {
            WinSys.GetWindowRect(windowHandle, ref followedWindowSize);

            // animation is finished.
            if ( WinSys.RECT.Diff( oldPos, followedWindowSize ) == 0 )
            {
                // ok, the user just to maximize it, we're gonna give it to him
                WinSys.GetWindowRect( thisHandle, ref thisWindowSize);

                int thisWidth = thisWindowSize.Right - thisWindowSize.Left;

                Left = Math.Max( followedWindowSize.Left - thisWidth, 0 );
                Top = followedWindowSize.Top;
                Height = followedWindowSize.Bottom - followedWindowSize.Top;

                WinSys.SetWindowPos( windowHandle
                            , IntPtr.Zero
                            , followedWindowSize.Left + thisWidth
                            , followedWindowSize.Top
                            , followedWindowSize.Right - followedWindowSize.Left - thisWidth
                            , followedWindowSize.Bottom - followedWindowSize.Top
                            , 0
                            );

                WinSys.SetWindowPos( thisHandle
                            , windowHandle
                            , followedWindowSize.Left
                            , followedWindowSize.Top
                            , thisWidth
                            , followedWindowSize.Bottom - followedWindowSize.Top
                            , 0
                            );

                currentState = TrackingState.Maximized;
                windowFollowTimer.Interval = windowFollowDelay;
            }

            oldPos = followedWindowSize;
        }
Esempio n. 50
0
   public static Offset<Joint> CreateJoint(FlatBufferBuilder builder,
 JointType type = JointType.SpineBase,
 TrackingState state = TrackingState.NotTracked,
 Offset<Vector2> position2DOffset = default(Offset<Vector2>),
 Offset<Vector3> position3DOffset = default(Offset<Vector3>),
 Offset<Vector4> rotationOffset = default(Offset<Vector4>))
   {
       builder.StartObject(5);
       Joint.AddRotation(builder, rotationOffset);
       Joint.AddPosition3D(builder, position3DOffset);
       Joint.AddPosition2D(builder, position2DOffset);
       Joint.AddState(builder, state);
       Joint.AddType(builder, type);
       return Joint.EndJoint(builder);
   }
Esempio n. 51
0
        private void ChangeState(TrackingState newState)
        {
            state = newState;
            metricsComboBox.Items.Clear();
            switch (state)
            {
                case TrackingState.Capabilities:
                    ClearControls("Capabilities");
                    metricsComboBox.Items.Add("Capability Gap Type");
                    metricsComboBox.Items.Add("Prioritized Capability Gap Type");
                    metricsComboBox.Items.Add("Capability Gap Amount");
                    metricsComboBox.Items.Add("Prioritized Capability Gap Amount");

                    graphTypeComboBox.Items.Clear();
                    break;
                case TrackingState.CUPEQuestions:
                    ClearControls("CUPE");
                    metricsComboBox.Items.Add("Business Future");
                    metricsComboBox.Items.Add("Business Current");
                    metricsComboBox.Items.Add("IT Future");
                    metricsComboBox.Items.Add("IT Current");

                    graphTypeComboBox.Items.Clear();
                    graphTypeComboBox.Items.Add("Line Graph");
                    graphTypeComboBox.Items.Add("Bar Graph");
                    break;
                case TrackingState.Objectives:
                    ClearControls("Objectives");
                    metricsComboBox.Items.Add("Total Priority");
                    break;
                case TrackingState.ITAttributes:
                    ClearControls("Capabilities");
                    metricsComboBox.Items.Add("Average As Is Score");
                    metricsComboBox.Items.Add("Average To Be Score");
                    itAttributesComboBox.Enabled = true;

                    graphTypeComboBox.Items.Clear();
                    break;
                case TrackingState.Imperatives:
                    ClearControls("Imperatives");
                    metricsComboBox.Items.Add("Differentiation");
                    metricsComboBox.Items.Add("Criticality");
                    metricsComboBox.Items.Add("Effectiveness");

                    graphTypeComboBox.Items.Clear();
                    graphTypeComboBox.Items.Add("Line Graph");
                    graphTypeComboBox.Items.Add("Bar Graph");
                    break;
            }
        }
Esempio n. 52
0
 public static void AddState(FlatBufferBuilder builder, TrackingState state)
 {
     builder.AddInt(1, (int)state, 0);
 }
        Ellipse MakeEllipseForJoint(
          JointType jointType,
          TrackingState trackingState,
          Brush brush,
          Point position2d)
        {
            int width = jointType == JointType.Head ? HEAD_WIDTH : REGULAR_WIDTH;

            Ellipse ellipse = new Ellipse()
            {
                Width = width,
                Height = width,
                Fill = trackingState == TrackingState.Inferred ? InferredBrush : brush
            };
            Canvas.SetLeft(ellipse, position2d.X - (width / 2));
            Canvas.SetTop(ellipse, position2d.Y - (width / 2));
            return (ellipse);
        }
Esempio n. 54
0
        void tracking()
        {
            WinSys.GetWindowRect(windowHandle, ref followedWindowSize);
            WinSys.GetWindowPlacement( windowHandle, ref windowInformation);

            // if the window has been maximized
            if ( (windowInformation.flags & WinSys.SW_SHOWMAXIMIZED) != 0
              || (windowInformation.flags & WinSys.SW_MAXIMIZE) != 0)
            {
                currentState = TrackingState.WaitingMaximization;
                windowFollowTimer.Interval = fastTimerInterval;
            }
            else
            {
                if ( WinSys.RECT.Diff( oldPos, followedWindowSize ) > 0 )
                {
                    #if LOGGING
                    logEvent( "% Moved < " + followedWindowSize.Left.ToString()
                                    + ", " + followedWindowSize.Top.ToString()
                                    + ", " + (followedWindowSize.Right - followedWindowSize.Left).ToString()
                                    + ", " + (followedWindowSize.Bottom - followedWindowSize.Top).ToString()
                                    + " >" );
                    #endif

                    Left = Math.Max( followedWindowSize.Left - Width, 0 );
                    Top = followedWindowSize.Top;
                    Height = followedWindowSize.Bottom - followedWindowSize.Top;

                    oldPos = followedWindowSize;
                    // here we handle the speedup to follow the window
                    // to obtain a smoother move
                    lastWindowMove = 0;
                    if (windowFollowTimer.Interval != fastTimerInterval)
                        windowFollowTimer.Interval = fastTimerInterval;
                }
                else if (windowFollowTimer.Interval.Milliseconds == fastTimerInterval.Milliseconds)
                {
                    // when the window don't move anymore, we hope to bring
                    // back the old slow timer.
                    lastWindowMove += fastTimerInterval.Milliseconds;
                    if (lastWindowMove > maxWaitDelay)
                        windowFollowTimer.Interval = windowFollowDelay;
                }

                WinSys.GetWindowRect(thisHandle, ref thisWindowSize );
                WinSys.SetWindowPos( thisHandle
                            , windowHandle
                            , thisWindowSize.Left
                            , thisWindowSize.Top
                            , thisWindowSize.Right - thisWindowSize.Left
                            , thisWindowSize.Bottom - thisWindowSize.Top
                            , 0);
            }
        }
Esempio n. 55
0
    public void Update()
    {
        if (!activated)
        {
            return;
        }

        if (currentTarget)
        {
            // Check if lost target / new target
            currentTarget = GetTarget();
            if (!currentTarget)
            {
                trackingState = TrackingState.TrackingRight;
                trackingTimer = 0f;
            }
        }
        else
        {
            if (trackingState == TrackingState.TrackingTarget)
            {
                trackingState = TrackingState.TrackingRight;
            }

            // Check if acquired target
            currentTarget = GetTarget();

            if (currentTarget)
            {
                trackingState = TrackingState.TrackingTarget;
                firingTimer = reloadTime;
                AudioSource3D.PlayClipAtPoint(targetAcquiredSound, transform.position);
            }

        }

        switch (trackingState)
        {
            case TrackingState.TrackingTarget:
                TrackTarget();
                break;

            case TrackingState.TrackingRight:
                {
                    trackingTimer += Time.deltaTime;

                    Quaternion rightRotation = Quaternion.FromToRotation(Vector3.up, rightLimit.position - gunPivot.position);
                    Quaternion leftRotation = Quaternion.FromToRotation(Vector3.up, leftLimit.position - gunPivot.position);

                    float leftAngle = leftRotation.eulerAngles.z;
                    float rightAngle = rightRotation.eulerAngles.z;

                    float parameter = Mathfx.Hermite(0, 1, trackingTimer / trackTime);
                    gunPivot.eulerAngles = new Vector3(0, 0, Mathf.LerpAngle(leftAngle, rightAngle, parameter));

                    if (trackingTimer > trackTime)
                    {
                        trackingState = TrackingState.TrackingLeft;
                        trackingTimer = 0f;
                    }

                }
                break;

            case TrackingState.TrackingLeft:
                {
                    trackingTimer += Time.deltaTime;

                    Quaternion rightRotation = Quaternion.FromToRotation(Vector3.up, rightLimit.position - gunPivot.position);
                    Quaternion leftRotation = Quaternion.FromToRotation(Vector3.up, leftLimit.position - gunPivot.position);

                    float leftAngle = leftRotation.eulerAngles.z;
                    float rightAngle = rightRotation.eulerAngles.z;

                    float parameter = Mathfx.Hermite(0, 1, trackingTimer / trackTime);
                    gunPivot.eulerAngles = new Vector3(0, 0, Mathf.LerpAngle(rightAngle, leftAngle, parameter));

                    if (trackingTimer > trackTime)
                    {
                        trackingState = TrackingState.TrackingRight;
                        trackingTimer = 0f;
                    }
                }
                break;
        }
    }
        protected override async void OnToolMouseMove(MapViewMouseEventArgs e) {
            //All of this logic is to avoid unnecessarily updating the graphic position
            //for ~every~ mouse move. We skip any "intermediate" points in-between rapid
            //mouse moves.
            lock (_lock) {
                if (_trackingMouseMove == TrackingState.NotTracking)
                    return;
                else {
                    if (_workingLocation.HasValue) {
                        _lastLocation = e.ClientPoint;
                        return;
                    }
                    else {
                        _lastLocation = e.ClientPoint;
                        _workingLocation = e.ClientPoint;
                    }
                }
                _trackingMouseMove = TrackingState.Tracking;
            }

            //The code "inside" the QTR will execute for all points that
            //get "buffered" or "queued". This avoids having to spin up a QTR
            //for ~every~ point of ~every mouse move.
            await QueuedTask.Run(() => {

                var symReference = _pointSymbol.MakeSymbolReference();
                while (true) {
                    System.Windows.Point? point;
                    Polyline lineFeature = null;
                    IDisposable graphic = null;
                    lock (_lock) {
                        point = _lastLocation;
                        _lastLocation = null;
                        _workingLocation = point;

                        if (point == null || !point.HasValue) {//No new points came in while we updated the overlay
                            _workingLocation = null;
                            break;
                        }
                        else if (_lineFeature == null || _graphic == null) {//conflict with the mouse down,
                            //If this happens then we are done. A new line and point will be
                            //forthcoming from the SketchCompleted callback
                            _trackingMouseMove = TrackingState.NotTracking;
                            break;
                        }
                        lineFeature = _lineFeature;
                        graphic = _graphic;
                    }
                    //update the graphic overlay
                    var nearest = GeometryEngine.NearestPoint(lineFeature, MapView.Active.ClientToMap(point.Value));
                    this.UpdateOverlay(graphic, nearest.Point, symReference);
                }
            });
        }
Esempio n. 57
0
    public void Start()
    {
        firingState = FiringState.Reloading;
        firingTimer = reloadTime;

        trackingTimer = 0;

        laserRenderer.enabled = false;

        trackingState = TrackingState.TrackingRight;

        targets = new List<GameObject>();
        currentTarget = null;
    }
        protected override Task HandleMouseDownAsync(MapViewMouseButtonEventArgs e) {
            //Select a line feature and place the initial graphic. Clear out any
            //previously placed graphic
            return QueuedTask.Run(() => {
                var mapPoint = this.ActiveMapView.ClientToMap(e.ClientPoint);
                var lineFeature = Module1.SelectLineFeature(mapPoint);

                if (lineFeature != null) {
                    var nearest = GeometryEngine.NearestPoint(lineFeature, mapPoint);
                    lock (_lock) {
                        _workingLocation = null;
                        _lineFeature = lineFeature;
                        if (_graphic != null)
                            _graphic.Dispose();
                        _graphic = this.AddOverlay(nearest.Point, _pointSymbol.MakeSymbolReference());
                        _trackingMouseMove = TrackingState.CanTrack;
                    }
                }
                else {
                    lock (_lock) {
                        _workingLocation = null;
                        _lineFeature = null;
                        if (_graphic != null)
                            _graphic.Dispose();
                        _graphic = null;
                        _trackingMouseMove = TrackingState.NotTracking;
                    }
                }
            });
        }
        // Update is called once per frame
        void Update()
        {
            if (! isTraining) {

                return;
            }

            if(lastEngineState != currentEngineState)
            {
                currentEngineState = lastEngineState;

                switch (currentEngineState) {

                case  TrackingState.Tracked:
                    break;
                case  TrackingState.Calibrating:
                    break;
                case TrackingState.NotTracked:
                    OnLostTracking();
                    break;
                default:
                    break;
                }
            }

            textRepetition.text = count.ToString();

            totalTime += Time.deltaTime;
            int seconds = ((int)totalTime) % 60;
            int minutes = ((int)totalTime) / 60;
            string time = minutes + ":" + seconds;

            textDuration.text = time;
        }
Esempio n. 60
0
        /// <summary>
        /// Constructs a body adapter from a serialized version
        /// </summary>
        /// <param name="body"></param>
        public KinectBody(KGP.Serialization.Body.KinectBodyInternal body)
        {
            body.Validate(); //This will check preconditions to make sure we have a valid construct

            this.clippedEdges = body.ClippedEdges;
            this.handLeftConfidence = body.HandLeftConfidence;
            this.handLeftState = body.HandLeftState;
            this.handRightConfidence = body.HandRightConfidence;
            this.handRightState = body.HandRightState;
            this.isRestricted = body.IsRestricted;
            this.isTracked = body.IsTracked;

            Dictionary<JointType, JointOrientation> orientations = new Dictionary<JointType, JointOrientation>();
            Dictionary<JointType, Joint> jointsDic = new Dictionary<JointType,Joint>();
            for (int i = 0; i < body.Joints.Length;i++)
            {
                var joint = body.Joints[i];
                orientations.Add(joint.JointType, body.JointOrientations[i]);
                jointsDic.Add(joint.JointType, joint);

            }

            this.joints = jointsDic;
            this.jointOrientations =orientations;

            this.lean = body.Lean;
            this.leanTrackingState = body.LeanTrackingState;
            this.trackingId = body.TrackingId;
        }