Exemplo n.º 1
0
        public static void Save(string name, Image <Gray, byte> img)
        {
            TrainingImages.Add(img);
            Names.Add(name);
            string id = (DateTime.Now.Ticks).ToString();

            Table.BlankRow();
            Table.ReplaceString("id", id);
            Table.ReplaceString("name", name);
            Table.Append();
            img.Save(DBFile.DataFileName("FACE" + id + ".BMP"));
        }
Exemplo n.º 2
0
        internal DBStatus Open()
        {
            if (OpenCount > 0)
            {
                OpenCount++;
                DBStatus stat = new DBStatus();
                stat.Values = new string[FieldCount];
                stat.BlankRow();
                return(stat);
            }

            try {
                DBStream = new FileStream(DataFileName(Name + DBFEXENSION), FileMode.Open);
            }catch (Exception e) {
                LogError(e);
                return(null);
            }

            Formatter = new BinaryFormatter();
            Header    = (DBHeader)Formatter.Deserialize(DBStream);
            if (!Header.IsValid())
            {
                DBStream.Close();
                ServerLog.Register("No se puedo abrir \"" + Name + "\" debido a que el encabezado es inválido.");
                return(null);
            }
            FieldCount = Header.Fields;
            Fields     = new DBField[FieldCount];
            for (int i = 0; i < FieldCount; i++)
            {
                DBField field = (DBField)Formatter.Deserialize(DBStream);
                field.Name = Encoding.ASCII.GetString(field.BName).Trim();
                Fields[i]  = field;
            }

            DBStatus status = new DBStatus();

            status.Table  = this;
            status.Values = new string[FieldCount];
            status.BlankRow();
            return(status);
        }