private void button2_Click(object sender, EventArgs e) { if (comboBox1.Text != "" && comboBox2.Text != "") { yoklamaliste liste = new yoklamaliste(); liste.sinifid = comboBox2.Text; liste.dersid = comboBox1.Text; liste.Show(); } else { MessageBox.Show("Lütfen bilgileri eksiksiz doldurun...", "EKSİK ALAN UYARISI", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
private void yoklama_Load(object sender, EventArgs e) { if (label6.Text == "hafta1") { hafta = 1; } else if (label6.Text == "hafta2") { hafta = 2; } else if (label6.Text == "hafta3") { hafta = 3; } else if (label6.Text == "hafta4") { hafta = 4; } else if (label6.Text == "hafta5") { hafta = 5; } else if (label6.Text == "hafta6") { hafta = 6; } else if (label6.Text == "hafta7") { hafta = 7; } else if (label6.Text == "hafta8") { hafta = 8; } else if (label6.Text == "hafta9") { hafta = 9; } else if (label6.Text == "hafta10") { hafta = 10; } else if (label6.Text == "hafta11") { hafta = 11; } else if (label6.Text == "hafta12") { hafta = 12; } else if (label6.Text == "hafta13") { hafta = 13; } else if (label6.Text == "hafta14") { hafta = 14; } label2.Text = txtFaceName.Text; Capture capture = new Capture(); capture.Start(); capture.ImageGrabbed += (a, b) => { var image = capture.RetrieveBgrFrame(); var grayimage = image.Convert <Gray, byte>(); HaarCascade haaryuz = new HaarCascade("haarcascade_frontalface_alt2.xml"); MCvAvgComp[][] Yuzler = grayimage.DetectHaarCascade(haaryuz, 1.2, 5, HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(15, 15)); MCvFont font = new MCvFont(FONT.CV_FONT_HERSHEY_COMPLEX, 0.5, 0.5); foreach (MCvAvgComp yuz in Yuzler[0]) { var sadeyuz = grayimage.Copy(yuz.rect).Convert <Gray, byte>().Resize(100, 100, INTER.CV_INTER_CUBIC); //Resimler aynı boyutta olmalıdır. O yüzden Resize ile yeniden boyutlandırma yapılmıştır. Aksi taktirde Classifier_Train sınıfının 245. satırında hata alınacaktır. pictureBox2.Image = sadeyuz.ToBitmap(); if (train != null) { if (train.IsTrained) { string name = train.Recognise(sadeyuz); int match_value = (int)train.Get_Eigen_Distance; image.Draw(name + " ", ref font, new Point(yuz.rect.X - 2, yuz.rect.Y - 2), new Bgr(Color.LightGreen)); label5.Text = name; } } image.Draw(yuz.rect, new Bgr(Color.Red), 2); } yuz = label5.Text; pictureBox1.Image = image.ToBitmap(); }; baglanti.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = baglanti; cmd.CommandText = "SELECT * FROM siniff where sinif_adi='" + label4.Text + "'"; SqlDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { sinifid = dr.GetValue(0).ToString(); } baglanti.Close(); baglanti.Open(); SqlCommand derskmt = new SqlCommand(); derskmt.Connection = baglanti; derskmt.CommandText = "SELECT * FROM ders where ders_adi='" + label3.Text + "'"; SqlDataReader dersoku = derskmt.ExecuteReader(); if (dersoku.Read()) { dersid = dersoku.GetValue(0).ToString(); } baglanti.Close(); baglanti.Open(); string kayit = "SELECT ogrenci_no AS [Öğrenci Numarası], ogrenci_adi AS[Öğrenci Adı] FROM ogrenci where sinifid='" + sinifid + "'"; SqlCommand kmt = new SqlCommand(kayit, baglanti); SqlDataAdapter dada = new SqlDataAdapter(kmt); DataTable dtdt = new DataTable(); dada.Fill(dtdt); dataGridView1.DataSource = dtdt; baglanti.Close(); yoklamaliste liste = new yoklamaliste(); liste.listesinifid = sinifid; liste.listedersid = dersid; }