private void button6_Click(object sender, EventArgs e) { System.Environment.CurrentDirectory = apppath; if (File.Exists(apppath + @"\output.mp4")) { File.Delete(apppath + @"\output.mp4"); } var app = new System.Diagnostics.ProcessStartInfo(); app.FileName = "cmd.exe"; app.UseShellExecute = true; app.Arguments = " /c png2Video_input_run.bat"; if (!checkBox1.Checked) { app.Arguments += " (4/" + numericUpDown1.Value.ToString() + ") "; } else { app.Arguments += " 4*" + numericUpDown1.Value.ToString(); } var png2Video_input = System.Diagnostics.Process.Start(app); png2Video_input.EnableRaisingEvents = true; app = new System.Diagnostics.ProcessStartInfo(); app.FileName = "cmd.exe"; app.UseShellExecute = true; app.Arguments = " /c png2video_run.bat"; if (!checkBox1.Checked) { app.Arguments += " (1/" + numericUpDown1.Value.ToString() + ") "; } else { app.Arguments += " " + numericUpDown1.Value.ToString(); } var png2video_run = System.Diagnostics.Process.Start(app); png2video_run.EnableRaisingEvents = true; png2video_run.WaitForExit(); png2Video_input.WaitForExit(); app = new System.Diagnostics.ProcessStartInfo(); app.FileName = "cmd.exe"; app.UseShellExecute = true; app.Arguments = " /c JoinLRVideo_run.bat"; var JoinLRVideo = System.Diagnostics.Process.Start(app); JoinLRVideo.EnableRaisingEvents = true; JoinLRVideo.WaitForExit(); MessageBox.Show("finished"); if (File.Exists(apppath + @"\output.mp4")) { Form2 video = new Form2(); video.axWindowsMediaPlayer1.URL = apppath + @"\output.mp4"; video.Show(); } }
private void finalProc() { System.Environment.CurrentDirectory = apppath + "\\main"; string directoryName = apppath; string fileName = "temp"; string extension = ".png"; if (openFileDialog1.FileName != "") { directoryName = System.IO.Path.GetDirectoryName(openFileDialog1.FileName); fileName = System.IO.Path.GetFileNameWithoutExtension(openFileDialog1.FileName); extension = System.IO.Path.GetExtension(openFileDialog1.FileName); } pictureBox2.Image = CreateImage(string.Format(@"tecoGAN\results\calendar\output_{0:D4}" + ".png", 1)); string outfile = ""; outfile = directoryName + "\\" + fileName + "_super_res.avi"; if (File.Exists(outfile)) { File.Delete(outfile); } OpenCvSharp.Size sz = new OpenCvSharp.Size(pictureBox2.Image.Width, pictureBox2.Image.Height); int codec = 0; // コーデック(AVI) var EncodedFormat = OpenCvSharp.FourCC.MJPG; OpenCvSharp.VideoWriter vw = new OpenCvSharp.VideoWriter(outfile, EncodedFormat, Fps, sz, true); DirectoryInfo images = new DirectoryInfo(@"tecoGAN\results\calendar"); int filenum = 0; foreach (FileInfo file in images.GetFiles()) { filenum++; } progressBar1.Value = 0; progressBar1.Maximum = filenum; for (int i = 0; i < filenum; i++) { if (stopping) { break; } string newfile = string.Format(@"tecoGAN\results\calendar\output_{0:D4}" + ".png", i); if (!System.IO.File.Exists(newfile)) { continue; } var img = OpenCvSharp.Cv2.ImRead(newfile, OpenCvSharp.ImreadModes.Color); if (!checkBox1.Checked) { OpenCvSharp.Cv2.Resize(img, img, new OpenCvSharp.Size((int)((float)img.Width * (float)numericUpDown1.Value), (int)((float)img.Height * (float)numericUpDown1.Value)), 0, 0); } else { OpenCvSharp.Cv2.Resize(img, img, new OpenCvSharp.Size((int)(0.5f + (float)img.Width / (float)numericUpDown1.Value), (int)(0.5f + (float)img.Height / (float)numericUpDown1.Value)), 0, 0); } pictureBox1.Image = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(img); //pictureBox2.Image = CreateImage(newfile); newfile = string.Format(@"tecoGAN\LR\calendar\{0:D4}" + ".png", i); if (!System.IO.File.Exists(newfile)) { continue; } pictureBox1.Image = CreateImage(newfile); vw.Write(img); progressBar1.Value++; progressBar1.Refresh(); Application.DoEvents(); // 非推奨 } vw.Dispose(); stopping = false; MessageBox.Show("finished"); if (File.Exists(outfile)) { Form2 video = new Form2(); video.axWindowsMediaPlayer1.URL = outfile; video.Show(); } progressBar1.Value = 0; }