将指纹模板保存到SQL数据库 [英] Saving fingerprint template to SQL database

查看:306
本文介绍了将指纹模板保存到SQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有U.are.u指纹4500阅读器,目前它附带的sdk将指纹模板保存为文件而不是数据库。我想将它保存到数据库中,并且还能够从数据库中验证手指。这是下面的代码



我尝试过:



I have U.are.u fingerprint 4500 reader, currently the sdk that came with it saves the fingerprint template as a file instead of to a database. I would like to save it into a database and also be able to verify the finger from the database. That is the code below

What I have tried:

protected virtual void Init()
    {
        try
        {
            Capturer = new DPFP.Capture.Capture();              // Create a capture operation.

            if ( null != Capturer )
                Capturer.EventHandler = this;                   // Subscribe for capturing events.
            else
                SetPrompt("Can't initiate capture operation!");
        }
        catch
        {               
            MessageBox.Show("Can't initiate capture operation!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);            
        }
    }

    protected virtual void Process(DPFP.Sample Sample)
    {
        // Draw fingerprint sample image.
        DrawPicture(ConvertSampleToBitmap(Sample));
    }

    protected void Start()
    {
        if (null != Capturer)
        {
            try
            {
                Capturer.StartCapture();
                SetPrompt("Using the fingerprint reader, scan your fingerprint.");
            }
            catch
            {
                SetPrompt("Can't initiate capture!");
            }
        }
    }

    protected void Stop()
    {
        if (null != Capturer)
        {
            try
            {
                Capturer.StopCapture();
            }
            catch
            {
                SetPrompt("Can't terminate capture!");
            }
        }
    }

#region Form Event Handlers:

    private void CaptureForm_Load(object sender, EventArgs e)
    {
        Init();
        Start();                                                // Start capture operation.
    }

    private void CaptureForm_FormClosed(object sender, FormClosedEventArgs e)
    {
        Stop();
    }
#endregion

#region EventHandler Members:

    public void OnComplete(object Capture, string ReaderSerialNumber, DPFP.Sample Sample)
    {
        MakeReport("The fingerprint sample was captured.");
        SetPrompt("Scan the same fingerprint again.");
        Process(Sample);
    }

    public void OnFingerGone(object Capture, string ReaderSerialNumber)
    {
        MakeReport("The finger was removed from the fingerprint reader.");
    }

    public void OnFingerTouch(object Capture, string ReaderSerialNumber)
    {
        MakeReport("The fingerprint reader was touched.");
    }

    public void OnReaderConnect(object Capture, string ReaderSerialNumber)
    {
        MakeReport("The fingerprint reader was connected.");
    }

    public void OnReaderDisconnect(object Capture, string ReaderSerialNumber)
    {
        MakeReport("The fingerprint reader was disconnected.");
    }

    public void OnSampleQuality(object Capture, string ReaderSerialNumber, DPFP.Capture.CaptureFeedback CaptureFeedback)
    {
        if (CaptureFeedback == DPFP.Capture.CaptureFeedback.Good)
            MakeReport("The quality of the fingerprint sample is good.");
        else
            MakeReport("The quality of the fingerprint sample is poor.");
    }
#endregion

    protected Bitmap ConvertSampleToBitmap(DPFP.Sample Sample)
    {
        DPFP.Capture.SampleConversion Convertor = new DPFP.Capture.SampleConversion();  // Create a sample convertor.
        Bitmap bitmap = null;                                                           // TODO: the size doesn't matter
        Convertor.ConvertToPicture(Sample, ref bitmap);                                 // TODO: return bitmap as a result
        return bitmap;
    }

    protected DPFP.FeatureSet ExtractFeatures(DPFP.Sample Sample, DPFP.Processing.DataPurpose Purpose)
    {
        DPFP.Processing.FeatureExtraction Extractor = new DPFP.Processing.FeatureExtraction();  // Create a feature extractor
        DPFP.Capture.CaptureFeedback feedback = DPFP.Capture.CaptureFeedback.None;
        DPFP.FeatureSet features = new DPFP.FeatureSet();
        Extractor.CreateFeatureSet(Sample, Purpose, ref feedback, ref features);            // TODO: return features as a result?
        if (feedback == DPFP.Capture.CaptureFeedback.Good)
            return features;
        else
            return null;
    }

    protected void SetStatus(string status)
    {
        this.Invoke(new Function(delegate() {
            StatusLine.Text = status;
        }));
    }

    protected void SetPrompt(string prompt)
    {
        this.Invoke(new Function(delegate() {
            Prompt.Text = prompt;
        }));
    }
    protected void MakeReport(string message)
    {
        this.Invoke(new Function(delegate() {
            StatusText.AppendText(message + "\r\n");
        }));
    }

    private void DrawPicture(Bitmap bitmap)
    {
        this.Invoke(new Function(delegate() {
            Picture.Image = new Bitmap(bitmap, Picture.Size);   // fit the image into the picture box
        }));
    }

    private DPFP.Capture.Capture Capturer;

}

推荐答案

将文件保存到磁盘后,您可以将文件中的字节保存到数据库。这基本上与例如将图片从文件保存到数据库相同。



有很多例子,但这里有一个比较存储二进制数据时的不同选项如何存储和获取二进制数据到文件流列 [ ^ ]



当你想再次使用该文件时,从数据库中读取它,将其保存到磁盘并正常使用。
Once the file is saved to the disk you can save the bytes from the file to the database. This is basically the same as for example saving a picture from a file to database.

There are quite a few examples, but here's one comparing different options you have when storing binary data How to store and fetch binary data into a file stream column[^]

And when you want to use the file again, read it from the database, save it to disk and use normally.


这篇关于将指纹模板保存到SQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆