diff --git a/QSoft.MediaCapture/WebCam_MF.cs b/QSoft.MediaCapture/WebCam_MF.cs index 740c658..073ac6a 100644 --- a/QSoft.MediaCapture/WebCam_MF.cs +++ b/QSoft.MediaCapture/WebCam_MF.cs @@ -5,6 +5,8 @@ using System.Runtime.InteropServices; using System.Threading.Tasks; +//https://learn.microsoft.com/zh-tw/windows/win32/api/mfidl/nn-mfidl-imfcameraconfigurationmanager + namespace QSoft.MediaCapture { public sealed class WebCam_MF: IMFCaptureEngineOnEventCallback,IDisposable diff --git a/README.md b/README.md index b6e3111..ee1db3e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,30 @@ -# QSoft.MediaCapture -https://learn.microsoft.com/zh-tw/windows/win32/api/mfidl/nn-mfidl-imfcameraconfigurationmanager \ No newline at end of file +# Quick start +## Search all video capture +```c# +foreach(var oo in QSoft.MediaCapture.WebCam_MF.GetAllWebCams()) +{ + System.Diagnostics.Trace.WriteLine(oo.FriendName); + System.Diagnostics.Trace.WriteLine(oo.SymbolLinkName); +} +``` +and filter FriendName, SymbolLinkName get it + +# Init and start preview +```c# +var camera = QSoft.MediaCapture.WebCam_MF.GetAllWebCams().Find(x => x.FriendName == "USB2.0 HD UVC WebCam"); +if(camera != null) +{ + await camera.InitCaptureEngine(); + await camera.StartPreview(host.Child.Handle); +} +``` +try below code when use WPF +```c# +var camera = QSoft.MediaCapture.WebCam_MF.GetAllWebCams().Find(x => x.FriendName == "USB2.0 HD UVC WebCam"); +if(camera != null) +{ + await camera.InitCaptureEngine(); + await camera.StartPreview(x => this.image.Source = x); +} + +``` \ No newline at end of file diff --git a/WpfAppNET472/Window_NET472.xaml.cs b/WpfAppNET472/Window_NET472.xaml.cs index 77c4177..b48308f 100644 --- a/WpfAppNET472/Window_NET472.xaml.cs +++ b/WpfAppNET472/Window_NET472.xaml.cs @@ -31,15 +31,24 @@ public Window_NET472() MainUI m_MainUI; private async void Window_Loaded(object sender, RoutedEventArgs e) { - if(m_MainUI == null) + if (m_MainUI == null) { this.DataContext = this.m_MainUI = new MainUI(); - foreach(var oo in QSoft.MediaCapture.WebCam_MF.GetAllWebCams()) + //foreach(var oo in QSoft.MediaCapture.WebCam_MF.GetAllWebCams()) + //{ + // System.Diagnostics.Trace.WriteLine(oo.FriendName); + // System.Diagnostics.Trace.WriteLine(oo.SymbolLinkName); + // //await oo.InitCaptureEngine(); + // ////await oo.StartPreview(host.Child.Handle); + // //await oo.StartPreview(x => this.image.Source = x); + // //this.m_MainUI.WebCams.Add(oo); + //} + + var camera = QSoft.MediaCapture.WebCam_MF.GetAllWebCams().Find(x => x.FriendName == "USB2.0 HD UVC WebCam"); + if(camera != null) { - await oo.InitCaptureEngine(); - //await oo.StartPreview(host.Child.Handle); - await oo.StartPreview(x => this.image.Source = x); - this.m_MainUI.WebCams.Add(oo); + await camera.InitCaptureEngine(); + await camera.StartPreview(host.Child.Handle); } }