Skip to content

Commit 4ac6fbd

Browse files
basic video effect from documentation sample
1 parent c1fea51 commit 4ac6fbd

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Samples/StyleTransfer/AppViewModel.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
using System.Diagnostics;
1212
using Windows.Media.Capture;
1313
using Windows.Media.Playback;
14+
using Windows.Media.Effects;
15+
using Windows.Media;
16+
using Windows.Foundation.Collections;
1417

1518
namespace StyleTransfer
1619
{
@@ -99,6 +102,12 @@ public async Task StartWebcamStream()
99102

100103
// Initialize MediaCapture
101104
await _mediaCapture.InitializeAsync(settings);
105+
106+
// Initialize VideoEffect
107+
var videoEffectDefinition = new VideoEffectDefinition("VideoEffectComponent.StyleTransferVideoEffect");
108+
IMediaExtension videoEffect = await _mediaCapture.AddVideoEffectAsync(videoEffectDefinition, MediaStreamType.VideoPreview);
109+
videoEffect.SetProperties(new PropertySet() { { "FadeValue", .15 } });
110+
102111
StartPreview();
103112
}
104113
catch (Exception ex)
@@ -124,6 +133,7 @@ public void SetMediaSource(object obj)
124133

125134
private void StartPreview()
126135
{
136+
127137
Debug.WriteLine("StartPreview");
128138
_selectedMediaFrameSource = _mediaCapture.FrameSources.FirstOrDefault(source => source.Value.Info.MediaStreamType == MediaStreamType.VideoPreview
129139
&& source.Value.Info.SourceKind == MediaFrameSourceKind.Color).Value;

Samples/StyleTransfer/StyleTransfer.csproj

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<UseVSHostingProcess>false</UseVSHostingProcess>
3030
<ErrorReport>prompt</ErrorReport>
3131
<Prefer32Bit>true</Prefer32Bit>
32+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
3233
</PropertyGroup>
3334
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
3435
<OutputPath>bin\x86\Release\</OutputPath>
@@ -41,6 +42,7 @@
4142
<ErrorReport>prompt</ErrorReport>
4243
<Prefer32Bit>true</Prefer32Bit>
4344
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
45+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
4446
</PropertyGroup>
4547
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
4648
<DebugSymbols>true</DebugSymbols>
@@ -52,6 +54,7 @@
5254
<UseVSHostingProcess>false</UseVSHostingProcess>
5355
<ErrorReport>prompt</ErrorReport>
5456
<Prefer32Bit>true</Prefer32Bit>
57+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
5558
</PropertyGroup>
5659
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
5760
<OutputPath>bin\ARM\Release\</OutputPath>
@@ -64,6 +67,7 @@
6467
<ErrorReport>prompt</ErrorReport>
6568
<Prefer32Bit>true</Prefer32Bit>
6669
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
70+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
6771
</PropertyGroup>
6872
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'">
6973
<DebugSymbols>true</DebugSymbols>
@@ -76,6 +80,7 @@
7680
<ErrorReport>prompt</ErrorReport>
7781
<Prefer32Bit>true</Prefer32Bit>
7882
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
83+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
7984
</PropertyGroup>
8085
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM64'">
8186
<OutputPath>bin\ARM64\Release\</OutputPath>
@@ -88,6 +93,7 @@
8893
<ErrorReport>prompt</ErrorReport>
8994
<Prefer32Bit>true</Prefer32Bit>
9095
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
96+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
9197
</PropertyGroup>
9298
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
9399
<DebugSymbols>true</DebugSymbols>
@@ -99,6 +105,7 @@
99105
<UseVSHostingProcess>false</UseVSHostingProcess>
100106
<ErrorReport>prompt</ErrorReport>
101107
<Prefer32Bit>true</Prefer32Bit>
108+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
102109
</PropertyGroup>
103110
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
104111
<OutputPath>bin\x64\Release\</OutputPath>
@@ -111,6 +118,7 @@
111118
<ErrorReport>prompt</ErrorReport>
112119
<Prefer32Bit>true</Prefer32Bit>
113120
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
121+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
114122
</PropertyGroup>
115123
<PropertyGroup>
116124
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
@@ -215,6 +223,11 @@
215223
<ItemGroup>
216224
<PRIResource Include="Strings\en-US\Resources.resw" />
217225
</ItemGroup>
226+
<ItemGroup>
227+
<Reference Include="VideoEffectComponent">
228+
<HintPath>..\..\..\source\repos\VideoEffectComponent\bin\x64\Debug\VideoEffectComponent.winmd</HintPath>
229+
</Reference>
230+
</ItemGroup>
218231
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
219232
<VisualStudioVersion>14.0</VisualStudioVersion>
220233
</PropertyGroup>

0 commit comments

Comments
 (0)