//int cont = 0; public Frm_Login() { InitializeComponent(); heigth = this.Height; width = this.Width; //GARGAMOS LA DETECCION DE LAS CARAS POR haarcascades face = new HaarCascade("haarcascade_frontalface_default.xml"); try { dbc.ObtenerBytesImagen(); //carga de caras y etiquetas para cada imagen string[] Labels = dbc.Name; NumLabels = dbc.TotalUser; ContTrain = NumLabels; string LoadFaces; for (int tf = 0; tf < NumLabels; tf++) { con = tf; Bitmap bmp = new Bitmap(dbc.ConvertByteToImg(con)); LoadFaces = "face" + tf + ".bmp"; trainingImages.Add(new Image <Gray, byte>(bmp)); //cargo la foto con ese nombre labels.Add(Labels[tf]); //cargo el nombre que se encuentre en la posicion del tf } } catch (Exception e) { MessageBox.Show(e + "No hay ningun rosto registrado).", "Cargar rostros", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public Frm_RegistroTrabajador() { InitializeComponent(); heigth = this.Height; width = this.Width; //GARGAMOS LA DETECCION DE LAS CARAS POR haarcascades face = new HaarCascade("haarcascade_frontalface_default.xml"); try { dbc.ObtenerBytesImagen(); //carga de caras previus trainned y etiquetas para cada imagen Labels = dbc.Name; //Labelsinfo.Split('%');//separo los nombres de los usuarios NumLabels = dbc.TotalUser; // Convert.ToInt32(Labels[0]);//extraigo el total de usuarios registrados ContTrain = NumLabels; for (int tf = 0; tf < NumLabels; tf++)//recorro el numero de nombres registrados { con = tf; Bitmap bmp = new Bitmap(dbc.ConvertByteToImg(con)); //LoadFaces = "face" + tf + ".bmp"; trainingImages.Add(new Image <Gray, byte>(bmp)); //cargo la foto con ese nombre labels.Add(Labels[tf]); //cargo el nombre que se encuentre en la posicion del tf } } catch (Exception e) {//Si la variable NumLabels es 0 me presenta el msj MessageBox.Show(e + " No hay ningún rostro en la Base de Datos, por favor añadir por lo menos una cara", "Cragar caras en tu Base de Datos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }