Exemplo n.º 1
0
        /// <summary>
        /// Recognise a Grayscale Image using the trained Eigen Recogniser
        /// </summary>
        /// <param name="Input_image"></param>
        /// <returns></returns>
        public string Recognise(Image <Gray, byte> Input_image, int Eigen_Thresh, FormYoklama form)
        {
            if (_IsTrained)
            {
                EigenObjectRecognizer.RecognitionResult ER = recognizer.Recognize(Input_image);
                //handle if recognizer.EigenDistanceThreshold is set as a null will be returned
                //NOTE: This is still not working correctley
                if (ER == null)
                {
                    Eigen_label    = "Tanımsız";
                    Eigen_Distance = 0;
                    return(Eigen_label);
                }
                else
                {
                    try
                    {
                        bool    karar = true;
                        OGRENCI ogr   = new OGRENCI();
                        ogr.OGRENCI_NO = ER.Label;
                        ogr            = Veritabani.OGRENCI_GETIR(ogr)[0];
                        Eigen_label    = ogr.AD + " " + ogr.SOYAD;

                        foreach (DataGridViewRow row in form.dgYoklama.Rows)
                        {
                            if (row.Cells[0].Value.ToString().Contains(ogr.OGRENCI_NO))
                            {
                                karar = false;
                            }
                        }

                        if (karar)
                        {
                            OGRENCI ogr2 = new OGRENCI();
                            ogr2 = Veritabani.OGRENCI_GETIR(ogr)[0];
                            form.dgYoklama.Rows.Add(ogr2.OGRENCI_NO, ogr2.AD, ogr2.SOYAD, ogr2.CINSIYET);
                        }

                        Eigen_Distance = ER.Distance;
                        if (Eigen_Thresh > -1)
                        {
                            Eigen_threshold = Eigen_Thresh;
                        }
                        if (Eigen_Distance > Eigen_threshold)
                        {
                            return(Eigen_label);
                        }
                        else
                        {
                            return("Tanımsız");
                        }
                    }
                    catch (Exception)
                    {
                        return("Tanımsız");
                    }
                }
            }
            else
            {
                return("");
            }
        }
        private void yoklamaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormYoklama f = new FormYoklama();

            f.Show();
        }