problem retrieving data from OBS virtual camera in C# WPF app (AForge)

kcapxis

New Member
Hello, i have a c# app where a get all the webcam from my pc, i can see my built in camera and OBS virtual using Aforge but when i try to put the output of OBS cam
nothing display
After some debug i found that the OBS virtual cam never call the new frame methode.
Does anyone now how to retrive the images of OBS cam ?

PS: it work with the built in camera

c# code:
public Flux()
{
InitializeComponent();
double primaryW = System.Windows.SystemParameters.PrimaryScreenWidth;
double virtualW = System.Windows.SystemParameters.VirtualScreenWidth;

this.Left = primaryW + (virtualW - primaryW) / 2 - this.ActualWidth / 2;
var path = System.IO.Directory.GetCurrentDirectory();
//ImageAttente.Source = new BitmapImage(new Uri(path + "..\\..\\..\\" + "mouette_algo.jpg"))



FilterInfoCollection filterInfoCollection = new FilterInfoCollection(FilterCategory.VideoInputDevice);
foreach (FilterInfo Device in filterInfoCollection) Console.WriteLine($"Device [{Device.Name}]");
var FilterInfo = filterInfoCollection[1]; // OBS Virtual Camera
camname.Content = FilterInfo.Name.ToString();
captureDevice = new VideoCaptureDevice(FilterInfo.MonikerString);
captureDevice.NewFrame += VideoCaptureDevice_NewFrame;
captureDevice.Start();

}
BitmapImage BitmapToImageSource(Bitmap bitmap)
{
using (MemoryStream memory = new MemoryStream())
{
bitmap.Save(memory, System.Drawing.Imaging.ImageFormat.Bmp);
memory.Position = 0;
BitmapImage bitmapimage = new BitmapImage();
bitmapimage.BeginInit();
bitmapimage.StreamSource = memory;
bitmapimage.CacheOption = BitmapCacheOption.OnLoad;
bitmapimage.EndInit();

return bitmapimage;
}
}

private void VideoCaptureDevice_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
Bitmap frame = (Bitmap)eventArgs.Frame.Clone();

Dispatcher.BeginInvoke(new Action(() =>
{
VC.Source = BitmapToImageSource(frame);
}));
}

VC is my image in xaml file.

VideoCaptureDevice_NewFrame is never call when i var FilterInfo = filterInfoCollection[1]; // OBS Virtual Camera

if i do var FilterInfo = filterInfoCollection[0]; //built in

everything work find
 
Top