diff --git a/vmaf-gui/Form1.cs b/vmaf-gui/Form1.cs
index c9bcf11..67469db 100644
--- a/vmaf-gui/Form1.cs
+++ b/vmaf-gui/Form1.cs
@@ -1,15 +1,9 @@
using System;
-using System.Collections.Generic;
using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading;
-using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
-using System.Xml;
+using System.Threading;
+using System.Windows.Forms;
namespace vmaf_gui
{
@@ -20,11 +14,11 @@ public Form1()
InitializeComponent();
}
-
+
string ChildProcess(string program_name, string args, bool show)
{
-
+
// Spawn a child process. We don't need output from stdout so we don't capture it
var p = new Process();
p.StartInfo.UseShellExecute = false;
@@ -33,17 +27,17 @@ string ChildProcess(string program_name, string args, bool show)
p.StartInfo.FileName = program_name;
p.StartInfo.Arguments = args;
-
+
p.Start();
-
+
// p.standardoutput is an input stream
-
+
string output = "";
Console.WriteLine(program_name);
Console.WriteLine(args);
-
+
p.WaitForExit();
return output;
}
@@ -72,17 +66,17 @@ private void compressedFileDialog_FileOk(object sender, CancelEventArgs e)
private void Form1_Load(object sender, EventArgs e)
{
-
+
//cmbResolution.SelectedIndex = 1;
-
+
// Get list of model files and add them to the cmbModel form control
string[] models = Directory.GetFiles(".\\model");
foreach (string model in models)
{
string safeName = model.Substring(8, model.Length - 8);
- if (!safeName.Contains(".model")&& safeName.Contains(".json"))
+ if (!safeName.Contains(".model") && safeName.Contains(".json"))
{
- // cmbModel.Items.Add(safeName);
+ // cmbModel.Items.Add(safeName);
}
}
try
@@ -99,17 +93,17 @@ private void Form1_Load(object sender, EventArgs e)
private void button1_Click(object sender, EventArgs e)
{
prgProgress.Value = 0;
-
+
try
{
-
+
originalFileDialog.OpenFile();
compressedFileDialog.OpenFile();
originalFileDialog.Dispose();
compressedFileDialog.Dispose();
- string sourcePath ="\""+ originalFileDialog.FileName + "\"";
+ string sourcePath = "\"" + originalFileDialog.FileName + "\"";
string compressedPath = "\"" + compressedFileDialog.FileName + "\"";
Console.WriteLine(sourcePath);
@@ -136,7 +130,8 @@ private void button1_Click(object sender, EventArgs e)
// Define what functions the thread does
ThreadStart tStart = new ThreadStart(
- () => {
+ () =>
+ {
// Decompress source video file
lblProgress.Invoke(new Action(delegate () { lblProgress.Text = "Decompressing Source..."; }));
@@ -152,18 +147,21 @@ private void button1_Click(object sender, EventArgs e)
vmaf(resolution, model, psnr, ssim);
prgProgress.Invoke(new Action(delegate () { prgProgress.PerformStep(); }));
- // Show results in notepad
+ // Done
prgProgress.Invoke(new Action(delegate () { prgProgress.PerformStep(); }));
lblProgress.Invoke(new Action(delegate () { lblProgress.Text = "Done."; }));
- ChildProcess("notepad", "log.xml", true);
-
-
+
// Clean up form controls and delete .yuv files to save disk space
lblProgress.Invoke(new Action(delegate () { lblProgress.Text = ""; }));
File.Delete("./temp/compressed.yuv");
File.Delete("./temp/source.yuv");
button1.Invoke(new Action(delegate () { button1.Enabled = true; }));
+ // Show Results
+ results resultsForm = new results();
+ resultsForm.showResults("./log.xml");
+ resultsForm.ShowDialog();
+
}
);
@@ -183,12 +181,12 @@ private void button1_Click(object sender, EventArgs e)
}
}
- void decompressVideo(string path,string output)
+ void decompressVideo(string path, string output)
{
try
{
// Use ffmpeg to decompress the video into .yuv file
- ChildProcess("ffmpeg.exe", "-y -i " + path + " -pix_fmt yuv420p -vsync 0 "+ output,false);
+ ChildProcess("ffmpeg.exe", "-y -i " + path + " -pix_fmt yuv420p -vsync 0 " + output, false);
}
catch (Exception err)
{
@@ -196,12 +194,12 @@ void decompressVideo(string path,string output)
}
}
- void vmaf(string resolution,string model,bool psnr,bool ssim)
+ void vmaf(string resolution, string model, bool psnr, bool ssim)
{
// Build arguments list for vmaf
//string args = "yuv420p "+ resolution +" ./temp/source.yuv ./temp/compressed.yuv .\\model\\"+ model +" --log log.xml";
Array res = resolution.Split(' ');
-
+
string args = $"--threads 4 --reference ./temp/source.y4m --distorted ./temp/compressed.y4m -o log.xml";
/*
if (chkPSNR.Checked)
@@ -213,18 +211,17 @@ void vmaf(string resolution,string model,bool psnr,bool ssim)
args += " --ssim";
}*/
- //lblProgress.Text = "Performing VMAF...";
lblProgress.Invoke(new Action(delegate () { lblProgress.Text = "Performing VMAF..."; }));
- ChildProcess("vmaf.exe",args ,false);
+ ChildProcess("vmaf.exe", args, false);
+
+
+
-
-
-
}
-
+
}
-
+
}
diff --git a/vmaf-gui/results.Designer.cs b/vmaf-gui/results.Designer.cs
new file mode 100644
index 0000000..8945937
--- /dev/null
+++ b/vmaf-gui/results.Designer.cs
@@ -0,0 +1,87 @@
+
+namespace vmaf_gui
+{
+ partial class results
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
+ System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
+ System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
+ this.resultsChart = new System.Windows.Forms.DataVisualization.Charting.Chart();
+ this.label1 = new System.Windows.Forms.Label();
+ ((System.ComponentModel.ISupportInitialize)(this.resultsChart)).BeginInit();
+ this.SuspendLayout();
+ //
+ // resultsChart
+ //
+ chartArea1.Name = "ChartArea1";
+ this.resultsChart.ChartAreas.Add(chartArea1);
+ legend1.Name = "Legend1";
+ this.resultsChart.Legends.Add(legend1);
+ this.resultsChart.Location = new System.Drawing.Point(12, 12);
+ this.resultsChart.Name = "resultsChart";
+ series1.ChartArea = "ChartArea1";
+ series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
+ series1.Legend = "Legend1";
+ series1.Name = "VMAF";
+ this.resultsChart.Series.Add(series1);
+ this.resultsChart.Size = new System.Drawing.Size(776, 426);
+ this.resultsChart.TabIndex = 0;
+ this.resultsChart.Text = "chart1";
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.label1.Location = new System.Drawing.Point(795, 13);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(161, 25);
+ this.label1.TabIndex = 1;
+ this.label1.Text = "VMAF: 100.00";
+ //
+ // results
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(962, 450);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.resultsChart);
+ this.Name = "results";
+ this.Text = "results";
+ ((System.ComponentModel.ISupportInitialize)(this.resultsChart)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.DataVisualization.Charting.Chart resultsChart;
+ private System.Windows.Forms.Label label1;
+ }
+}
\ No newline at end of file
diff --git a/vmaf-gui/results.cs b/vmaf-gui/results.cs
new file mode 100644
index 0000000..e26d08e
--- /dev/null
+++ b/vmaf-gui/results.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Data;
+using System.Linq;
+using System.Windows.Forms;
+using System.Windows.Forms.DataVisualization.Charting;
+using System.Xml.Linq;
+
+namespace vmaf_gui
+{
+ public partial class results : Form
+ {
+ public results()
+ {
+ InitializeComponent();
+ }
+
+ public void showResults(string path)
+ {
+ var doc = XDocument.Load(path);
+
+ var frames = from frame in doc.Root.Descendants("frame")
+ select frame;
+
+ double total = 0;
+ foreach (var frame in frames)
+ {
+ double frameNum = double.Parse(frame.Attribute("frameNum").Value);
+ double vmafScore = double.Parse(frame.Attribute("vmaf").Value);
+ total += vmafScore;
+ this.resultsChart.Series["VMAF"].Points.AddXY(frameNum, vmafScore);
+ }
+
+ double average = Math.Round(total / frames.ToArray().Length,2);
+
+ label1.Text = "VMAF: " + average;
+ }
+ }
+}
diff --git a/vmaf-gui/results.resx b/vmaf-gui/results.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/vmaf-gui/results.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/vmaf-gui/vmaf-gui.csproj b/vmaf-gui/vmaf-gui.csproj
index 531ef9b..8256fd3 100644
--- a/vmaf-gui/vmaf-gui.csproj
+++ b/vmaf-gui/vmaf-gui.csproj
@@ -66,6 +66,7 @@
+
@@ -85,6 +86,12 @@
+
+ Form
+
+
+ results.cs
+
Form1.cs
@@ -98,6 +105,9 @@
Resources.resx
True
+
+ results.cs
+
SettingsSingleFileGenerator
Settings.Designer.cs