Exemplo n.º 1
0
        void IrisUploadNow(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker w = sender as BackgroundWorker;
            int ins            = int.MinValue;

            w.ReportProgress(ins++, "Initializing The Scanning Engine");
            Thread.Sleep(1000);
            w.ReportProgress(ins++, "Performing Scanning Iris Image...");
            IrisRecognitionNative.IrisReg ir = new IrisRecognitionNative.IrisReg();
            object c = null;

            try { c = ir.createiristemplate(e.Argument.ToString()); }
            catch (Exception ex)
            {
                st.WMsgBox("Invalid Image Or Could not able to locate the IRIS data.\nInput Gray Scale Image of Maximum Size 512x512." + ex.ToString());
            }
            w.ReportProgress(ins++, "Scanning Completed...");
            System.Double[,] res = null;
            if (c != null)
            {
                res = (System.Double[, ])c;
                w.ReportProgress(ins++, "Calculating Values... Please Wait.");
                string al = AlreadyMatchingTemplate(res);

                if (al == null)
                {
                    st.EMsgBox("Iris Not Found. Unable to Login.");
                    return;
                }
                else
                {
                    //w.ReportProgress(-2, ikey);
                    e.Result = al;
                }
            }
        }
Exemplo n.º 2
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            if (txtIrisImg.Text.Trim().Length == 0)
            {
                st.EMsgBox("Please Input the Path of the Image.");
                return;
            }
            if (!new FileInfo(txtIrisImg.Text.Trim()).Exists)
            {
                st.EMsgBox("Invalid Path. No file Exists.");
                return;
            }
            btnUpload.Enabled       = false;
            btnRegister.Enabled     = false;
            picIris.BackgroundImage = Image.FromFile(txtIrisImg.Text.Trim());
            pl.Visible = true;
            ls.Visible = true;
            ls.Text    = "";
            w          = new BackgroundWorker();
            w.WorkerReportsProgress      = true;
            w.WorkerSupportsCancellation = true;
            w.DoWork += new DoWorkEventHandler((object s1, DoWorkEventArgs e1) =>
            {
                //int p = 1;
                int ins = int.MinValue;
                w.ReportProgress(ins++, "Initializing The Scanning Engine");
                Thread.Sleep(1000);
                w.ReportProgress(ins++, "Performing Scanning Iris Image...");
                IrisRecognitionNative.IrisReg ir = new IrisRecognitionNative.IrisReg();
                object c = null;
                try { c = ir.createiristemplate(txtIrisImg.Text.Trim()); }
                catch (Exception ex)
                {
                    st.WMsgBox("Invalid Image OR Could not able to locate the IRIS data.\nInput Gray Scale Image of Maximum Size 512x512." + ex.ToString());
                }
                w.ReportProgress(ins++, "Scanning Completed...");
                System.Double[,] res = null;
                string ikey          = "";
                if (c != null)
                {
                    res  = (System.Double[, ])c;
                    ikey = RandomString(20);
                    w.ReportProgress(ins++, "Calculating Values... Please Wait.");
                    //st.IMsgBox(HashMatrix(res));

                    /*for (int i = 0; i < res.GetLength(0); i++)
                     * {
                     *  for (int j = 0; j < res.GetLength(1); j++)
                     *  {
                     *      v += res[i, j];
                     *      /* w.ReportProgress(p++, res[i, j]);
                     *      w.ReportProgress(ins++, "Printing : [" + i + "," + j + "] : " + res[i, j]);
                     *      Thread.Sleep(10);
                     *  }
                     * }*/

                    //string al = st.AlreadyStored(st.ObjectToByteArray(res));
                    string al = AlreadyMatchingTemplate(res);

                    if (al != null)
                    {
                        st.WMsgBox("The Iris Information Matches to the Existing Profile. [" + al + "]\n\nPlease Choose the Image of Other Person.");
                        return;
                    }
                    curIrisData = st.ObjectToByteArray(res);
                    w.ReportProgress(-2, ikey);
                }

                /*byte[] udata = null;
                 * if (res != null)
                 * {
                 *  udata = st.ObjectToByteArray(res);
                 * }
                 * e1.Result = udata;*/
            });
            w.ProgressChanged += new ProgressChangedEventHandler((object s2, ProgressChangedEventArgs e2) =>
            {
                pl.Visible = true;
                if (e2.ProgressPercentage < -3)
                {
                    ls.Visible = true;
                    ls.Text    = e2.UserState.ToString();
                    return;
                }
                if (e2.ProgressPercentage == -2)
                {
                    txtImgKey.Text = e2.UserState.ToString();
                    return;
                }
                //richTextBox1.AppendText(e2.UserState.ToString() + " ");
            });
            w.RunWorkerCompleted += new RunWorkerCompletedEventHandler((object s3, RunWorkerCompletedEventArgs e3) =>
            {
                btnUpload.Enabled   = true;
                pl.Visible          = false;
                ls.Text             = "";
                btnRegister.Enabled = true;
                //txtImgKey.Text =
            });
            w.RunWorkerAsync();
        }