C# 后台开发语言
WPF 的 WPFMediaKit 控件在前台显示 摄像头视频
前端代码
<StackPanel Name="WP_vce" Grid.Column="0" Grid.Row="1">
<WrapPanel HorizontalAlignment="Center" VerticalAlignment="Center" Background="#F6F6F6">
<WPFMediaKit:VideoCaptureElement Grid.Row="1" x:Name="vce" Stretch="Fill" FPS="30" />
</WrapPanel>
</StackPanel>
后端代码
public TakePhoto()
{
InitializeComponent();
this.vce.Width = (float)System.Windows.SystemParameters.PrimaryScreenWidth - 400;
this.vce.Height = (float)System.Windows.SystemParameters.PrimaryScreenHeight - 200;
vce.VideoCaptureSource = "ICT Camera";
vce.Play();
}
WPF运行效果
注:同上面一样的代码是可以打开 笔记本电脑摄像头 和 USB外接摄像头ICT Camera 并正常显示 图画;
在网上找过一些案例, 有一个Winfrom 的例子在本地是能成功打开 USB 2.0 Camera摄像头 画面显示正确, 没有存在 坏的摄像头情况;