Visual Studio 2010 で EMGU CV を使用してビデオをキャプチャしようとしていますが、行を実行すると
video.WriteFrame<Bgr, byte>(marked);
次のエラーが表示されます。
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");
}
誰がこれを引き起こしているのか知っていますか?
ありがとう
エヴァン