我使用的是Windows 7 x64,EmguCV 2.4.9。当我在笔记本电脑中运行代码时,它会在下面显示此问题。在我的桌面中,代码运行良好。谁能告诉我这是什么问题:
下面给出了守则:
public MainWindow()
{
InitializeComponent();
}
void timer_Tick(object sender, EventArgs e)
{
Image<Bgr, Byte> currentFrame = capture.QueryFrame();
if (currentFrame != null)
{
Image<Gray, Byte> grayFrame = currentFrame.Convert<Gray, Byte>();
**var detectedFaces = grayFrame.DetectHaarCascade(haarCascade)[0]; ///Problem arises in this line::: SEHException was unhandeled**
foreach (var face in detectedFaces)
currentFrame.Draw(face.rect, new Bgr(0, double.MaxValue, 0), 3);
image1.Source = ToBitmapSource(currentFrame);
}
}
[DllImport("gdi32")]
private static extern int DeleteObject(IntPtr o);
public static BitmapSource ToBitmapSource(IImage image)
{
using (System.Drawing.Bitmap source = image.Bitmap)
{
IntPtr ptr = source.GetHbitmap(); //obtain the Hbitmap
BitmapSource bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
ptr,
IntPtr.Zero,
Int32Rect.Empty,
System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
DeleteObject(ptr); //release the HBitmap
return bs;
}
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
capture = new Capture();
haarCascade = new HaarCascade(@"C:\Emgu\emgucv-windows-universal-gpu 2.4.9.1847\opencv\data\haarcascades\haarcascade_frontalface_default.xml");
timer = new DispatcherTimer();
timer.Tick += new EventHandler(timer_Tick);
timer.Interval = new TimeSpan(0, 0, 0);
timer.Start();
}
}
}
我已经在bin \ debug和system32中复制了opencv_xxx.dll。但仍然遇到问题。一些帮助将不胜感激。