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 をコピーしました。しかし、まだ問題が発生しています。いくつかの助けをいただければ幸いです。