我試圖捕捉到Visual Studio 2010中使用EMGU CV視頻寫入視頻的時候,但「System.AccessViolationException了未處理」的錯誤時,執行線使用emgu CV
video.WriteFrame<Bgr, byte>(marked);
我得到的follwing錯誤:
System.AccessViolationException了未處理
試圖讀取或寫入保護內存。這通常表明其他內存已損壞。
private void button3_Click_1(object sender, EventArgs e)
{
Capture camera = new Capture();
if (camera == null)
{
MessageBox.Show("can't find a camera", "error");
}
double fps = camera.GetCaptureProperty(CAP_PROP.CV_CAP_PROP_FPS);
double cpHeight = camera.GetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT);
double cpWidth = camera.GetCaptureProperty(CAP_PROP.CV_CAP_PROP_FRAME_WIDTH);
double fourcc = camera.GetCaptureProperty(CAP_PROP.CV_CAP_PROP_FOURCC);
CvInvoke.cvNamedWindow("camera");
Image<Bgr, byte> temp = camera.QueryFrame();
//路徑
SaveFileDialog SaveFileDialog1 = new SaveFileDialog();
SaveFileDialog1.FileName = DateTime.Now.ToString("yyyyMMddhhmmss");
SaveFileDialog1.Filter = "Image Files(*.avi)|*.avi|All files (*.*)|*.*";
if (SaveFileDialog1.ShowDialog() == DialogResult.OK)
{
MessageBox.Show("START RECORD,ESC TO STOP");
}
VideoWriter video = new VideoWriter(SaveFileDialog1.FileName, (int)fourcc, 15, 800, 600, true);
while (temp != null)
{
CvInvoke.cvShowImage("camera", temp.Ptr);
temp = camera.QueryFrame();
int c = CvInvoke.cvWaitKey(20);
Image<Bgr, byte> marked = faceDetection(temp);
video.WriteFrame<Bgr, byte>(marked);
if (c == 27) break;
}
video.Dispose();
camera.Dispose();
CvInvoke.cvDestroyWindow("camera");
}
有沒有人知道可能是什麼原因造成的?
感謝
埃文