Reputation: 117
I'm trying to convert Mat to bitmap to open my webcam but with no success. However, I've seen a question with the same context compared to this question but without any answer from the other users : question ,
This is the code used :
private void OpenWebcam_Click(object sender, RoutedEventArgs e)
{
var capture = new Emgu.CV.VideoCapture();
using (var nextFrame = capture.QueryFrame())
{
if (nextFrame != null)
{
image.Source = nextFrame.ToBitmap(); // error here because there is no ToBitmap method
}
}
}
Note that the code I've found in this question How to get video stream from webcam in emgu cv? seems to have worked, but I'm using a new version so the method was deleted.
Upvotes: 2
Views: 6591
Reputation: 18812
If using WPF, you can install Emgu.CV.Wpf
then connect the output to a System.Windows.Controls.Image
object.
// Convert the Mat to a BitmapSource for display in WPF
image.Source = nextFrame.ToBitmapSource();
Upvotes: 0
Reputation: 380
Simply install Emgu.CV.Bitmap nuget package and use it like following:
myimage.ToBitmap()
Upvotes: 5
Reputation: 117
I've solved this problem after installing : Emgu.UI.windows
and now , this code works for me:
var bitmap = Emgu.CV.BitmapExtension.ToBitmap(nextFrame);
Upvotes: 1