Skip to content

Commit

Permalink
Version 6.2
Browse files Browse the repository at this point in the history
BUGFIX: High FPS videos replay is in time.
BUGFIX: Change of the framerate is correctly reflected in the timestamps and the replay speed.
  • Loading branch information
avosskuehler committed Dec 27, 2021
1 parent f630ab8 commit c9ea1b3
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 50 deletions.
6 changes: 3 additions & 3 deletions Setup/Setup/Config.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
<?define SupportPhone = "[email protected]"?>
<?define InstallDescription = "Video analysis for science education."?>
<?define UpgradeGuid = "{4830D7E5-685D-4637-B1BD-9A347BB911CF}"?>
<?define ProductVersion="6.1.0" ?>
<?define ProductVersion="6.2.1" ?>

<?if $(var.Platform) = x64 ?>
<?define ProductName = "Viana.NET 6.1" ?>
<?define ProductName = "Viana.NET" ?>
<?define Win64 = "yes" ?>
<?define PlatformName = "x64"?>
<?define PlatformProgramFilesFolder = "ProgramFiles64Folder" ?>
<?else ?>
<?define ProductName = "Viana.NET 6.1" ?>
<?define ProductName = "Viana.NET" ?>
<?define Win64 = "no" ?>
<?define PlatformName = "x86"?>
<?define PlatformProgramFilesFolder = "ProgramFilesFolder" ?>
Expand Down
3 changes: 3 additions & 0 deletions VianaNET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProjectSection
EndProject
Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "Setup", "Setup\Setup\Setup.wixproj", "{2248D372-66FC-471F-89D6-601930B8538D}"
ProjectSection(ProjectDependencies) = postProject
{9DAD3858-72EA-4B23-A8B5-DF12BBC1AAFE} = {9DAD3858-72EA-4B23-A8B5-DF12BBC1AAFE}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
5 changes: 3 additions & 2 deletions VianaNET/Logging/ErrorLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ public static void ProcessException(Exception ex, bool showMessageBox)

string message = GetLogEntryForException(innerException);
WriteLine(message);

if (showMessageBox)
{
// if (showMessageBox)
VianaDialog dlg = new VianaDialog("Exception occured", ex.Message, message, true);
dlg.ShowDialog();
}
Expand All @@ -119,7 +120,7 @@ public static void WriteLine(string line)
{
fs =
new FileStream(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\VianaNETErrorLog.txt",
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\VianaNETErrorLog.txt",
FileMode.Append);
logWriter = new StreamWriter(fs);
}
Expand Down
75 changes: 50 additions & 25 deletions VianaNET/Modules/Video/Control/VideoBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public VideoBase()
this.bkgWorker.DoWork += this.Worker_DoWork;

this.OpenCVObject = new VideoCapture();
this.OpenCVObject.SetExceptionMode(true);
}

/// <summary>
Expand Down Expand Up @@ -754,7 +755,7 @@ private void Worker_DoWork(object sender, DoWorkEventArgs e)
selectionEnd = App.Project.VideoData.SelectionEnd;
});

using (Mat frameMat = new Mat())
try
{
while (!worker.CancellationPending)
{
Expand Down Expand Up @@ -803,6 +804,8 @@ private void Worker_DoWork(object sender, DoWorkEventArgs e)
//fpswatch.Restart();

// Bildverarbeitung grab, retreive, analyze, send to processing chain
var frameMat = new Mat();
//using (var frameMat = new Mat())
{
this.OpenCVObject.Read(frameMat);
if (frameMat.Empty())
Expand All @@ -826,7 +829,8 @@ private void Worker_DoWork(object sender, DoWorkEventArgs e)

if (this.rotation.HasValue)
{
using (Mat rotMat = new Mat())
var rotMat = new Mat();
//using (Mat rotMat = new Mat())
{
Cv2.Rotate(frameMat, rotMat, this.rotation.Value);

Expand All @@ -838,6 +842,8 @@ private void Worker_DoWork(object sender, DoWorkEventArgs e)
Video.Instance.VideoElement.NewFrameCallback(newFrame);
});
}

rotMat.Release();
}
else
{
Expand All @@ -851,10 +857,14 @@ private void Worker_DoWork(object sender, DoWorkEventArgs e)
}
}


frameMat.Release();
GC.Collect();
}
}
catch (Exception ex)
{
ErrorLogger.ProcessException(ex, false);
}
}

/// <summary>
Expand All @@ -863,42 +873,57 @@ private void Worker_DoWork(object sender, DoWorkEventArgs e)
/// </summary>
protected void GrabCurrentFrame()
{
using (Mat frameMat = new Mat())
try
{
this.OpenCVObject.Retrieve(frameMat);
if (frameMat.Empty())
{
return;
}

if (this.rotation.HasValue)
var frameMat = new Mat();
//using (Mat frameMat = new Mat())
{
using (Mat rotMat = new Mat())
this.OpenCVObject.Retrieve(frameMat);
if (frameMat.Empty())
{
Cv2.Rotate(frameMat, rotMat, this.rotation.Value);
return;
}

if (this.rotation.HasValue)
{
var rotMat = new Mat();
//using (Mat rotMat = new Mat())
{
Cv2.Rotate(frameMat, rotMat, this.rotation.Value);

// Must create and use WriteableBitmap in the same thread(UI Thread).
this.Dispatcher.Invoke(() =>
{
WriteableBitmap newFrame = rotMat.ToWriteableBitmap();
Video.Instance.OriginalImageSource = newFrame;
Video.Instance.VideoElement.NewFrameCallback(newFrame);
});
}

rotMat.Release();
}
else
{
// Must create and use WriteableBitmap in the same thread(UI Thread).
this.Dispatcher.Invoke(() =>
{
WriteableBitmap newFrame = rotMat.ToWriteableBitmap();
WriteableBitmap newFrame = frameMat.ToWriteableBitmap();
Video.Instance.OriginalImageSource = newFrame;
Video.Instance.VideoElement.NewFrameCallback(newFrame);
});
}
}
else
{
// Must create and use WriteableBitmap in the same thread(UI Thread).
this.Dispatcher.Invoke(() =>
{
WriteableBitmap newFrame = frameMat.ToWriteableBitmap();
Video.Instance.OriginalImageSource = newFrame;
Video.Instance.VideoElement.NewFrameCallback(newFrame);
});
}
}

UiServices.WaitUntilReady();
frameMat.Release();
GC.Collect();

UiServices.WaitUntilReady();
}
catch (Exception ex)
{
ErrorLogger.ProcessException(ex, false);
}
}
}
}
17 changes: 12 additions & 5 deletions VianaNET/Modules/Video/Control/VideoPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,18 @@ public override double MediaPositionInMS

set
{
this.OpenCVObject.Set(VideoCaptureProperties.PosMsec, value / App.Project.VideoData.FramerateFactor);
//this.OpenCVObject.Set(VideoCaptureProperties.PosFrames, value / this.FrameTimeInMS / App.Project.VideoData.FramerateFactor);
this.OpenCVObject.Grab();
this.GrabCurrentFrame();
this.UpdateFrameIndex();
try
{
this.OpenCVObject.Set(VideoCaptureProperties.PosMsec, value / App.Project.VideoData.FramerateFactor);
//this.OpenCVObject.Set(VideoCaptureProperties.PosFrames, value / this.FrameTimeInMS / App.Project.VideoData.FramerateFactor);
this.OpenCVObject.Grab();
this.GrabCurrentFrame();
this.UpdateFrameIndex();
}
catch (Exception ex)
{
ErrorLogger.ProcessException(ex, false);
}
}
}

Expand Down
13 changes: 5 additions & 8 deletions VianaNET/Modules/Video/Dialogs/VideoInfoDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,11 @@ private void OkClick(object sender, RoutedEventArgs e)
{
this.DialogResult = true;

// Update FPS, if needed
if (this.DefaultFrameRate != this.FrameRate)
{
double factor = this.DefaultFrameRate / this.FrameRate;
App.Project.VideoData.FramerateFactor = factor;
Video.Instance.VideoPlayerElement.MediaDurationInMS = this.Duration * factor;
Video.Instance.VideoElement.FrameTimeInMS = 1000d / this.FrameRate;
}
// Update FPS always cause, when resetting to equal values, it ignores the value
double factor = this.DefaultFrameRate / this.FrameRate;
App.Project.VideoData.FramerateFactor = factor;
Video.Instance.VideoPlayerElement.MediaDurationInMS = this.Duration * factor;
Video.Instance.VideoElement.FrameTimeInMS = 1000d / this.FrameRate;

this.Close();
}
Expand Down
4 changes: 2 additions & 2 deletions VianaNET/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("6.1.*")]
[assembly: AssemblyFileVersion("6.1.0")]
[assembly: AssemblyVersion("6.2.*")]
[assembly: AssemblyFileVersion("6.2.1")]
[assembly: Guid("1E23CAD1-6F4B-4a08-BF9B-91E27D8E2503")]
10 changes: 5 additions & 5 deletions VianaNET/VianaNET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
</Reference>
<Reference Include="WpfMath, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\WpfMath\wpf-math\src\WpfMath\bin\Release\net452\WpfMath.dll</HintPath>
<HintPath>..\..\wpf-math\src\WpfMath\bin\Release\net452\WpfMath.dll</HintPath>
</Reference>
<Reference Include="XAMLMarkupExtensions, Version=2.1.2.0, Culture=neutral, PublicKeyToken=c726e0262981a1eb, processorArchitecture=MSIL">
<HintPath>..\packages\XAMLMarkupExtensions.2.1.2\lib\net48\XAMLMarkupExtensions.dll</HintPath>
Expand Down Expand Up @@ -939,22 +939,22 @@
<ItemGroup>
<PublishFile Include="CustomStyles\FontAwesome\fontawesome-all.css">
<Visible>False</Visible>
<PublishState>Exclude</PublishState>
<IncludeHash>True</IncludeHash>
<Group>
</Group>
<TargetPath>
</TargetPath>
<PublishState>Exclude</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>File</FileType>
</PublishFile>
<PublishFile Include="CustomStyles\FontAwesome\IconChar.tt">
<Visible>False</Visible>
<PublishState>Exclude</PublishState>
<IncludeHash>True</IncludeHash>
<Group>
</Group>
<TargetPath>
</TargetPath>
<PublishState>Exclude</PublishState>
<IncludeHash>True</IncludeHash>
<FileType>File</FileType>
</PublishFile>
</ItemGroup>
Expand Down

0 comments on commit c9ea1b3

Please sign in to comment.