Ejemplo n.º 1
0
        /// <summary>
        ///   Process image looking for interest points.
        /// </summary>
        ///
        /// <param name="image">Source image data to process.</param>
        ///
        /// <returns>Returns list of found interest points.</returns>
        ///
        public List <FastRetinaKeypoint> ProcessImage(UnmanagedImage image)
        {
            // check image format
            if (
                (image.PixelFormat != PixelFormat.Format8bppIndexed) &&
                (image.PixelFormat != PixelFormat.Format24bppRgb) &&
                (image.PixelFormat != PixelFormat.Format32bppRgb) &&
                (image.PixelFormat != PixelFormat.Format32bppArgb)
                )
            {
                throw new UnsupportedImageFormatException("Unsupported pixel format of the source image.");
            }

            // make sure we have grayscale image
            if (image.PixelFormat == PixelFormat.Format8bppIndexed)
            {
                grayImage = image;
            }
            else
            {
                // create temporary grayscale image
                grayImage = Grayscale.CommonAlgorithms.BT709.Apply(image);
            }


            // 1. Extract corners points from the image.
            List <IntPoint> corners = Detector.ProcessImage(grayImage);

            List <FastRetinaKeypoint> features = new List <FastRetinaKeypoint>();

            for (int i = 0; i < corners.Count; i++)
            {
                features.Add(new FastRetinaKeypoint(corners[i].X, corners[i].Y));
            }


            // 2. Compute the integral for the given image
            integral = IntegralImage.FromBitmap(grayImage);


            // 3. Compute feature descriptors if required
            descriptor = null;
            if (featureType != FastRetinaKeypointDescriptorType.None)
            {
                descriptor = GetDescriptor();
                descriptor.Compute(features);
            }

            return(features);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///   Gets the <see cref="FastRetinaKeypointDescriptor">
        ///   feature descriptor</see> for the last processed image.
        /// </summary>
        ///
        public FastRetinaKeypointDescriptor GetDescriptor()
        {
            if (descriptor == null || pattern == null)
            {
                if (pattern == null)
                {
                    pattern = new FastRetinaKeypointPattern(octaves, scale);
                }

                descriptor          = new FastRetinaKeypointDescriptor(grayImage, integral, pattern);
                descriptor.Extended = featureType == FastRetinaKeypointDescriptorType.Extended;
            }

            return(descriptor);
        }