首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >数字人物指纹作为WSQ捕获图像

数字人物指纹作为WSQ捕获图像
EN

Stack Overflow用户
提问于 2019-10-24 13:50:12
回答 1查看 1.1K关注 0票数 0

我使用数字人物指纹设备,需要将图像捕获为WSQ格式,而不是Bmp格式

使用C# DigitalPersona One Touch for Windows

样本码

代码语言:javascript
运行
复制
private DPFP.Capture.SampleConversion SampleConversion;
private Bitmap Image;
public async void OnComplete(object Capture, string ReaderSerialNumber, DPFP.Sample Sample)
        {

            var imgName = string.Format("fingerprint{0}.bmp", DateTime.Now.Ticks);
            SampleConversion.ConvertToPicture(Sample, ref Image);
            Image.Save(imgName, System.Drawing.Imaging.ImageFormat.Bmp);
        }

我在C#中找到了将bmp转换为wsq wsqEncodeDecode的库,但是wsq的结果不正确,

任何直接从sdk返回以wsq格式捕获的图像的解决方案?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-03-20 12:52:54

为了实现我所需要的,我做了以下工作:

我用了两个图书馆

1- AForge.ImagingAForge.Imaging.FormatsDelta.Wsq DLL

代码语言:javascript
运行
复制
            private Bitmap Image;

        public async void OnComplete(object Capture, string ReaderSerialNumber, DPFP.Sample Sample)
           {
            SampleConversion.ConvertToPicture(Sample, ref Image);
            Image.RotateFlip(RotateFlipType.Rotate180FlipNone);
            Image = resizeImage(364, 400, Image);
            var img8bppx = Grayscale.CommonAlgorithms.BT709.Apply(Image);

            var rawImageData = Conversions.GdiImageToImageInfo(img8bppx);
            WsqEncoder encoder = new WsqEncoder();
            var result = encoder.Encode(rawImageData);
            }

是调整大小的方法。

代码语言:javascript
运行
复制
public Bitmap resizeImage(int newWidth, int newHeight, Image imgPhoto)
        {
            int sourceWidth = imgPhoto.Width;
            int sourceHeight = imgPhoto.Height;

            //Consider vertical pics
            if (sourceWidth < sourceHeight)
            {
                int buff = newWidth;

                newWidth = newHeight;
                newHeight = buff;
            }

            int sourceX = 0, sourceY = 0, destX = 0, destY = 0;
            float nPercent = 0, nPercentW = 0, nPercentH = 0;

            nPercentW = ((float)newWidth / (float)sourceWidth);
            nPercentH = ((float)newHeight / (float)sourceHeight);
            if (nPercentH < nPercentW)
            {
                nPercent = nPercentH;
                destX = System.Convert.ToInt16((newWidth -
                          (sourceWidth * nPercent)) / 2);
            }
            else
            {
                nPercent = nPercentW;
                destY = System.Convert.ToInt16((newHeight -
                          (sourceHeight * nPercent)) / 2);
            }

            int destWidth = (int)(sourceWidth * nPercent);
            int destHeight = (int)(sourceHeight * nPercent);


            Bitmap bmPhoto = new Bitmap(newWidth, newHeight,
                          PixelFormat.Format24bppRgb);

            bmPhoto.SetResolution(imgPhoto.HorizontalResolution,
                         imgPhoto.VerticalResolution);

            Graphics grPhoto = Graphics.FromImage(bmPhoto);
            grPhoto.Clear(Color.Black);
            grPhoto.InterpolationMode =
                System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

            grPhoto.DrawImage(imgPhoto,
                new Rectangle(destX, destY, destWidth, destHeight),
                new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight),
                GraphicsUnit.Pixel);

            grPhoto.Dispose();
            imgPhoto.Dispose();
            return bmPhoto;
        }
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58542855

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档