Skip to content

Commit

Permalink
Updated to demonstrate camera config
Browse files Browse the repository at this point in the history
  • Loading branch information
sskodje committed Nov 1, 2022
1 parent 69d34e7 commit 5fc264e
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion TestApp/App.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
Expand Down
4 changes: 3 additions & 1 deletion TestApp/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,14 @@

<TextBlock FontFamily="Arial">
<TextBlock.Text>
<MultiBinding StringFormat="{}[Camera] {0} [{1},{2}] ({3} x {4})]">
<MultiBinding StringFormat="{}[Camera] {0} [{1},{2}] {3}fps ({4} x {5})]">
<Binding Path="FriendlyName" />
<Binding Path="Position.Left"
UpdateSourceTrigger="PropertyChanged" />
<Binding Path="Position.Top"
UpdateSourceTrigger="PropertyChanged" />
<Binding Path="CaptureFormat.Framerate"
UpdateSourceTrigger="PropertyChanged" />
<Binding Path="OutputSize.Width"
UpdateSourceTrigger="PropertyChanged" />
<Binding Path="OutputSize.Height"
Expand Down
20 changes: 16 additions & 4 deletions TestApp/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Diagnostics;
using System.IO;
using System.Linq;

using System.Security.Cryptography;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
Expand Down Expand Up @@ -609,7 +609,9 @@ private List<RecordingSourceBase> CreateSelectedRecordingSources()
{
OutputSize = cam.IsCustomOutputSizeEnabled ? cam.OutputSize : null,
SourceRect = cam.IsCustomOutputSourceRectEnabled ? cam.SourceRect : null,
Position = cam.IsCustomPositionEnabled ? cam.Position : null
Position = cam.IsCustomPositionEnabled ? cam.Position : null,
CaptureFormat = cam.CaptureFormat
};
}
else if (x is CheckableRecordableImage img)
Expand Down Expand Up @@ -768,7 +770,7 @@ private void ProgressTimer_Tick(object sender, EventArgs e)
AverageFrameRate = CurrentFrameNumber / DateTimeOffset.FromUnixTimeMilliseconds(_recordedFrameTimes.Last()).Subtract(_recordingStartTime.Value).TotalSeconds;
_recordedFrameTimes.RemoveRange(0, Math.Max(0, _recordedFrameTimes.Count - 10));
double intervalMillis = (double)(_recordedFrameTimes.Last() - _recordedFrameTimes.First());
CurrentFrameRate = (_recordedFrameTimes.Count-1) / (double)intervalMillis * 1000;
CurrentFrameRate = (_recordedFrameTimes.Count - 1) / (double)intervalMillis * 1000;
}
}
private void UpdateProgress()
Expand Down Expand Up @@ -974,7 +976,17 @@ private void RefreshSourceComboBox()

foreach (RecordableCamera cam in Recorder.GetSystemVideoCaptureDevices())
{
RecordingSources.Add(new CheckableRecordableCamera(cam));
var availableFormats = Recorder.GetSupportedVideoCaptureFormatsForDevice(cam.DeviceName);
var formatsToDisplay = availableFormats
.GroupBy(x=>x.Framerate)
.FirstOrDefault()
.GroupBy(x => x.FrameSize)
.SelectMany(x => new List<VideoCaptureFormat> { x.First() })
.ToList();
foreach (var format in formatsToDisplay)
{
RecordingSources.Add(new CheckableRecordableCamera(cam) { CaptureFormat = format });
}
}

RecordingSources.Add(new CheckableRecordableVideo(@"testmedia\cat.mp4"));
Expand Down
2 changes: 1 addition & 1 deletion TestApp/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion TestApp/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion TestApp/TestApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TestApp</RootNamespace>
<AssemblyName>TestApp</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
Expand Down

0 comments on commit 5fc264e

Please sign in to comment.