Skip to content

Commit f8333d9

Browse files
Merge pull request #319 from microsoft/user/t-limay/StyleTransfer-InputMedia
Input image pipeline
2 parents f0115ed + 8391cb2 commit f8333d9

File tree

8 files changed

+510
-148
lines changed

8 files changed

+510
-148
lines changed

Samples/FNSCandyStyleTransfer/UWP/cs/MainPage.xaml

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -23,94 +23,94 @@ Copyright (C) Microsoft Corporation. All rights reserved.
2323
</Page.Resources>
2424

2525
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
26-
27-
<Grid>
28-
<Grid.RowDefinitions>
29-
<RowDefinition Height="80"/>
30-
<RowDefinition Height="300*"/>
31-
<RowDefinition Height="30"/>
32-
</Grid.RowDefinitions>
33-
34-
<!--Status and result display-->
26+
27+
<Grid>
28+
<Grid.RowDefinitions>
29+
<RowDefinition Height="80"/>
30+
<RowDefinition Height="300*"/>
31+
<RowDefinition Height="30"/>
32+
</Grid.RowDefinitions>
33+
34+
<!--Status and result display-->
3535
<StackPanel x:Name="UIStatusPanel" Background="#BFFFFFFF" VerticalAlignment="Top" Grid.Row="0">
3636
<ContentControl Name="UIModelControls">
37-
<StackPanel Orientation="Horizontal">
38-
<ToggleSwitch Name="UIToggleInferenceDevice"
37+
<StackPanel Orientation="Horizontal">
38+
<ToggleSwitch Name="UIToggleInferenceDevice"
3939
OnContent="GPU"
4040
OffContent="CPU"
4141
IsOn="True"
4242
Toggled="UIToggleInferenceDevice_Toggled"
4343
Margin="10,0,0,0"/>
4444

45-
<ListBox Name="UIStyleList" SelectionChanged="UIStyleList_SelectionChanged">
46-
<ListBox.ItemsPanel>
47-
<ItemsPanelTemplate>
48-
<VirtualizingStackPanel Orientation="Horizontal"/>
49-
</ItemsPanelTemplate>
50-
</ListBox.ItemsPanel>
51-
</ListBox>
45+
<ListBox Name="UIStyleList" SelectionChanged="UIStyleList_SelectionChanged">
46+
<ListBox.ItemsPanel>
47+
<ItemsPanelTemplate>
48+
<VirtualizingStackPanel Orientation="Horizontal"/>
49+
</ItemsPanelTemplate>
50+
</ListBox.ItemsPanel>
51+
</ListBox>
5252

53-
</StackPanel>
54-
</ContentControl>
53+
</StackPanel>
54+
</ContentControl>
5555

5656

57-
<!--Image preview and acquisition control-->
58-
<ContentControl Name="UIImageControls"
57+
<!--Image preview and acquisition control-->
58+
<ContentControl Name="UIImageControls"
5959
VerticalAlignment="Stretch"
6060
HorizontalAlignment="Stretch"
6161
IsEnabled="False">
6262

63-
<StackPanel Orientation="Horizontal">
64-
<Button Name="UIButtonLiveStream"
63+
<StackPanel Orientation="Horizontal">
64+
<Button Name="UIButtonLiveStream"
6565
ToolTipService.ToolTip="Camera preview"
6666
Click="UIButtonLiveStream_Click">
67-
<Button.Content>
68-
<SymbolIcon Symbol="Video"/>
69-
</Button.Content>
70-
</Button>
71-
<Button Name="UIButtonAcquireImage"
67+
<Button.Content>
68+
<SymbolIcon Symbol="Video"/>
69+
</Button.Content>
70+
</Button>
71+
<Button Name="UIButtonAcquireImage"
7272
ToolTipService.ToolTip="Take a photo"
7373
Click="UIButtonAcquireImage_Click">
74-
<Button.Content>
75-
<SymbolIcon Symbol="Camera"/>
76-
</Button.Content>
77-
</Button>
78-
<Button Name="UIButtonFilePick"
74+
<Button.Content>
75+
<SymbolIcon Symbol="Camera"/>
76+
</Button.Content>
77+
</Button>
78+
<Button Name="UIButtonFilePick"
7979
ToolTipService.ToolTip="Select an image from a file"
8080
Click="UIButtonFilePick_Click">
81-
<Button.Content>
82-
<SymbolIcon Symbol="OpenFile"/>
83-
</Button.Content>
84-
</Button>
85-
<Button Name="UIButtonInking"
81+
<Button.Content>
82+
<SymbolIcon Symbol="OpenFile"/>
83+
</Button.Content>
84+
</Button>
85+
<Button Name="UIButtonInking"
8686
ToolTipService.ToolTip="Draw on a canvas"
8787
Click="UIButtonInking_Click">
88-
<Button.Content>
89-
<SymbolIcon Symbol="Edit"/>
90-
</Button.Content>
91-
</Button>
92-
<Button Name="UIButtonSaveImage"
88+
<Button.Content>
89+
<SymbolIcon Symbol="Edit"/>
90+
</Button.Content>
91+
</Button>
92+
<Button Name="UIButtonSaveImage"
9393
ToolTipService.ToolTip="Save the image result to a file"
9494
IsEnabled="false"
9595
VerticalAlignment="Bottom"
9696
Click="UIButtonSaveImage_Click"
9797
Background="#FF939393" >
98-
<Button.Content>
99-
<SymbolIcon Symbol="Save"/>
100-
</Button.Content>
101-
</Button>
98+
<Button.Content>
99+
<SymbolIcon Symbol="Save"/>
100+
</Button.Content>
101+
</Button>
102102

103-
</StackPanel>
104-
</ContentControl>
105-
</StackPanel>
106-
<!--<StackPanel Orientation="Horizontal">-->
103+
</StackPanel>
104+
</ContentControl>
105+
</StackPanel>
106+
<!--<StackPanel Orientation="Horizontal">-->
107107

108108
<!--<Viewbox Stretch="Uniform" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="1">-->
109-
<Grid Grid.Row="1">
110-
<Grid.ColumnDefinitions>
111-
<ColumnDefinition Width="200*"/>
112-
<ColumnDefinition Width="200*"/>
113-
</Grid.ColumnDefinitions>
109+
<Grid Grid.Row="1">
110+
<Grid.ColumnDefinitions>
111+
<ColumnDefinition Width="200*"/>
112+
<ColumnDefinition Width="200*"/>
113+
</Grid.ColumnDefinitions>
114114

115115
<Viewbox Stretch="Uniform">
116116
<StackPanel Name="UIInkControls"
@@ -138,46 +138,46 @@ Copyright (C) Microsoft Corporation. All rights reserved.
138138
</Viewbox>
139139

140140
<!--Camera preview-->
141-
<MediaPlayerElement Name="UIMediaPlayerElement"
141+
<MediaPlayerElement Name="UIMediaPlayerElement"
142142
Stretch="Uniform"
143143
AreTransportControlsEnabled="False"
144144
Canvas.ZIndex="-1"
145145
MaxWidth="720"
146146
MaxHeight="720"
147147
Grid.Column="0"/>
148148

149-
<Image Name="UIInputImage"
149+
<Image Name="UIInputImage"
150150
Grid.Column="0"
151151
Stretch="Uniform"
152152
MaxWidth="720"
153153
MaxHeight="720"/>
154154

155-
<Grid Grid.Column="1" VerticalAlignment="Stretch">
155+
<Grid Grid.Column="1" VerticalAlignment="Stretch">
156156

157-
<Image Name="UIResultImage"
157+
<Image Name="UIResultImage"
158158
Stretch="Uniform"
159159
MaxWidth="720"
160160
MaxHeight="720"/>
161161

162-
<ProgressRing Name="UIProcessingProgressRing"
162+
<ProgressRing Name="UIProcessingProgressRing"
163163
MaxWidth="720"
164164
MaxHeight="720"
165165
IsActive="false"
166166
Visibility="Collapsed"/>
167-
</Grid>
168167
</Grid>
169-
<!--</Viewbox>-->
170-
171-
<StackPanel Name="UICameraSelectionControls" Orientation="vertical" Visibility="Collapsed" VerticalAlignment="Bottom" HorizontalAlignment="Left" Grid.Row="1">
172-
<TextBlock Text="Camera: " Style="{StaticResource TextBlockStyling}"/>
173-
<ComboBox Name="UICmbCamera" SelectionChanged="UICmbCamera_SelectionChanged" Foreground="White" >
174-
<ComboBox.Background>
175-
<SolidColorBrush Color="Black" Opacity="0.3"/>
176-
</ComboBox.Background>
177-
</ComboBox>
178-
<TextBlock Text="Preview resolution: " Style="{StaticResource TextBlockStyling}"/>
179-
<TextBlock Name="UITxtBlockPreviewProperties" Text="0x0" Style="{StaticResource TextBlockStyling}"/>
180-
</StackPanel>
168+
</Grid>
169+
<!--</Viewbox>-->
170+
171+
<StackPanel Name="UICameraSelectionControls" Orientation="vertical" Visibility="Collapsed" VerticalAlignment="Bottom" HorizontalAlignment="Left" Grid.Row="1">
172+
<TextBlock Text="Camera: " Style="{StaticResource TextBlockStyling}"/>
173+
<ComboBox Name="UICmbCamera" SelectionChanged="UICmbCamera_SelectionChanged" Foreground="White" >
174+
<ComboBox.Background>
175+
<SolidColorBrush Color="Black" Opacity="0.3"/>
176+
</ComboBox.Background>
177+
</ComboBox>
178+
<TextBlock Text="Preview resolution: " Style="{StaticResource TextBlockStyling}"/>
179+
<TextBlock Name="UITxtBlockPreviewProperties" Text="0x0" Style="{StaticResource TextBlockStyling}"/>
180+
</StackPanel>
181181

182182
<Border x:Name="UIStatusBorder" Grid.Row="2">
183183
<StackPanel Orientation="Horizontal">
@@ -207,6 +207,6 @@ Copyright (C) Microsoft Corporation. All rights reserved.
207207
</Border>
208208

209209
</Grid>
210-
210+
211211
</Grid>
212212
</Page>

Samples/StyleTransfer/AppModel.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,29 @@ public bool UseGPU
5959
}
6060
}
6161

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+
}
6285
// MediaSource for transformed media
6386
private MediaSource _outputMediaSource;
6487
public MediaSource OutputMediaSource

0 commit comments

Comments
 (0)