亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

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

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

AForge引用

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

2.項目引用

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

2.2.頁面添加命名空間

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

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

3.創(chuàng)建控件

為XAML中添加一個WindowsFormsHost 嵌入一個VideoSourcePlayer

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

初始化

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

            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(); //啟動
            }

實際效果(演示):

拍照

player.GetCurrentVideoFrame();

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

相關(guān)文章

最新評論