Пример #1
0
        public void LoadDB()
        {
            using (conn = new SqlCeConnection(stringCon))
            {
                conn.Open();
                using (cmd = new SqlCeCommand(@"SELECT * FROM FaceList", conn))
                {
                    SqlCeDataReader re = cmd.ExecuteReader();
                    while (re.Read())
                    {
                        TFaceRecord fr = new TFaceRecord();
                        fr.ImageFileName = re.GetString(0);
                        fr.subjectName   = re.GetString(1);

                        fr.FacePosition       = new FSDK.TFacePosition();
                        fr.FacePosition.xc    = re.GetInt32(2);
                        fr.FacePosition.yc    = re.GetInt32(3);
                        fr.FacePosition.w     = re.GetInt32(4);
                        fr.FacePosition.angle = re.GetFloat(5);

                        fr.FacialFeatures      = new FSDK.TPoint[2];
                        fr.FacialFeatures[0]   = new FSDK.TPoint();
                        fr.FacialFeatures[0].x = re.GetInt32(6);
                        fr.FacialFeatures[0].y = re.GetInt32(7);

                        fr.FacialFeatures[1]   = new FSDK.TPoint();
                        fr.FacialFeatures[1].x = re.GetInt32(8);
                        fr.FacialFeatures[1].y = re.GetInt32(9);

                        fr.Template = new byte[FSDK.TemplateSize];
                        re.GetBytes(10, 0, fr.Template, 0, FSDK.TemplateSize);

                        Image img      = Image.FromStream(new System.IO.MemoryStream(re.GetSqlBinary(11).Value));
                        Image img_face = Image.FromStream(new System.IO.MemoryStream(re.GetSqlBinary(12).Value));
                        fr.image     = new FSDK.CImage(img);
                        fr.faceImage = new FSDK.CImage(img_face);



                        dbList.Add(fr);

                        img.Dispose();
                        img_face.Dispose();
                    }
                }
                conn.Close();
            }
        }
Пример #2
0
        }     // Load<T>

        public static T LoadData <T>(SqlCeDataReader reader, int dataIndex, int dataAltIdex) where T : class
        {
            if (!reader.IsDBNull(0))
            {
                var data = reader.GetSqlBinary(dataIndex).Value;
                return(XmlSerialization.Deserialize <T>(data));
            }
            else if (!reader.IsDBNull(1))
            {
                var data = reader.GetSqlBinary(dataAltIdex).Value;
                return(XmlSerialization.Deserialize <T>(data));
            }
            else
            {
                return(null);
            } // if-else
        }     // LoadData<T>
Пример #3
0
        public List <TFaceRecord> LoadSubject(string conString)
        {
            InitializeSDK();
            SubjectImageList = new ImageList();

            List <TFaceRecord> SubjectList = new List <TFaceRecord>();

            try
            {
                using (conn = new SqlCeConnection(conString))
                {
                    conn.Open();

                    using (cmd = new SqlCeCommand(@"Select * From FaceList", conn))
                    {
                        SqlCeDataReader reader = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            TFaceRecord fr = new TFaceRecord();
                            fr.ImageFileName = reader.GetString(0);
                            fr.suspectName   = reader.GetString(1);

                            fr.FacePosition       = new FSDK.TFacePosition();
                            fr.FacePosition.xc    = reader.GetInt32(2);
                            fr.FacePosition.yc    = reader.GetInt32(3);
                            fr.FacePosition.w     = reader.GetInt32(4);
                            fr.FacePosition.angle = reader.GetFloat(5);

                            fr.FacialFeatures      = new FSDK.TPoint[2];
                            fr.FacialFeatures[0]   = new FSDK.TPoint();
                            fr.FacialFeatures[0].x = reader.GetInt32(6);
                            fr.FacialFeatures[0].y = reader.GetInt32(7);

                            fr.FacialFeatures[1]   = new FSDK.TPoint();
                            fr.FacialFeatures[1].x = reader.GetInt32(8);
                            fr.FacialFeatures[1].y = reader.GetInt32(9);

                            fr.Template = new byte[FSDK.TemplateSize];
                            reader.GetBytes(10, 0, fr.Template, 0, FSDK.TemplateSize);

                            Image img      = Image.FromStream(new System.IO.MemoryStream(reader.GetSqlBinary(11).Value));
                            Image img_face = Image.FromStream(new System.IO.MemoryStream(reader.GetSqlBinary(12).Value));
                            fr.image     = new FSDK.CImage(img);
                            fr.faceImage = new FSDK.CImage(img_face);

                            SubjectList.Add(fr);
                            SubjectImageList.Images.Add(fr.faceImage.ToCLRImage());

                            img.Dispose();
                            img_face.Dispose();
                        }
                    }
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Exception on loading database");
            }

            return(SubjectList);
        }