-
Notifications
You must be signed in to change notification settings - Fork 440
Expand file tree
/
Copy pathAppModel.cs
More file actions
156 lines (144 loc) · 4.31 KB
/
AppModel.cs
File metadata and controls
156 lines (144 loc) · 4.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Text;
using System.Threading.Tasks;
using Windows.Media;
using Windows.Media.Capture;
using Windows.Media.Core;
using Windows.Media.Playback;
using Windows.UI.Composition;
using Windows.UI.Xaml.Controls;
namespace StyleTransfer
{
enum InputMediaType
{
None,
LiveStream,
AcquireImage,
FilePick
}
class AppModel : INotifyPropertyChanged
{
public AppModel()
{
this._modelSource = "candy";
this._selectedCameraIndex = 0;
this._outputCaptureElement = new CaptureElement();
}
public List<String> ModelFileNames
{
get
{
return new List<string>
{ "candy",
"mosaic",
"la_muse",
"udnie"
};
}
}
// Name of the style transfer model to apply to input media
private string _modelSource;
public string ModelSource
{
get { return _modelSource; }
set
{
_modelSource = value;
OnPropertyChanged();
}
}
// Type of input media to use
private InputMediaType _inputMedia;
public InputMediaType InputMedia
{
get { return _inputMedia; }
set
{
_inputMedia = value;
OnPropertyChanged();
OnPropertyChanged("StreamingControlsVisible");
}
}
// Input VideoFrame when processing images
private VideoFrame _inputFrame;
public VideoFrame InputFrame
{
get { return _inputFrame; }
set
{
_inputFrame = value;
OnPropertyChanged();
}
}
// Output VideoFrame when processing images
private VideoFrame _outputFrame;
public VideoFrame OutputFrame
{
get { return _outputFrame; }
set
{
_outputFrame = value;
OnPropertyChanged();
}
}
// MediaSource for transformed media
private CaptureElement _outputCaptureElement;
public CaptureElement OutputCaptureElement
{
get
{
if (_outputCaptureElement == null)
_outputCaptureElement = new CaptureElement();
return _outputCaptureElement;
}
set
{
_outputCaptureElement = value;
OnPropertyChanged();
}
}
// MediaSource for the input media
private MediaSource _inputMediaSource;
public MediaSource InputMediaSource
{
get { return _inputMediaSource; }
set { _inputMediaSource = value; OnPropertyChanged(); }
}
// List of cameras available to use as input
private IEnumerable<string> _cameraNamesList;
public IEnumerable<string> CameraNamesList
{
get { return _cameraNamesList; }
set { _cameraNamesList = value; OnPropertyChanged(); }
}
// Index in CameraNamesList of the selected input camera
private int _selectedCameraIndex;
public int SelectedCameraIndex
{
get { return _selectedCameraIndex; }
set
{
_selectedCameraIndex = value;
OnPropertyChanged();
}
}
public bool StreamingControlsVisible
{
get
{
return _inputMedia == InputMediaType.LiveStream;
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}