I\'m currently working on a project that use Facial Recognition. I therefore need a way to display the webcam images to the user so he can adjust his face.
I\'ve bee
I believe you have to use interop (source):
using System.Windows.Interop;
using System.Windows.Media.Imaging;
public static ImageSource AsImageSource(
this Image image) where TColor : IColor, new()
{
return Imaging.CreateBitmapSourceFromHBitmap(image.Bitmap.GetHbitmap(),
IntPtr.Zero, Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
}
Which could be used like this:
void timer_Elapsed(object sender, ElapsedEventArgs e)
{
using (Image frame = capture.QueryFrame())
{
if (frame != null)
{
var bmp = frame.AsImageSource();
}
}
}
If the interop doesn't perform well enough, take a look at the source of Image.ToBitmap
and Image.get_Bitmap
to see how you could implement your own WriteableBitmap
.