欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

WPF使用AForge調(diào)用攝像頭

 更新時(shí)間:2022年01月30日 11:20:45   作者:痕跡g  
這篇文章介紹了WPF使用AForge調(diào)用攝像頭的方法,對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧

AForge引用

1.創(chuàng)建WPF項(xiàng)目, 在NuGet安裝AForge相關(guān)SDK包:

2.項(xiàng)目引用

2.1.由于在WPF當(dāng)中使用AForge,需要通過(guò)WindowsFormsHost嵌入在WPF當(dāng)中使用, 所以需要給項(xiàng)目添加相關(guān)引用:

2.2.頁(yè)面添加命名空間

.xaml文件中,添加以下命名空間:

        xmlns:wfi ="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
        xmlns:aforge="clr-namespace:AForge.Controls;assembly=AForge.Controls

3.創(chuàng)建控件

為XAML中添加一個(gè)WindowsFormsHost 嵌入一個(gè)VideoSourcePlayer

 <wfi:WindowsFormsHost >
   <aforge:VideoSourcePlayer x:Name="player" Dock="Fill" />
 </wfi:WindowsFormsHost>

初始化

在后臺(tái)代碼中, 添加初始化代碼, 以下代碼模擬設(shè)置的第一個(gè)攝像頭, FilterInfoCollection實(shí)際為一個(gè)集合。

            FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            if (videoDevices.Count > 0)
            {
                var videoDevice = new VideoCaptureDevice(videoDevices[0].MonikerString);
                videoDevice.VideoResolution = videoDevice.VideoCapabilities[0];  //設(shè)置分辨率
                player.VideoSource = videoDevice; //設(shè)置源
                player.Start(); //啟動(dòng)
            }

實(shí)際效果(演示):

拍照

player.GetCurrentVideoFrame();

到此這篇關(guān)于WPF使用AForge調(diào)用攝像頭的文章就介紹到這了。希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論