0
我有一个辅助类是这样的:Emgu.Cv WPF(C#)如何从图像框(image.source)加载图像
class helper
{
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
// System.Runtime.InteropServices.dll
public static extern bool DeleteObject(IntPtr handle);
public static BitmapSource bs;
public static IntPtr ip;
public static BitmapSource LoadBitmap(System.Drawing.Bitmap source)
{
ip = source.GetHbitmap();
bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(ip, IntPtr.Zero, System.Windows.Int32Rect.Empty,
System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
DeleteObject(ip);
return bs;
}
我想读的图像,当我点击这样的按钮:
private void Button_Click(object sender, RoutedEventArgs e)
{
//plaka resşm aytıştırma gelecek
imgPlate1.Source = img.Source;
// Mat image = CvInvoke.Imread(imgPlate1.Source,ImreadModes.Color);
Mat image = CvInvoke.Imread(helper.LoadBitmap((System.Drawing.Bitmap)imgPlate1.Source,ImreadModes.Color));
// ProcessImage(image);
// helper.SaveImageCapture((BitmapSource)imgCapture.Source);
}
processImage来是另一个函数后读取图像 我会用,但我不能我的形象。另一方面我没有问题,这条线:
imgPlate1.Source = img.Source;
我可以看到我的图像我的图像箱声名是imgPlate