Beispiel #1
0
 private int TemplateCompute(TemplateFeatures tf)
 {
     //KNearestNeighbors knn = new KNearestNeighbors()
     return(Compute(tf.TemplateFeaturesList));
 }
Beispiel #2
0
 public int TemplateMatch(TemplateFeatures tf)
 {
     return(TemplateCompute(tf));
 }
Beispiel #3
0
        public int TemplateMatch(Image <Gray, Byte> template, TemplateFeatures features)
        {
            _template = template;

            int firstNode = _nodeMainTemplate.TemplateMatch(features);

            switch (firstNode)
            {
            case 0:        // a chosen
                // second stage
                int secondNodeA =
                    _nodeATemplate.TemplateMatch(features.TemplateFeaturesList.ToList().GetRange(0, 3).ToArray());

                switch (secondNodeA)
                {
                case 0:          // open chosen
                    return(TemplateFeatures.CLASSIFICATION_HAND_OPEN);

                case 1:         // right or left chosen
                    int thirdNode = _nodeClickTemplate.TemplateMatch(features.TemplateFeaturesList.ToList().GetRange(0, 2).ToArray());

                    switch (thirdNode)
                    {
                    case 0:             // left click
                        return(TemplateFeatures.CLASSIFICATION_HAND_LEFT);

                    case 1:             // right click
                        return(TemplateFeatures.CLASSIFICATION_HAND_RIGHT);

                    default:
                        return(-1);
                    }

                default:
                    return(-1);
                }

            case 1:         // B chosen
                int secondNodeB = _nodeBTemplate.TemplateMatch(features);

                switch (secondNodeB)
                {
                case 0:
                    return(TemplateFeatures.CLASSIFICATION_HAND_HALT);

                case 1:
                    int thirdNode = _nodeScrollTemplate.TemplateMatch(features);

                    switch (thirdNode)
                    {
                    case 0:             // left click
                        return(TemplateFeatures.CLASSIFICATION_HAND_DOWN);

                    case 1:             // right click
                        return(TemplateFeatures.CLASSIFICATION_HAND_UP);

                    default:
                        return(-1);
                    }

                default:
                    return(-1);
                }

            default:
                return(-1);
            }
        }