示例#1
0
 private bool UpdateGreaterThanThreshold(InternalToken token)
 {
     if (Math.Abs(token.DeltaPosition.x) > TokenUpdateTranslationThreshold || Math.Abs(token.DeltaPosition.y) > TokenUpdateTranslationThreshold ||
         Math.Abs(token.DeltaAngle) > TokenUpdateRotationThreshold)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#2
0
文件: Token.cs 项目: CGVGroup/ToMMI
 internal Token(InternalToken internalToken, bool MeanSquare)
 {
     this._id    = internalToken.Id;
     this._class = internalToken.Class;
     if (!MeanSquare)
     {
         this._position      = internalToken.Position;
         this._angle         = internalToken.Angle;
         this._deltaAngle    = internalToken.DeltaAngle;
         this._deltaPosition = internalToken.DeltaPosition;
     }
     else
     {
         this._position      = internalToken.MeanSquarePosition;
         this._angle         = internalToken.MeanSquareAngle;
         this._deltaAngle    = internalToken.MeanSquareDeltaAngle;
         this._deltaPosition = internalToken.MeanSquareDeltaPosition;
     }
 }
示例#3
0
        private void IdentifyCluster(Cluster cluster)
        {
            //TODO this function requires updates
            Profiler.BeginSample("---TokenEngine : Token Identification");
            InternalToken token = TokenIdentification.Instance.IdentifyCluster(cluster);

            Profiler.EndSample();
            if (token != null)
            {
                //Statistics
                tokenStatistics.TokenIdentification(true);

                //Calculate TokenClass
                Profiler.BeginSample("---TokenEngine: Class LUT");
                token.ComputeTokenClass(ClassComputeRefSystem, ComputeDimension);
                Profiler.EndSample();

                tokenStatistics.TokenClassRecognition(token.Class);

                //Cluster Identification was succesfull

                //Set Token ID
                token.SetTokenId(GetFirstAvailableTokenId());
                tokenIds.Add(token.Id);

                //Add Token to internal List
                tokens.Add(token.HashId, token);

                //Add Token To Global List
                InputManager.AddToken(new Token(token, ContinuousMeanSquare));

                //Add Token TO local buffer
                succesfullyIdentifiedTokens.Add(token);
            }
            else
            {
                tokenStatistics.TokenIdentification(false);

                //Add token to local buffer
                failedIdentifiedCluster.Add(cluster);
            }
        }
示例#4
0
        internal Token(InternalToken internalToken, bool MeanSquare)
        {
            this._id = internalToken.Id;
            this._class = internalToken.Class;
            if (!MeanSquare)
            {
                this._position = internalToken.Position;
                this._angle = internalToken.Angle;
                this._deltaAngle = internalToken.DeltaAngle;
                this._deltaPosition = internalToken.DeltaPosition;
            }
            else
            {
                this._position = internalToken.MeanSquarePosition;
                this._angle = internalToken.MeanSquareAngle;
                this._deltaAngle = internalToken.MeanSquareDeltaAngle;
                this._deltaPosition = internalToken.MeanSquareDeltaPosition;

            }
        }
 internal static void AddToken(InternalToken token)
 {
     _tokens[token.Id] = new Token(token,TokenManager.Instance.ContinuousMeanSquare);
 }
示例#6
0
        public InternalToken IdentifyCluster(Cluster cluster)
        {
            InternalToken token = null;
            bool          originFound, axisDistinguished;
            //Cluster identification Algorithm
            Dictionary <int, TouchInput> clusterPoints = cluster.Points;

            TokenMarker[] meanSquaredTokenReferenceSystem;

            /*Ordered indexes of markers 0 => Origin
             *                            1 => X axis
             *                            2 => Y axis
             *                            3 => Data
             */
            int[] orderedIndexes = new int[4];

            //Find two furthest apart poits which reppresent the x xis and the y axis markers
            Profiler.BeginSample("------Token Identification : Find Two Furthest Point");
            int[] furthestPointIndexes = FindTwoFurthestPoints(clusterPoints.Values.ToArray());
            Profiler.EndSample();

            //Gets indexes of two remaing points which reppresent origin and data marker
            int[] originAndDataIndexes = clusterPoints.Where(p => p.Key != furthestPointIndexes[0] && p.Key != furthestPointIndexes[1])
                                         .Select(z => z.Key).ToArray();

            Profiler.BeginSample("------Token Identification : Find Origin");
            originFound = FindOriginIndex(furthestPointIndexes, originAndDataIndexes, clusterPoints, ref orderedIndexes);
            Profiler.EndSample();

            if (originFound)
            {
                //Origin Marker Identified and stored in orderedIndexes[0]
                Profiler.BeginSample("------Token Identification : Distinguish Axis");
                axisDistinguished = DistinguishAxisVectors(furthestPointIndexes, clusterPoints, ref orderedIndexes);
                Profiler.EndSample();

                if (axisDistinguished)
                {
                    //Axis markers have been correctly identified
                    //Remaing point is Data Marker
                    orderedIndexes[3] = clusterPoints.Where(p => p.Key != orderedIndexes[0] && p.Key != orderedIndexes[1] && p.Key != orderedIndexes[2])
                                        .Select(z => z.Key).Single();

                    //Compute Mean Square Problem for reference System

                    Dictionary <int, TokenMarker> markers = TokenUtils.ConvertTouchInputToMarkers(orderedIndexes, clusterPoints);

                    Profiler.BeginSample("------Token Identification: MeanSquare Calcs");
                    meanSquaredTokenReferenceSystem = TokenUtils.MeanSquareOrthogonalReferenceSystem(markers[orderedIndexes[0]],
                                                                                                     markers[orderedIndexes[1]],
                                                                                                     markers[orderedIndexes[2]],
                                                                                                     TokenManager.CurrentTokenType.DistanceOriginAxisMarkersPX);
                    Profiler.EndSample();
                    Profiler.BeginSample("------Token Identification: MeanSquare Calcs Maxima");
                    TokenMarker[] meanSquaredTokenReferenceSystemOptimized = TokenUtils.MeanSquareOrthogonalReferenceSystemOptimized(markers[orderedIndexes[0]],
                                                                                                                                     markers[orderedIndexes[1]],
                                                                                                                                     markers[orderedIndexes[2]],
                                                                                                                                     TokenManager.CurrentTokenType.DistanceOriginAxisMarkersPX);

                    Profiler.EndSample();
                    //Create Token
                    token = new InternalToken(cluster.Hash, markers);
                    token.SetMeanSquareReferenceSystem(meanSquaredTokenReferenceSystem);
                }
            }
            else
            {
                //No orthogonal vectors found thus no origin, failed identification
                //For the moment return null, in case consider doing second iteration on second maximum

                return(token);
            }


            return(token);
        }
 private bool UpdateGreaterThanThreshold(InternalToken token)
 {
     if (Math.Abs(token.DeltaPosition.x) > TokenUpdateTranslationThreshold || Math.Abs(token.DeltaPosition.y) > TokenUpdateTranslationThreshold ||
        Math.Abs(token.DeltaAngle) > TokenUpdateRotationThreshold)
         return true;
     else
         return false;
 }
        public InternalToken IdentifyCluster(Cluster cluster)
        {
            InternalToken token = null;
            bool originFound, axisDistinguished;
            //Cluster identification Algorithm
            Dictionary<int, TouchInput> clusterPoints = cluster.Points;
            TokenMarker[] meanSquaredTokenReferenceSystem;

            /*Ordered indexes of markers 0 => Origin
            *                            1 => X axis
            *                            2 => Y axis
            *                            3 => Data
            */
            int[] orderedIndexes = new int[4];

            //Find two furthest apart poits which reppresent the x xis and the y axis markers
            Profiler.BeginSample("------Token Identification : Find Two Furthest Point");
            int[] furthestPointIndexes = FindTwoFurthestPoints(clusterPoints.Values.ToArray());
            Profiler.EndSample();

            //Gets indexes of two remaing points which reppresent origin and data marker
            int[] originAndDataIndexes = clusterPoints.Where(p => p.Key != furthestPointIndexes[0] && p.Key != furthestPointIndexes[1])
                                                      .Select(z => z.Key).ToArray();

            Profiler.BeginSample("------Token Identification : Find Origin");
            originFound = FindOriginIndex(furthestPointIndexes, originAndDataIndexes, clusterPoints, ref orderedIndexes);
            Profiler.EndSample();

            if (originFound)
            {
                //Origin Marker Identified and stored in orderedIndexes[0]
                Profiler.BeginSample("------Token Identification : Distinguish Axis");
                axisDistinguished = DistinguishAxisVectors(furthestPointIndexes, clusterPoints, ref orderedIndexes);
                Profiler.EndSample();

                if (axisDistinguished)
                {
                    //Axis markers have been correctly identified
                    //Remaing point is Data Marker
                    orderedIndexes[3] = clusterPoints.Where(p => p.Key != orderedIndexes[0] && p.Key != orderedIndexes[1] && p.Key != orderedIndexes[2])
                                                     .Select(z => z.Key).Single();

                    //Compute Mean Square Problem for reference System

                    Dictionary<int, TokenMarker> markers = TokenUtils.ConvertTouchInputToMarkers(orderedIndexes, clusterPoints);

                    Profiler.BeginSample("------Token Identification: MeanSquare Calcs");
                    meanSquaredTokenReferenceSystem = TokenUtils.MeanSquareOrthogonalReferenceSystem(markers[orderedIndexes[0]],
                                                                                                     markers[orderedIndexes[1]],
                                                                                                     markers[orderedIndexes[2]],
                                                                                                     TokenManager.CurrentTokenType.DistanceOriginAxisMarkersPX);
                    Profiler.EndSample();
                    Profiler.BeginSample("------Token Identification: MeanSquare Calcs Maxima");
                    TokenMarker[] meanSquaredTokenReferenceSystemOptimized = TokenUtils.MeanSquareOrthogonalReferenceSystemOptimized(markers[orderedIndexes[0]],
                                                                                                                       markers[orderedIndexes[1]],
                                                                                                                       markers[orderedIndexes[2]],
                                                                                                                       TokenManager.CurrentTokenType.DistanceOriginAxisMarkersPX);

                    Profiler.EndSample();
                    //Create Token
                    token = new InternalToken(cluster.Hash, markers);
                    token.SetMeanSquareReferenceSystem(meanSquaredTokenReferenceSystem);
                }

            }
            else
            {
                //No orthogonal vectors found thus no origin, failed identification
                //For the moment return null, in case consider doing second iteration on second maximum

                return token;
            }

            return token;
        }