private void MainForm_Load(object sender, EventArgs e) { mainBmp = new Bitmap(Image.FromFile("./plane.bmp")); pb_main.Image = mainBmp; double[,] img = ImageTool.GetGreyScale(mainBmp); ImageTool.SetImage(mainBmp, img); int libCount = LoadLibrary("./imgLib", mainBmp.Width, mainBmp.Height, FACES_PER_PERSON); avg = ImageTool.GetAvg(lib); difLib = ImageTool.GetDifferenceArray(lib, avg); sb_lib.Maximum = libCount; libBmp = new Bitmap(mainBmp.Width, mainBmp.Height); EigenObject eigVects = ImageTool.GetEigen(ImageTool.GetA(lib)); ImageTool.normalize(eigVects.vectors); eigFaces = ImageTool.getEigenFaces(eigVects.vectors, difLib); libWeights = new double[lib.Length][]; for (int i = 0; i < lib.Length; i++) { libWeights[i] = ImageTool.getWeights(eigFaces, lib[i], avg); } double[] weights = ImageTool.getWeights(eigFaces, img, avg); comp = ImageTool.compareWeigths(libWeights, weights); int p = ImageTool.smallestVal(comp); lb_person.Text = "Person: " + p; recon = ImageTool.reconstruct(weights, eigFaces, avg); ImageTool.normalize(recon, 255); pb_lib.Image = libBmp; ImageTool.SetImage(libBmp, lib[p]); sb_lib.Value = p; }
public FaceRecog() { mainBmp = new Bitmap(Image.FromFile("./plane.bmp")); //Would be picturebox of compared image. //pb_main.Image = mainBmp; double[,] img = ImageTool.GetGreyScale(mainBmp); ImageTool.SetImage(mainBmp, img); int libCount = LoadLibrary("./imgLib", mainBmp.Width, mainBmp.Height, FACES_PER_PERSON); avg = ImageTool.GetAvg(lib); difLib = ImageTool.GetDifferenceArray(lib, avg); //Would be scrollbar //sb_lib.Maximum = libCount; libBmp = new Bitmap(mainBmp.Width, mainBmp.Height); EigenObject eigVects = ImageTool.GetEigen(ImageTool.GetA(lib)); ImageTool.normalize(eigVects.vectors); eigFaces = ImageTool.getEigenFaces(eigVects.vectors, difLib); libWeights = new double[lib.Length][]; for (int i = 0; i < lib.Length; i++) { libWeights[i] = ImageTool.getWeights(eigFaces, lib[i], avg); } double[] weights = ImageTool.getWeights(eigFaces, img, avg); comp = ImageTool.compareWeigths(libWeights, weights); int p = ImageTool.smallestVal(comp); //Would be guess of face //lb_person.Text = "Person: " + p; recon = ImageTool.reconstruct(weights, eigFaces, avg); ImageTool.normalize(recon, 255); //would be displaying the image. //pb_lib.Image = libBmp; ImageTool.SetImage(libBmp, lib[p]); //Would be setting scrollbar to correct position //sb_lib.Value = p; }