【问题标题】:Saving fingerprint template to SQL database将指纹模板保存到 SQL 数据库
【发布时间】:2017-01-12 09:59:17
【问题描述】:

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

namespace Enrollment
{
    /* NOTE: This form is a base for the EnrollmentForm and the VerificationForm,
        All changes in the CaptureForm will be reflected in all its derived forms.
    */
    public partial class CaptureForm : Form, DPFP.Capture.EventHandler
    {
        public CaptureForm()
        {
            InitializeComponent();
        }

        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;

    }
}

【问题讨论】:

  • 你的问题是什么?
  • 如何将指纹模板保存到SQL数据库中
  • 关于如何使用 C# 和 SQL Server 保存数据的例子不胜枚举——发布 200 行代码并不是一个好问题。请阅读有关提出好问题的常见问题解答,并在您真正有问题时回来。只是有工作要做并不是在这里发布问题的理由。
  • 这不是一份工作,这是我最后一年的项目。我真的很需要帮助,每次来这里都没有人想帮助我,总是说我应该先做这个还是先做那个,请不要有人帮我吗?

标签: c# sql


【解决方案1】:

您还没有展示数据库交互代码,所以实际上没有人可以帮助您。要指导您了解您想要什么,请执行以下操作:-

  1. Process 函数是您可以将指纹保存到 DB 的地方。 将转换后的Bitmap或直接DPFP.Sample格式作为二进制数据或字节数组保存到DB。选择取决于您的设计。建议Bitmap 方便维护。

    protected virtual void Process(DPFP.Sample Sample) {

        // Draw fingerprint sample image.
        var fingerprintBMP = DrawPicture(ConvertSampleToBitmap(Sample));
        //Call a function eg. SaveToDB(fingerprintBMP) to save to DB
    

    }

  2. SaveToDB 函数应该没有问题。参考link

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-03
    • 1970-01-01
    相关资源
    最近更新 更多