Beispiel #1
0
        private void radioButton1_Click(object sender, EventArgs e)
        {
            if (_fingersCollection == null || _fingersCollection.Count == 0)
            {
                return;
            }

            this.BeginInvoke(new MethodInvoker(delegate() { stopCapturing(); }));

            ProgramMode mode = ProgramMode.Enroll;

            setMode(mode);
            setModeRadioButtons(mode);

            clearLog();

            RadioButton rb       = sender as RadioButton;
            int         rbNumber = "radioButton".Length;

            rbNumber = Int32.Parse(rb.Name.Substring(rbNumber));
            WsqImage wsqImage = _fingersCollection[rbNumber - 1] as WsqImage;

            fingerChanged(rbNumber - 1);

            enrollFromWSQ(wsqImage);
        }
Beispiel #2
0
        private bool enrollFromWSQ(WsqImage wsqImage)
        {
            if (!isUserIdValid())
            {
                return(false);
            }

            MemoryStream ms = null;
            NImage       nImage;

            try
            {
                ms = new MemoryStream(wsqImage.Content);

                nImage = NImageFormat.Wsq.LoadImage(ms);
            }
            catch (Exception ex)
            {
                string text = string.Format("Error creating image retrieved from database {0}", ex.Message);
                ShowErrorMessage(text);

                return(false);
            }
            finally
            {
                if (ms != null)
                {
                    ms.Dispose();
                }
            }

            float horzResolution = nImage.HorzResolution;
            float vertResolution = nImage.VertResolution;

            if (horzResolution < 250)
            {
                horzResolution = 500;
            }
            if (vertResolution < 250)
            {
                vertResolution = 500;
            }

            NGrayscaleImage grayImage = (NGrayscaleImage)NImage.FromImage(NPixelFormat.Grayscale, 0, horzResolution, vertResolution, nImage);

            OnImage(grayImage);

            return(true);
        }
Beispiel #3
0
        private void processEnrolledData(byte[] serializedArrayOfWSQ)
        {
            PictureBox pb;

            ResourceManager rm = new ResourceManager("PSCBioVerification.Form1", this.GetType().Assembly);

            if (serializedArrayOfWSQ == null)
            {
                clearFingerBoxes();

                string text = rm.GetString("msgThePersonHasNotYetBeenEnrolled"); // "The person has not yet been enrolled"

                LogLine(text, true);
                ShowErrorMessage(text);
                return;
            }

            MemoryStream ms = new MemoryStream(serializedArrayOfWSQ);

            //Assembly.Load(string assemblyString)
            // Construct a BinaryFormatter and use it to deserialize the data to the stream.
            BinaryFormatter formatter = new BinaryFormatter();

            try
            {
                formatter.Binder   = new GenericBinder <WsqImage>();
                _fingersCollection = formatter.Deserialize(ms) as ArrayList;
            }
            catch (SerializationException ex)
            {
                LogLine(ex.Message, true);
                ShowErrorMessage(ex.Message);
                return;
            }
            finally
            {
                ms.Close();
            }

            int         bestQuality = 0;
            int         bestQualityRadioButton = 0;
            RadioButton rb = null; Label lab = null; WsqImage wsqImage = null;

            for (int i = 0; i < _fingersCollection.Count; i++)
            {
                Control[] control    = this.Controls.Find("radioButton" + (i + 1).ToString(), true);
                Control[] controlLab = this.Controls.Find("label" + (i + 1).ToString(), true);
                if (control.Length == 0)
                {
                    continue;
                }

                rb  = control[0] as RadioButton;
                lab = controlLab[0] as Label;

                wsqImage = _fingersCollection[i] as WsqImage;
                if (wsqImage == null)
                {
                    rb.Enabled  = false;
                    lab.Enabled = false;
                }
                else
                {
                    rb.Enabled  = true;
                    lab.Enabled = true;
                }

                pb = this.Controls.Find("fpPictureBox" + (i + 1).ToString(), true)[0] as PictureBox;

                if (_fingersCollection[i] != null)
                {
                    try
                    {
                        ms = new MemoryStream(wsqImage.Content);

                        NImage nImage = NImageFormat.Wsq.LoadImage(ms);

                        float horzResolution = nImage.HorzResolution;
                        float vertResolution = nImage.VertResolution;
                        if (horzResolution < 250)
                        {
                            horzResolution = 500;
                        }
                        if (vertResolution < 250)
                        {
                            vertResolution = 500;
                        }

                        NGrayscaleImage grayImage = (NGrayscaleImage)NImage.FromImage(NPixelFormat.Grayscale, 0, horzResolution, vertResolution, nImage);
                        int             q         = GetImageQuality(grayImage, this.Controls.Find("lbFinger" + (i + 1).ToString(), true)[0] as Label);

                        if (bestQuality < q)
                        {
                            bestQuality            = q;
                            bestQualityRadioButton = i;
                        }

                        pb.Image    = nImage.ToBitmap();
                        pb.SizeMode = PictureBoxSizeMode.Zoom;
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                    finally
                    {
                        ms.Close();
                    }
                }
                else
                {
                    pb.Image = null;
                    this.Controls.Find("lbFinger" + (i + 1).ToString(), true)[0].Text = "";
                }
            }

            stopProgressBar();

            rb = this.Controls.Find("radioButton" + (bestQualityRadioButton + 1).ToString(), true)[0] as RadioButton;
            this.BeginInvoke(new MethodInvoker(delegate() { checkRadioButton(rb.Name); }));
        }