Skip to content

Commit 0e0e368

Browse files
ok somehow works now let's clean this up
1 parent 4f8c572 commit 0e0e368

File tree

4 files changed

+593
-565
lines changed

4 files changed

+593
-565
lines changed

Samples/StyleTransfer/AppModel.cs

Lines changed: 142 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -1,136 +1,142 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.ComponentModel;
4-
using System.Diagnostics;
5-
using System.Linq;
6-
using System.Runtime.CompilerServices;
7-
using System.Runtime.InteropServices.WindowsRuntime;
8-
using System.Text;
9-
using System.Threading.Tasks;
10-
using Windows.Media;
11-
using Windows.Media.Capture;
12-
using Windows.Media.Core;
13-
using Windows.Media.Playback;
14-
using Windows.UI.Composition;
15-
16-
namespace StyleTransfer
17-
{
18-
class AppModel : INotifyPropertyChanged
19-
{
20-
public AppModel()
21-
{
22-
this._useGPU = true;
23-
this._modelSource = "candy";
24-
}
25-
26-
// Name of the style transfer model to apply to input media
27-
private string _modelSource;
28-
public string ModelSource
29-
{
30-
get { return _modelSource; }
31-
set
32-
{
33-
_modelSource = value;
34-
OnPropertyChanged();
35-
}
36-
}
37-
38-
// Type of input media to use
39-
private string _inputMedia;
40-
public string InputMedia
41-
{
42-
get { return _inputMedia; }
43-
set
44-
{
45-
_inputMedia = value;
46-
OnPropertyChanged();
47-
OnPropertyChanged("StreamingControlsVisible");
48-
}
49-
}
50-
51-
private bool _useGPU;
52-
public bool UseGPU
53-
{
54-
get { return _useGPU; }
55-
set
56-
{
57-
_useGPU = value;
58-
OnPropertyChanged();
59-
}
60-
}
61-
62-
// Input VideoFrame when processing images
63-
private VideoFrame _inputFrame;
64-
public VideoFrame InputFrame
65-
{
66-
get { return _inputFrame; }
67-
set
68-
{
69-
_inputFrame = value;
70-
OnPropertyChanged();
71-
}
72-
}
73-
74-
// Output VideoFrame when processing images
75-
private VideoFrame _outputFrame;
76-
public VideoFrame OutputFrame
77-
{
78-
get { return _outputFrame; }
79-
set
80-
{
81-
_outputFrame = value;
82-
OnPropertyChanged();
83-
}
84-
}
85-
// MediaSource for transformed media
86-
private MediaSource _outputMediaSource;
87-
public MediaSource OutputMediaSource
88-
{
89-
get { return _outputMediaSource; }
90-
set { _outputMediaSource = value; OnPropertyChanged(); }
91-
}
92-
93-
// MediaSource for the input media
94-
private MediaSource _inputMediaSource;
95-
public MediaSource InputMediaSource
96-
{
97-
get { return _inputMediaSource; }
98-
set { _inputMediaSource = value; OnPropertyChanged(); }
99-
}
100-
101-
// List of cameras available to use as input
102-
private IEnumerable<string> _cameraNamesList;
103-
public IEnumerable<string> CameraNamesList
104-
{
105-
get { return _cameraNamesList; }
106-
set { _cameraNamesList = value; OnPropertyChanged(); }
107-
}
108-
109-
// Index in CameraNamesList of the selected input camera
110-
private int _selectedCameraIndex;
111-
public int SelectedCameraIndex
112-
{
113-
get { return _selectedCameraIndex; }
114-
set
115-
{
116-
_selectedCameraIndex = value;
117-
OnPropertyChanged();
118-
}
119-
}
120-
121-
public bool StreamingControlsVisible
122-
{
123-
get
124-
{
125-
return _inputMedia == "LiveStream";
126-
}
127-
}
128-
129-
130-
public event PropertyChangedEventHandler PropertyChanged;
131-
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
132-
{
133-
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
134-
}
135-
}
136-
}
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Diagnostics;
5+
using System.Linq;
6+
using System.Runtime.CompilerServices;
7+
using System.Runtime.InteropServices.WindowsRuntime;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
using Windows.Media;
11+
using Windows.Media.Capture;
12+
using Windows.Media.Core;
13+
using Windows.Media.Playback;
14+
using Windows.UI.Composition;
15+
using Windows.UI.Xaml.Controls;
16+
17+
namespace StyleTransfer
18+
{
19+
class AppModel : INotifyPropertyChanged
20+
{
21+
public AppModel()
22+
{
23+
this._useGPU = true;
24+
this._modelSource = "candy";
25+
this._selectedCameraIndex = 0;
26+
this._outputMediaCapture = new CaptureElement();
27+
}
28+
29+
// Name of the style transfer model to apply to input media
30+
private string _modelSource;
31+
public string ModelSource
32+
{
33+
get { return _modelSource; }
34+
set
35+
{
36+
_modelSource = value;
37+
OnPropertyChanged();
38+
}
39+
}
40+
41+
// Type of input media to use
42+
private string _inputMedia;
43+
public string InputMedia
44+
{
45+
get { return _inputMedia; }
46+
set
47+
{
48+
_inputMedia = value;
49+
OnPropertyChanged();
50+
OnPropertyChanged("StreamingControlsVisible");
51+
}
52+
}
53+
54+
private bool _useGPU;
55+
public bool UseGPU
56+
{
57+
get { return _useGPU; }
58+
set
59+
{
60+
_useGPU = value;
61+
OnPropertyChanged();
62+
}
63+
}
64+
65+
// Input VideoFrame when processing images
66+
private VideoFrame _inputFrame;
67+
public VideoFrame InputFrame
68+
{
69+
get { return _inputFrame; }
70+
set
71+
{
72+
_inputFrame = value;
73+
OnPropertyChanged();
74+
}
75+
}
76+
77+
// Output VideoFrame when processing images
78+
private VideoFrame _outputFrame;
79+
public VideoFrame OutputFrame
80+
{
81+
get { return _outputFrame; }
82+
set
83+
{
84+
_outputFrame = value;
85+
OnPropertyChanged();
86+
}
87+
}
88+
// MediaSource for transformed media
89+
private CaptureElement _outputMediaCapture;
90+
public CaptureElement OutputMediaCapture
91+
{
92+
get {
93+
if (_outputMediaCapture == null) _outputMediaCapture = new CaptureElement();
94+
return _outputMediaCapture;
95+
}
96+
set { _outputMediaCapture = value; OnPropertyChanged(); }
97+
}
98+
99+
// MediaSource for the input media
100+
private MediaSource _inputMediaSource;
101+
public MediaSource InputMediaSource
102+
{
103+
get { return _inputMediaSource; }
104+
set { _inputMediaSource = value; OnPropertyChanged(); }
105+
}
106+
107+
// List of cameras available to use as input
108+
private IEnumerable<string> _cameraNamesList;
109+
public IEnumerable<string> CameraNamesList
110+
{
111+
get { return _cameraNamesList; }
112+
set { _cameraNamesList = value; OnPropertyChanged(); }
113+
}
114+
115+
// Index in CameraNamesList of the selected input camera
116+
private int _selectedCameraIndex;
117+
public int SelectedCameraIndex
118+
{
119+
get { return _selectedCameraIndex; }
120+
set
121+
{
122+
_selectedCameraIndex = value;
123+
OnPropertyChanged();
124+
}
125+
}
126+
127+
public bool StreamingControlsVisible
128+
{
129+
get
130+
{
131+
return _inputMedia == "LiveStream";
132+
}
133+
}
134+
135+
136+
public event PropertyChangedEventHandler PropertyChanged;
137+
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
138+
{
139+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
140+
}
141+
}
142+
}

0 commit comments

Comments
 (0)