コード例 #1
0
ファイル: Classifier.cs プロジェクト: gasparramoa/BrailleIO
 public OnlineClassificationResult(ClassificationResult originalResult)
     : base(
         originalResult.Name,
         originalResult.Probability,
         originalResult.NodeParameters.ToArray(),
         originalResult.AdditionalParameters)
 {
 }
コード例 #2
0
        private IClassificationResult RecognizeBlurryLineGesture(IList <Frame> frames)
        {
            if (!CheckTokenCriterion(frames, 1))
            {
                return(null);
            }

            Vertex startPoint, endPoint;
            int    startPointIndex = FindFirstFrameIndexWithCorrectCount(frames, 1, true);
            int    endPointIndex   = FindFirstFrameIndexWithCorrectCount(frames, 1, false);

            Touch t = frames[startPointIndex][0];

            startPoint = new Vertex(t.X, t.Y);

            int maxDistantBlobFrameIndex;
            //search endpoint es point with max distance from start point
            //accounts for misleading data and offers robust identification of lines with disadvantage of
            //more wrong positive classifications
            int maxDistantBlobIndex = GetBlobMaxDistantFromPointIndex(frames, startPoint, out maxDistantBlobFrameIndex);

            if (startPointIndex == -1 || endPointIndex == -1 ||
                startPointIndex == endPointIndex || maxDistantBlobFrameIndex == -1)
            {
                return(null);
            }


            t        = frames[endPointIndex][0];
            endPoint = new Vertex(t.X, t.Y);


            IClassificationResult result = null;

            if (CheckMaxDistanceFromLineKriterion(frames, startPoint, endPoint, MAXDISTFROMLINE) &&
                MetricDistances.EuclideanDistance(startPoint, endPoint) > MINLINELENGTH)
            {
                //return RecognizeDirectionalLine(startPoint, endPoint);
                result = new ClassificationResult(
                    "line",
                    0.9,
                    new Sample[] {
                    new Sample(DateTime.Now, startPoint),
                    new Sample(DateTime.Now, endPoint)
                },
                    new Dictionary <String, Object>()
                {
                    { "FirstTouch", startPoint },
                    { "LastTouch", endPoint },
                    { "angle", GetAngle(startPoint, endPoint) }
                });
            }
            return(result);
        }