private void TakeSnapshotButton_Click(object sender, RoutedEventArgs e) { // Take snapshot of webcam video. /// DEBUG //string name = @"C:\WebcamSnapshots\test2.jpg"; //@"C:\workspace\Harold\Harold\Resources\pix2pix\samples\3.png"; // /// RELEASE string name = System.IO.Path.GetTempFileName().Replace(".tmp", ".jpg"); Bitmap newBmp = Webcam.GetCurrentImage(); newBmp.Save(name); /// DEBUG PATHS //string[] ls = System.IO.Path.GetTempFileName().Split('\\'); //string pix2pixFilename = @"C:\workspace\Harold\Harold\Resources\pix2pix\outputs\" + ls[ls.Length-1].Replace(".tmp",".png"); //string textFileName = @"C:\workspace\Harold\Harold\Resources\pix2pix\outputs\" + ls[ls.Length - 1].Replace(".tmp", "_text.txt"); /// RELEASE PATHS string tempName = System.IO.Path.GetTempFileName(); string pix2pixFilename = tempName.Replace(".tmp", ".png"); string textFileName = tempName.Replace(".tmp", "_text.txt"); Console.WriteLine(pix2pixFilename); Console.WriteLine("coucou"); myVM.p2pConverter.ConvertImage(name, pix2pixFilename, textFileName, myVM.PythonPathOrigin); myVM.GetStructureFromP2P(); // Extract elements myVM.Pix2pixPath = pix2pixFilename; myVM.SlabPath = pix2pixFilename.Replace(".png", string.Empty) + "_slabs.png"; myVM.WallsPath = pix2pixFilename.Replace(".png", string.Empty) + "_walls.png"; myVM.ColumnsPath = pix2pixFilename.Replace(".png", string.Empty) + "_columns.png"; myVM.OpeningsPath = pix2pixFilename.Replace(".png", string.Empty) + "_openings.png"; //string json = File.ReadAllText(pix2pixFilename.Replace(".png","_contours.json")); //string old = "[\""; //json = json.Replace(old, "["); //old = "\"]"; //json = json.Replace(old, "]"); //old = "]\""; //json = json.Replace(old, "]"); //old = "\"["; //json = json.Replace(old, "["); //Console.WriteLine(json); //try //{ // myVM.MyStructure = JsonConvert.DeserializeObject<Structure>(json); // myVM.StructurePreprocess(); //} //catch(Exception ex) //{ // MessageBox.Show(ex.Message); //} //// Extract text ////string text = System.IO.File.ReadAllText(textFileName); ////Dictionary<string, object[]> texts = JsonConvert.DeserializeObject<Dictionary<string, object[]>>(text); ////Console.WriteLine("text found in the image: {0}", text); ////myVM.ProcessText(text); myVM.BuildView(); }