Skip to content

Commit f0115ed

Browse files
Merge pull request #318 from microsoft/user/t-limay/StyleTransfer-MediaCapture
Media capture pipeline for webcam streaming
2 parents eda3a69 + caa0688 commit f0115ed

17 files changed

+1040
-194
lines changed

Samples/StyleTransfer/App.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:local="using:StyleTransfer">
66

7-
<Application.Resources>
8-
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
9-
</Application.Resources>
7+
<Application.Resources>
8+
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
9+
</Application.Resources>
1010

1111
</Application>

Samples/StyleTransfer/AppModel.cs

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
using System.Text;
99
using System.Threading.Tasks;
1010
using Windows.Media;
11+
using Windows.Media.Capture;
1112
using Windows.Media.Core;
13+
using Windows.Media.Playback;
14+
using Windows.UI.Composition;
1215

1316
namespace StyleTransfer
1417
{
@@ -17,8 +20,10 @@ class AppModel : INotifyPropertyChanged
1720
public AppModel()
1821
{
1922
this._useGPU = true;
23+
this._modelSource = "candy";
2024
}
2125

26+
// Name of the style transfer model to apply to input media
2227
private string _modelSource;
2328
public string ModelSource
2429
{
@@ -30,14 +35,16 @@ public string ModelSource
3035
}
3136
}
3237

33-
private string _inputMediaSource;
34-
public string InputMediaSource
38+
// Type of input media to use
39+
private string _inputMedia;
40+
public string InputMedia
3541
{
36-
get { return _inputMediaSource; }
42+
get { return _inputMedia; }
3743
set
3844
{
39-
_inputMediaSource = value;
45+
_inputMedia = value;
4046
OnPropertyChanged();
47+
OnPropertyChanged("StreamingControlsVisible");
4148
}
4249
}
4350

@@ -52,18 +59,51 @@ public bool UseGPU
5259
}
5360
}
5461

55-
// In AppModel or in AppViewModel?
56-
private VideoFrame _outputFrame;
57-
public VideoFrame OutputFrame
62+
// MediaSource for transformed media
63+
private MediaSource _outputMediaSource;
64+
public MediaSource OutputMediaSource
5865
{
59-
get { return _outputFrame; }
66+
get { return _outputMediaSource; }
67+
set { _outputMediaSource = value; OnPropertyChanged(); }
68+
}
69+
70+
// MediaSource for the input media
71+
private MediaSource _inputMediaSource;
72+
public MediaSource InputMediaSource
73+
{
74+
get { return _inputMediaSource; }
75+
set { _inputMediaSource = value; OnPropertyChanged(); }
76+
}
77+
78+
// List of cameras available to use as input
79+
private IEnumerable<string> _cameraNamesList;
80+
public IEnumerable<string> CameraNamesList
81+
{
82+
get { return _cameraNamesList; }
83+
set { _cameraNamesList = value; OnPropertyChanged(); }
84+
}
85+
86+
// Index in CameraNamesList of the selected input camera
87+
private int _selectedCameraIndex;
88+
public int SelectedCameraIndex
89+
{
90+
get { return _selectedCameraIndex; }
6091
set
6192
{
62-
_outputFrame = value;
93+
_selectedCameraIndex = value;
6394
OnPropertyChanged();
6495
}
6596
}
6697

98+
public bool StreamingControlsVisible
99+
{
100+
get
101+
{
102+
return _inputMedia == "LiveStream";
103+
}
104+
}
105+
106+
67107
public event PropertyChangedEventHandler PropertyChanged;
68108
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
69109
{

0 commit comments

Comments
 (0)