public ManagedKeypoint GetKeypoint(FingerType fingerType, KeypointType keypointType)
        {
            if (keypointType == KeypointType.HandCenter)
            {
                return(HandCenter);
            }
            if (keypointType == KeypointType.Wrist)
            {
                return(WristCenter);
            }

            return(GetFinger(fingerType).GetKeypoint(keypointType));
        }
        KeypointDrawType GetKeypointDraw(KeypointType type)
        {
            switch (type)
            {
            case KeypointType.DrawRichKeypoints:
                return(KeypointDrawType.DrawRichKeypoints);

            case KeypointType.NotDrawSinglePoints:
                return(KeypointDrawType.NotDrawSinglePoints);

            default:
                return(KeypointDrawType.Default);
            }
        }
Пример #3
0
        public ManagedKeypoint GetKeypoint(KeypointType keypointType)
        {
            switch (keypointType)
            {
            case KeypointType.MCP:
                return(points[0]);

            case KeypointType.PIP:
                return(points.Length == 2 ? null : points[1]);

            case KeypointType.Tip:
                return(points[points.Length - 1]);
            }
            return(null);
        }
        public AlgorithmResult DetectSift(
            string filename,
            KeypointType kpsType,
            int features,
            int octaveLayers,
            double contrastThreshold,
            double edgeThreshold,
            double sigma)
        {
            AlgorithmResult   result      = new AlgorithmResult();
            Image <Bgr, byte> image       = ImageHelper.GetImage(filename);
            Image <Bgr, byte> resultImage = new Image <Bgr, byte>(filename);

            // Get features from image
            var sift      = new SIFT(features, octaveLayers, contrastThreshold, edgeThreshold, sigma);
            var keyPoints = sift.Detect(image);

            DrawKeypoints(
                image,
                new VectorOfKeyPoint(keyPoints),
                resultImage,
                new Bgr(Color.FromArgb(255, 77, 77)),
                GetKeypointDraw(kpsType));

            result.ImageArray = ImageHelper.SetImage(resultImage);
            result.KeyDatas   = new List <KeyPointModel>();
            result.KeyDatas.AddRange(keyPoints.Select(k => new KeyPointModel()
            {
                X        = k.Point.X,
                Y        = k.Point.Y,
                Size     = k.Size,
                Angle    = k.Angle,
                Response = k.Response,
                Octave   = k.Octave,
                ClassId  = k.ClassId
            }));
            return(result);
        }
        public AlgorithmResult DetectKaze(
            string filename,
            KeypointType kpsType,
            float threshold,
            int octaves,
            int sublevels)
        {
            AlgorithmResult   result      = new AlgorithmResult();
            Image <Bgr, byte> image       = ImageHelper.GetImage(filename);
            Image <Bgr, byte> resultImage = new Image <Bgr, byte>(filename);

            // Get features from image
            var kaze      = new KAZE(false, false, threshold, octaves, sublevels, Diffusivity.PmG2);
            var keyPoints = kaze.Detect(image);

            DrawKeypoints(
                image,
                new VectorOfKeyPoint(keyPoints),
                resultImage,
                new Bgr(Color.FromArgb(255, 77, 77)),
                GetKeypointDraw(kpsType));

            result.ImageArray = ImageHelper.SetImage(resultImage);
            result.KeyDatas   = new List <KeyPointModel>();
            result.KeyDatas.AddRange(keyPoints.Select(k => new KeyPointModel()
            {
                X        = k.Point.X,
                Y        = k.Point.Y,
                Size     = k.Size,
                Angle    = k.Angle,
                Response = k.Response,
                Octave   = k.Octave,
                ClassId  = k.ClassId
            }));

            return(result);
        }