Skip to content

Commit 64ac95d

Browse files
author
Linnea May
committed
add thread configurer and add lock for copying to output frame
1 parent 54f2812 commit 64ac95d

File tree

9 files changed

+359
-296
lines changed

9 files changed

+359
-296
lines changed

Samples/StyleTransfer/AppModel.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ public InputMediaType InputMedia
7070
}
7171
}
7272

73-
74-
7573
// Input VideoFrame when processing images
7674
private VideoFrame _inputFrame;
7775
public VideoFrame InputFrame

Samples/StyleTransfer/AppViewModel.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ await DispatcherHelper.RunAsync(() =>
8686
};
8787
UseGpu = false;
8888
_isPreviewing = false;
89+
NumThreads = 5;
8990
NotifyUser(true);
9091
}
9192

@@ -97,7 +98,26 @@ public AppModel AppModel
9798
return _appModel;
9899
}
99100
}
100-
101+
private int _numThreads;
102+
public int NumThreads
103+
{
104+
get
105+
{
106+
return _numThreads;
107+
}
108+
set
109+
{
110+
_numThreads = value;
111+
OnPropertyChanged();
112+
}
113+
}
114+
public int MaxThreads
115+
{
116+
get
117+
{
118+
return 10;
119+
}
120+
}
101121
private float _renderFPS;
102122
public float RenderFPS
103123
{
@@ -447,7 +467,8 @@ public async Task ChangeLiveStream()
447467
VideoEffectDefinition videoEffectDefinition = new VideoEffectDefinition(StyleTransferEffectId, new PropertySet() {
448468
{"ModelName", modelPath },
449469
{"UseGpu", UseGpu },
450-
{ "Notifier", _notifier} });
470+
{ "Notifier", _notifier},
471+
{ "NumThreads", NumThreads} });
451472
IMediaExtension videoEffect = await _mediaCapture.AddVideoEffectAsync(videoEffectDefinition, MediaStreamType.VideoPreview);
452473

453474
var props = _mediaCapture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoPreview) as VideoEncodingProperties;

Samples/StyleTransfer/BooleanToVisibilityConverter.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,24 @@ public object ConvertBack(object value, Type targetType, object parameter, strin
2828
return (value is Visibility && (Visibility)value == Visibility.Visible);
2929
}
3030
}
31+
public class InvertBooleanToVisibilityConverter : IValueConverter
32+
{
33+
public InvertBooleanToVisibilityConverter()
34+
{
35+
}
36+
37+
public object Convert(object value, Type targetType, object parameter, string language)
38+
{
39+
if (value is bool && (bool)value)
40+
{
41+
return Visibility.Collapsed;
42+
}
43+
return Visibility.Visible;
44+
}
45+
46+
public object ConvertBack(object value, Type targetType, object parameter, string language)
47+
{
48+
return (value is Visibility && (Visibility)value == Visibility.Collapsed);
49+
}
50+
}
3151
}

0 commit comments

Comments
 (0)