示例#1
0
        private List <Minutia> Extract(string fingerprintLabel, ResourceRepository repository)
        {
            Bitmap image = imageProvider.GetResource(fingerprintLabel, repository);

            if (image == null)
            {
                throw new ArgumentOutOfRangeException(fingerprintLabel, "Unable to extract minutia list: Invalid fingerprint!");
            }
            if (MinutiaListExtractor == null)
            {
                throw new InvalidOperationException("Unable to extract minutia list: Unassigned minutia list extractor!");
            }
            return(MinutiaListExtractor.ExtractFeatures(image));
        }
示例#2
0
        private SkeletonImage Extract(string fingerprintLabel, ResourceRepository repository)
        {
            Bitmap image = imageProvider.GetResource(fingerprintLabel, repository);

            if (image == null)
            {
                throw new ArgumentOutOfRangeException("fingerprintLabel", "Unable to extract SkeletonImage: Invalid fingerprint!");
            }
            if (SkeletonImageExtractor == null)
            {
                throw new InvalidOperationException("Unable to extract SkeletonImage: Unassigned skeleton image extractor!");
            }
            return(SkeletonImageExtractor.ExtractFeatures(image));
        }
示例#3
0
        /// <summary>
        ///     Gets the fingerprint image from the specified <see cref="ResourceRepository"/>.
        /// </summary>
        /// <param name="fingerprint">The fingerprint which image is being retrieved.</param>
        /// <param name="repository">The object used to store and retrieve resources.</param>
        /// <returns>The retrieved fingerprint image.</returns>
        public Bitmap GetResource(string fingerprint, ResourceRepository repository)
        {
            byte[] rawImage = null;
            foreach (string ext in new[] { "tif", "bmp", "jpg" })
            {
                string resourceName = string.Format("{0}.{1}", fingerprint, ext);
                rawImage = repository.RetrieveResource(resourceName);
                if (rawImage != null)
                {
                    break;
                }
            }
            if (rawImage == null)
            {
                return(null);
            }
            Bitmap srcBitmap = Image.FromStream(new MemoryStream(rawImage)) as Bitmap;

            if (srcBitmap == null)
            {
                return(null);
            }
            Bitmap returnBitmap;

            using (srcBitmap)
            {
                PixelFormat pixelFormat;
                switch (srcBitmap.PixelFormat)
                {
                case PixelFormat.Format8bppIndexed:
                case PixelFormat.Indexed:
                case PixelFormat.Format4bppIndexed:
                case PixelFormat.Format1bppIndexed:
                    pixelFormat = PixelFormat.Format24bppRgb;
                    break;

                default:
                    pixelFormat = srcBitmap.PixelFormat;
                    break;
                }
                returnBitmap = new Bitmap(srcBitmap.Width, srcBitmap.Height, pixelFormat);
                returnBitmap.SetResolution(srcBitmap.HorizontalResolution, srcBitmap.VerticalResolution);
                Graphics g = Graphics.FromImage(returnBitmap);
                g.DrawImage(srcBitmap, 0, 0);
            }
            return(returnBitmap);
        }
示例#4
0
        /// <summary>
        ///     Gets minutia list from the specified fingerprint and <see cref="ResourceRepository"/>.
        /// </summary>
        /// <param name="fingerprint">The fingerprint which minutia list is being retrieved.</param>
        /// <param name="repository">The object used to store and retrieve resources.</param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when the fingerprint is invalid.</exception>
        /// <exception cref="InvalidOperationException">Thrown when the minutia list extractor is not assigned.</exception>
        /// <returns>The retrieved minutia list.</returns>
        public List <Minutia> GetResource(string fingerprint, ResourceRepository repository)
        {
            bool   isPersistent = IsResourcePersistent();
            string resourceName =
                string.Format("{0}.{1}", fingerprint, GetSignature());

            if (isPersistent && repository.ResourceExists(resourceName))
            {
                return(MinutiaListSerializer.FromByteArray(repository.RetrieveResource(resourceName)));
            }

            List <Minutia> resource = Extract(fingerprint, repository);

            if (resource == null)
            {
                return(null);
            }

            if (isPersistent)
            {
                repository.StoreResource(resourceName, MinutiaListSerializer.ToByteArray(resource));
            }
            return(resource);
        }
示例#5
0
 /// <summary>
 ///     Gets minutia list from the specified fingerprint and <see cref="ResourceRepository"/>.
 /// </summary>
 /// <param name="fingerprint">The fingerprint which minutia list is being retrieved.</param>
 /// <param name="repository">The object used to store and retrieve resources.</param>
 /// <exception cref="ArgumentOutOfRangeException">Thrown when the fingerprint is invalid.</exception>
 /// <exception cref="InvalidOperationException">Thrown when the minutia list extractor is not assigned.</exception>
 /// <returns>The retrieved minutia list.</returns>
 object IResourceProvider.GetResource(string fingerprint, ResourceRepository repository)
 {
     return(GetResource(fingerprint, repository));
 }