At this point I have a function which calls for an image from my camera interface. This image is then saved to hard drive and also displayed in the Windows Forms GUI.
The function inside the camera interface which returns the image is as follows: height and width are both integers that are part of the camera interface class. In this case they were set to 800x600.
public Image<Bgr,byte> QueryFrame()
{
Image<Bgr, byte> temp;
lock (key)
{
using (Capture cap = new Capture())
{
cap.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT, height);
cap.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH, width);
temp = cap.QueryFrame().Copy();
}
}
return temp;
}
Calling the function a number of times revealed first that capturing a frame took a comparatively long time, locking the program out of use for a few seconds. Then, after capturing a few frames while running the program in Debug with Visual C# 2010, a windows error popped up for vshost.exe:
Faulting application DashboardGUI.vshost.exe, version 10.0.30319.1, time stamp 0x4ba2084b, faulting module MSVCR90.dll, version 9.0.30729.6161, time stamp 0x4dace5b9, exception code 0xc0000005, fault offset 0x00024682, process id 0xe78, application start time 0x01cc792086025f01.
I then proceeded to publish the application and run it from the executable and got the error:
Application: DashboardGUI.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.TypeInitializationException
Stack:
at Emgu.CV.CvInvoke.cvReleaseCapture(IntPtr ByRef)
at Emgu.CV.Capture.DisposeObject()
at Emgu.Util.DisposableObject.Finalize()
However I have also had it throw the same exception with Emgu.CV.CvInvoke.cvCreateCameraCapture(Int32).
What is causing these problems? How can they be avoided? And is there any way to make capturing a frame faster than it currently does (when it doesn't crash)?