示例#1
0
        /// <summary>
        /// Extract fingerprint featuries.
        /// </summary>
        public byte[] Extract(FingerprintImage fingerprintImage, ExtractionType extractionType)
        {
            if (!isInitialized)
            {
                throw new InvalidOperationException("Initialize FingerprintFeatureExtractor first.");
            }

            if (isDisposed)
            {
                throw new ObjectDisposedException(GetType().Name);
            }

            if (fingerprintImage == null)
            {
                throw new ArgumentNullException("fingerprintImage");
            }

            var featureSetSizeRecommended = 0;
            var featureSetSizeMinimum     = 0;

            CalculateFeatureSizeCore(extractionType, ref featureSetSizeRecommended, ref featureSetSizeMinimum);

            if (featureSetSizeRecommended <= 0)
            {
                throw new OutOfMemoryException();
            }

            var fdFeatures = Marshal.AllocHGlobal(featureSetSizeRecommended);

            var pImageQuality     = (int)FT_IMG_QUALITY.FT_UNKNOWN_IMG_QUALITY;
            var pFeaturesQualit   = (int)FT_FTR_QUALITY.FT_UNKNOWN_FTR_QUALITY;
            var featureSetCreated = 0;

            ExtractFeaturesCore(fxContextHandle, fingerprintImage.OriginalFingerprintImageSize, fingerprintImage.OriginalFingerprintImage, (int)extractionType,
                                featureSetSizeRecommended, fdFeatures, ref pImageQuality, ref pFeaturesQualit, ref featureSetCreated);

            if (featureSetCreated == 0 ||
                pImageQuality != (int)FT_IMG_QUALITY.FT_GOOD_IMG ||
                pFeaturesQualit != (int)FT_FTR_QUALITY.FT_GOOD_FTR)
            {
                throw new InvalidOperationException("Cannot extract features.");
            }

            var featuriesData = new byte[featureSetSizeRecommended];

            Marshal.Copy(fdFeatures, featuriesData, 0, featureSetSizeRecommended);

            Marshal.FreeHGlobal(fdFeatures);

            return(featuriesData);
        }
示例#2
0
        private void FingerprintEngineSampleCollected(object sender, ImageCapturedEventArgs e)
        {
            if (fingerprintImage != null)
            {
                fingerprintImage.Dispose();
            }

            fingerprintImage = e.FingerprintImage;

            var writableBitmap = new WriteableBitmap(fingerprintImage.Width, fingerprintImage.Height, fingerprintImage.DpiX, fingerprintImage.DpiY, PixelFormats.Gray8, BitmapPalettes.Gray256);

            writableBitmap.Lock();

            writableBitmap.WritePixels(new Int32Rect(0, 0, fingerprintImage.Width, fingerprintImage.Height), fingerprintImage.ImageData, fingerprintImage.Width * fingerprintImage.BitPerPixel / 8, 0);

            writableBitmap.Unlock();

            FingerprintImage.Source = writableBitmap;

            //var fpImage = new Services.Fingerprints.FingerprintImage();
            //fpImage.Header.DeviceType = 49264417347272704;
            //fpImage.Format.Bpp = PixelFormats.Gray8.BitsPerPixel;
            //fpImage.Format.ColorRepresentation = FingerprintImageColorRepresantation.NoColorRepresentation;
            //fpImage.Format.Height = fingerprintImage.Height;
            //fpImage.Format.Width = fingerprintImage.Width;
            //fpImage.Format.DpiX = fingerprintImage.DpiX;
            //fpImage.Format.DpiY = fingerprintImage.DpiY;
            //fpImage.Format.ImageType = FingerprintImageType.GrayScale;
            //fpImage.Format.Padding = FingerprintImagePadding.RightPadding;
            //fpImage.Format.Polarity = FingerprintImagePolarity.PositivePolarity;
            //fpImage.Format.SignificantBpp = 8;
            //fpImage.Format.Planes = 1;
            //fpImage.Data = fingerprintImage.ImageData;
            //fingerprintEnrollmentData.Add(new BiometricSample(fpImage,
            //    BiometricSampleHeaderType.DigitalPersonaFingerprintImage));
            using (var fe = new FingerprintFeatureExtractor())
            {
                fe.Initialize();
                var featuries = fe.Extract(fingerprintImage, ExtractionType.FeatureSetForEnrollment);


                fingerprintEnrollmentData.Add(new BiometricSample(featuries,
                                                                  BiometricSampleHeaderType.DigitalPersonaFingerprintFeatureSet));
            }
        }
        private void ImageCaptured(DATA_BLOB data)
        {
            var imageInformationPtr = Marshal.AllocHGlobal((int)data.cbData);

            CopyMemory(imageInformationPtr, data.pbData, data.cbData);

            var imageInformation = (FD_IMAGE)Marshal.PtrToStructure(imageInformationPtr, typeof(FD_IMAGE));

            var imagePtr = imageInformationPtr + (int)imageInformation.uOffsetToImage;

            var imageWidth  = imageInformation.Header.ImageFormat.iWidth;
            var imageHeigth = imageInformation.Header.ImageFormat.iHeight;
            var imageBpp    = (int)imageInformation.Header.ImageFormat.uBPP;

            var imageData = new byte[(imageWidth * imageHeigth * imageBpp + 7) / 8];

            Marshal.Copy(imagePtr, imageData, 0, imageData.Length);

            var fingerprintImage = new FingerprintImage(imageData, imageWidth, imageHeigth, imageBpp,
                                                        imageInformation.Header.ImageFormat.iXdpi, imageInformation.Header.ImageFormat.iYdpi, imageInformationPtr, (int)imageInformation.uSize);

            OnSampleCollected(new ImageCapturedEventArgs(fingerprintImage));
        }
示例#4
0
 public ImageCapturedEventArgs(FingerprintImage fingerprintImage)
 {
     FingerprintImage = fingerprintImage;
 }