private void btn_learn_resize_Click(object sender, EventArgs e) { foreach (string imgpath in trainFolder.GetAll()) { Mat tmp = new Mat(imgpath); tmp = ImgOps.InterpolationResize(tmp, 32, 32); tmp = ImgOps.RGBtoGrey(tmp).Mat; } }
private void btn_CNN_recognize_Click(object sender, EventArgs e) { if (tb_imgs_path.Text != "") { if (!Directory.Exists(tb_imgs_path.Text)) { MessageBox.Show("Folder does not exists"); return; } recognizeImageFolder.Load(tb_imgs_path.Text); List <string> sarr = new List <string>(); foreach (string s in recognizeImageFolder.GetAll()) { Mat im = new Mat(s); if (im.NumberOfChannels != 1) { im = ImgOps.RGBtoGrey(im).Mat; } if (im.Size != new Size(32, 32)) { im = new Image <Gray, byte>(ImgOps.InterpolationResize(im, 32, 32).Bitmap).Mat; } Image <Gray, byte> img = new Image <Gray, byte>(im.Bitmap); string sign = network.Recognize(img.Bytes); sarr.Add(sign); } string name = "results.txt"; string filepath = Path.Combine(recognizeImageFolder.GetPath(), name); List <string> res = new List <string>(); for (int i = 0; i < sarr.Count; i++) { res.Add(recognizeImageFolder.GetAll()[i] + "_!_" + sarr[i]); } File.WriteAllLines(filepath, res); } else { MessageBox.Show("Path to images is empty"); } }