void start() { DirectoryInfo dirInfo = new DirectoryInfo(@"E:\Work\Work apps\Antony\IFI_DB"); info = dirInfo.GetFiles("*.jpg"); //info.Length numberofimages = info.Length; numOfClasses = numberofimages / ImagePerClass; mymat = new List <double[]>(); List <string> filenames = new List <string>(); for (int i = 0; i < numberofimages; i++) { if (info[i].Name.Substring(3, 2) != "07") { filenames.Add(info[i].Name.Substring(0, 3)); var img = BitmapFactory.New(1, 1).FromStream(info[i].OpenRead()); if (img.PixelWidth != 100 || img.PixelHeight != 150) { img = img.Resize(100, 150, WriteableBitmapExtensions.Interpolation.Bilinear); } mymat.Add(helper.imgtomat(img.ToByteArray())); } } GC.Collect(); if (decide == 0) { pca = new PCA(mymat.ToArray(), filenames, filenames.Count); } else { if (File.Exists(@"E:\Work\Work apps\lda pca face rec\outputFile.txt")) { ObjectToSerialize objectToSerialize = Serializer.DeSerializeObject(@"E:\Work\Work apps\lda pca face rec\outputFile.txt"); lda = objectToSerialize.Lda; } else { lda = new LDA(mymat.ToArray(), filenames, filenames.Count); ObjectToSerialize objectToSerialize = new ObjectToSerialize(); objectToSerialize.Lda = lda; Serializer serializer = new Serializer(); serializer.SerializeObject(@"E:\Work\Work apps\lda pca face rec\outputFile.txt", objectToSerialize); } } }
void start() { DirectoryInfo dirInfo = new DirectoryInfo(@"E:\Work\Work apps\Antony\IFI_DB"); info = dirInfo.GetFiles("*.jpg"); //info.Length numberofimages = info.Length; numOfClasses = numberofimages / ImagePerClass; mymat = new List<double[]>(); List<string> filenames = new List<string>(); for (int i = 0; i < numberofimages; i++) { if (info[i].Name.Substring(3, 2) != "07") { filenames.Add(info[i].Name.Substring(0, 3)); var img = BitmapFactory.New(1, 1).FromStream(info[i].OpenRead()); if (img.PixelWidth != 100 || img.PixelHeight != 150) { img = img.Resize(100, 150, WriteableBitmapExtensions.Interpolation.Bilinear); } mymat.Add(helper.imgtomat(img.ToByteArray())); } } GC.Collect(); if (decide == 0) { pca = new PCA(mymat.ToArray(), filenames, filenames.Count); } else { if (File.Exists(@"E:\Work\Work apps\lda pca face rec\outputFile.txt")) { ObjectToSerialize objectToSerialize = Serializer.DeSerializeObject(@"E:\Work\Work apps\lda pca face rec\outputFile.txt"); lda = objectToSerialize.Lda; } else { lda = new LDA(mymat.ToArray(), filenames, filenames.Count); ObjectToSerialize objectToSerialize = new ObjectToSerialize(); objectToSerialize.Lda = lda ; Serializer serializer = new Serializer(); serializer.SerializeObject(@"E:\Work\Work apps\lda pca face rec\outputFile.txt", objectToSerialize); } } }
public ObjectToSerialize(SerializationInfo info, StreamingContext ctxt) { this.lda = (LDA)info.GetValue("Lda", typeof(LDA)); }