Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
1. modify readme
  • Loading branch information
oven425 committed Apr 10, 2024
1 parent a4f1164 commit b454777
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 8 deletions.
2 changes: 2 additions & 0 deletions QSoft.MediaCapture/WebCam_MF.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 30 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,30 @@
# QSoft.MediaCapture
https://learn.microsoft.com/zh-tw/windows/win32/api/mfidl/nn-mfidl-imfcameraconfigurationmanager
# 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);
}

```
21 changes: 15 additions & 6 deletions WpfAppNET472/Window_NET472.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit b454777

Please sign in to comment.