“System.AccessViolationException is unprocessing”错误,使用 emgu
本文关键字:错误 使用 emgu unprocessing System AccessViolationException is | 更新日期: 2023-09-27 18:36:18
我正在尝试在Visual Studio 2010中使用EMGU CV捕获视频,但是当它执行该行时
video.WriteFrame<Bgr, byte>(marked);
我收到以下错误:
System.AccessViolationException is unhandling
已尝试读取或写入受保护的内存。这通常表示其他内存已损坏。
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");
}
有谁知道可能导致这种情况的原因?
谢谢
埃文
重新排序以下行后,它对我完美地工作。 此外,检查标记为不为空。 如果标记为空,则引发访问冲突错误。
while (temp != null)
{
CvInvoke.cvShowImage("camera", temp.Ptr);
Image<Bgr, byte> marked = faceDetection(temp);
video.WriteFrame<Bgr, byte>(marked);
int c = CvInvoke.cvWaitKey(20);
if (c == 27) break;
temp = camera.QueryFrame();
}
很抱歉回答晚了,但也许有人会发现它有帮助。
我现在自己正在与此错误作斗争(在不同情况下),看起来这是尝试在 32 位 Windows 上的项目中包含 64 位组件的问题。
在32 位系统上它运行良好,在 64 位系统上我有"System.AccessViolationException is unhandled"
可悲的是,在我的情况下无能为力,只是放弃组件并以其他方式做
也许这里也是一个问题。什么是VideoWriter,看起来不像标准的.NET类?