public void Train(DirectoryInfo dir, int threshold, int size = 60) { FileInfo[] listFile = dir.GetFiles(); numberOfComponents = listFile.Length; this.size = size; this.threshold = threshold; faces = new Image <Gray, byte> [numberOfComponents]; int[] faceNo = new int[numberOfComponents]; this.labels = new String[numberOfComponents]; int i = 0; foreach (FileInfo fi in listFile) { this.labels[i] = Path.GetFileNameWithoutExtension(fi.FullName).Split('_')[0]; faceNo[i] = i; faces[i++] = new Image <Gray, byte>(fi.FullName).Resize(this.size, this.size, INTER.CV_INTER_CUBIC); } try { //MessageBox.Show("" + threshold); recognizer = new FisherFaceRecognizer(this.numberOfComponents, this.threshold); recognizer.Train(faces, faceNo); } catch (Exception E) { MessageBox.Show(E.Message); } }
private void btnLoadRecog_Click(object sender, EventArgs e) { FaceRecognizer fcrec = new FaceRecognizer(); fcrec.Show(); }
public PCA(int numberOfComponents, double threshold = 100) { this.numberOfComponents = numberOfComponents; this.threshold = threshold; recognizer = new EigenFaceRecognizer(this.numberOfComponents, this.threshold); }