示例#1
0
        public override IEnumerable <RecordValues> GetValues()
        {
            foreach (RecordValues values in Matrix0.GetValues())
            {
                yield return(new RecordValues("Matrix 0 " + values.Name, values.Length));
            }

            foreach (RecordValues values in Matrix1.GetValues())
            {
                yield return(new RecordValues("Matrix 1 " + values.Name, values.Length));
            }

            foreach (RecordValues values in Matrix2.GetValues())
            {
                yield return(new RecordValues("Matrix 2 " + values.Name, values.Length));
            }

            foreach (RecordValues values in Matrix3.GetValues())
            {
                yield return(new RecordValues("Matrix 3 " + values.Name, values.Length));
            }

            foreach (RecordValues values in Matrix4.GetValues())
            {
                yield return(new RecordValues("Matrix 4 " + values.Name, values.Length));
            }
        }
示例#2
0
        public GraphUI()
        {
            _edges = new EdgeCollection();

            this.DoubleBuffered = true;
            Control.CheckForIllegalCrossThreadCalls = false;

            _penEdge        = new Pen(Color.MediumPurple, 4);
            _penEdge.EndCap = LineCap.ArrowAnchor;

            _matrix              = new Matrix1();
            _matrix.SizeChanged += new EventHandler(_matrix_SizeChanged);
            Reset();
        }
示例#3
0
 public override void Calculate()
 {
     int[,] A = new int[Matrix1.GetLength(0), Matrix2.GetLength(1)];
     for (int i = 0; i < Matrix1.GetLength(0); i++)
     {
         for (int j = 0; j < Matrix2.GetLength(1); j++)
         {
             for (int k = 0; k < Matrix1.GetLength(1); k++)
             {
                 A[i, j] += Matrix1[i, k] * Matrix2[k, j];
             }
         }
     }
     MatrixResult = A;
 }
示例#4
0
        private void loaddanhsachsv()
        {
            //MessageBox.Show("AAA");

            labels = null;
            matrix1s = null;
            labels = new List<string>();
            matrix1s = new List<Matrix1>();

            int len = newsizegb.Width; //MessageBox.Show("new size gb with" + len.ToString());
            dt = kketnoi.laydl("select hinh,h.MSSV from Hinh H,sinhvien sv where h.mssv=sv.mssv and malop='" + loptxt.Text.Trim() + "'");
            int indexmt; string dtt2 = "";//============================
            for (int tbd = 0; tbd < dt.Rows.Count; tbd++)
            {
                //MessageBox.Show(dt.Rows.Count.ToString());
                string mangmatran = dt.Rows[tbd]["hinh"].ToString();
                //MessageBox.Show(mangmatran.Length.ToString() +"\n"+mangmatran.ToString());

                //for (int i = 0; i < mangmatran.Length - 1; i += 2)
                //{
                string[] mangmatran1 = mangmatran.Split('.');

                // string s = "";
                //dtt2 = "";
                x = new Matrix1(len, len);
                indexmt = 0;
                for (int j = 0; j < len; j++)
                    for (int k = 0; k < len; k++)
                    {
                        x[j, k] = Convert.ToInt16(mangmatran1[indexmt]);//mangmatran[i][indexmt] - 48;
                        dtt2 += x[j, k];
                        indexmt++;
                        //s += x[j, k];
                    }
                // MessageBox.Show(dtt2);
                labels.Add(dt.Rows[tbd]["MSSV"].ToString());

                matrix1s.Add(x);

                // }
                // dtt2 += x.ToString();//=======================

            }
            //string fileName = Application.StartupPath + "\\dtt2.txt";
            //StreamWriter sw = new StreamWriter(fileName, false);
            //sw.WriteLine(dtt2);
            //sw.Close();

            // gridControl1.DataSource = dt;
        }
示例#5
0
        private void addface_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox1.Text == "" | loptxt.Text == "" | mssvtxt.Text == "") MessageBox.Show("Chưa nhập đủ thông tin");
                else
                {
                    gray = grabber.QueryGrayFrame().Resize(640, 480, INTER.CV_INTER_CUBIC);

                    //Face Detector
                    MCvAvgComp[][] facesDetected = gray.DetectHaarCascade(
             face,
             1.1,
             5,
             Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.FIND_BIGGEST_OBJECT,
             new Size(60, 60));
                    //Action for each element detected
                    foreach (MCvAvgComp f in facesDetected[0])
                    {
                        //  resultface = currentFrame.Copy(f.rect).Convert<Gray, byte>().Resize(100, 100, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
                        TrainedFace = currentFrame.Copy(f.rect).Convert<Gray, byte>();

                        break;
                    }

                    if (resultface == null) { timer3.Start(); return; }
                    //resize face detected image for force to compare the same size with the
                    //test image with cubic interpolation type method
                    TrainedFace = resultface.Resize(100, 100, INTER.CV_INTER_CUBIC);
                    //them ten va face vao mang

                    //Show face added in gray scale
                    //if (dem == 0)
                    imageBox1.Image = TrainedFace;

                    try
                    {
                        //TrainedFace.Save(directory + "face" + matrix1s.Count + ".bmp");
                        grabber.QueryFrame().Resize(640, 480, INTER.CV_INTER_CUBIC).Save(directory + textBox1.Text + matrix1s.Count + ".bmp");

                    }
                    catch (Exception ex)
                    {
                        for (int i = matrix1s.Count; i < dem; i++)
                        {
                            // File.Delete(directory + "face" + (matrix1s.Count + dem) + ".bmp");
                            File.Delete(directory + textBox1.Text + (matrix1s.Count + dem) + ".bmp");
                        }
                    }

                    //tface.Add(TrainedFace);
                    TrainedFace = TrainedFace.Resize(50, 50, INTER.CV_INTER_CUBIC);

                    Bitmap tam = TrainedFace.ToBitmap();
                    Bitmap bmnewsize = new Bitmap(tam, newsizegb);
                    x = PCA.image_2_matrix(bmnewsize);
                    x = Radon1.ApdungRadon(x);// PCA.apDungWaveletGabors(x, 0, 1.56, 1);
                    matrix1stam.Add(x);
                    matrix1s.Add(x);
                    labels.Add(mssvtxt.Text);

                    if (dem != 9)
                        addface.Text = "Add face " + (dem + 2).ToString();
                    dem++;

                    if (dem == 10)
                    {
                        luuanh();
                        MessageBox.Show(textBox1.Text + "'s Face detected and added :)", "Training OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        dem = 0; mauso = 1;
                        // tface = null; tface = new List<Image<Gray, byte>>();
                        matrix1stam = null; matrix1stam = new List<Matrix1>();
                        x = null;
                        imageBox1.Image = null;
                        ibe1.Image = ibe2.Image = ibn.Image = ibm.Image = null;
                        addface.Text = "Add face 1";
                        resultface = resulteyeL = resulteyeR = resultmouth = resultnose = null;
                        refreshdata();

                    }
                    HDfaces++;
                    mauso++;
                    if (HDfaces <= 10)
                    {

                        label9.Text = mauso.ToString();
                        pictureBox1.Image = Image.FromFile(Application.StartupPath.ToString() + "/huongdan/" + HDfaces.ToString() + ".bmp");
                        //MessageBox.Show(HDfaces.ToString());
                    }

                }

            }
            catch (Exception ex)
            {
                dem = 0;
                MessageBox.Show(ex.ToString(), "Training Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
示例#6
0
 public void gabor(Bitmap bmg)
 {
     //Bitmap bmg = new Bitmap(filenamepath);
     Bitmap tam = new Bitmap(bmg, newsizegb);
     x = PCA.image_2_matrix(tam);
     x = Radon1.ApdungRadon(x);//PCA.apDungWaveletGabors(x, 0, 1.56, 1);
 }
示例#7
0
        public void CapNhatAnh(List<double> list, string ma, Matrix1 matrix)
        {
            //Cập nhật số lần
            DataTable dtb = new DataTable();
            SqlCommand cm;
            // SqlDataAdapter da;
            string index = "";
            kketnoi.connect();
            for (int l = 0; l < list.Count; l += 2)
            {
                index += list[l].ToString();
                cm = new SqlCommand("UPDATE [Hinh] SET [SoLan] = @solan WHERE MSSV=@mssv and MaHinh=@mahinh", kketnoi.con);
                string tam = kketnoi.lay1dong("select solan from hinh where mssv='" + ma + "' and mahinh='" + list[l] + "' ");
                if (tam.Trim() == "") tam = "0";
                cm.Parameters.AddWithValue("@solan", Convert.ToInt32(tam) + 1);
                cm.Parameters.AddWithValue("@mssv", ma);
                cm.Parameters.AddWithValue("@mahinh", list[l]);
                kketnoi.connect();
                cm.ExecuteNonQuery();
            }
            kketnoi.connectClose();
            //Tìm kiếm mã ảnh có số lần cập nhật thấp nhất theo mssv
            string mahinh = kketnoi.lay1dong("select top 1  mahinh from hinh where mssv='" + ma + "' and solan<=(select min(solan) from hinh where mssv='" + ma + "')");
            // Lưu ma trận
            string matran = "";
            int row = matrix.NoRows;
            int col = matrix.NoCols;
            for (int k = 0; k < row; k++)
                for (int l = 0; l < col; l++)
                {
                    matran += matrix[k, l];
                    matran += '.';
                }

            string minsolan = kketnoi.lay1dong("select min(solan) from hinh where mssv='" + ma + "'");
            //MessageBox.Show("mssv " + ma + "_" + "\nmahinh it nhat " + mahinh);
            //MessageBox.Show(matran.ToString());

            //cập nhật ma trận +so lan theo mã hình và mssv
            kketnoi.connect();
            cm = new SqlCommand("UPDATE [Hinh] SET [Hinh] = @hinh, solan=@solan, ngaycapnhat=@ngay WHERE MSSV=@mssv and MaHinh=@mahinh", kketnoi.con);
            cm.Parameters.AddWithValue("@hinh", matran);
            cm.Parameters.AddWithValue("@mssv", ma);
            cm.Parameters.AddWithValue("@mahinh", mahinh);
            cm.Parameters.AddWithValue("@solan", Convert.ToInt16(minsolan) + 1);
            cm.Parameters.AddWithValue("@ngay", DateTime.Now.ToString());
            cm.ExecuteNonQuery();
            kketnoi.connectClose();
            //MessageBox.Show(index);
        }