Ref: https://github.com/Sascha-L/WPF-MediaKit/
1. ASUS X450J @ Windows 10 x64
2. Visual Studio 2017
3. nuget add
3-1 Helixtoolkit.wpf
3-2 WPFMediaKit
4. new WPF Project
4-1 xaml
<Window x:Class="wk1108.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:wk1108"
xmlns:med="clr-namespace:WPFMediaKit.DirectShow.Controls;assembly=WPFMediaKit"
xmlns:h="http://helix-toolkit.org/wpf"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<h:HelixViewport3D>
<h:DefaultLights/>
<ModelVisual3D>
<ModelVisual3D.Content>
<GeometryModel3D>
<GeometryModel3D.Geometry>
<MeshGeometry3D
Positions="-1 -1 0 1 -1 0 -1 1 0 1 1 0"
TextureCoordinates="1 0 0 0 1 1 0 1 "
TriangleIndices="0 1 2 1 3 2" />
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<VisualBrush>
<VisualBrush.Visual>
<med:VideoCaptureElement Name="VC" EnableSampleGrabbing="True" />
</VisualBrush.Visual>
</VisualBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
<!-- Translate the plane. -->
<GeometryModel3D.Transform>
<TranslateTransform3D
OffsetX="2" OffsetY="0" OffsetZ="-1" >
</TranslateTransform3D>
</GeometryModel3D.Transform>
</GeometryModel3D>
</ModelVisual3D.Content>
</ModelVisual3D>
</h:HelixViewport3D>
</Grid>
</Window>
4-2 C# code
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.Closing += MainWindow_Closing;
VC.VideoCaptureDevice = WPFMediaKit.DirectShow.Controls.MultimediaUtil.VideoInputDevices[0];
}
private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
VC.Stop();
}
}
4-3 手動加入 DirectShowLib-2005.DLL @ package build folder
5. Result
沒有留言:
張貼留言