我正在使用 Emgucv 从视频文件中捕获帧这是我的代码
private void Frame(object sender, EventArgs arg)
{
try
{
timesbetweenframes++;
Image<Bgr, Byte> frame = FrameExtractor.QueryFrame();
if (timesbetweenframes == 10 || timesbetweenframes == 0)
{
if (frame != null)
{
Bgr min = new Bgr(65, 65, 65);
Bgr threshold = new Bgr(128, 128, 128);
Image<Bgr, Byte> Frame2 = frame;
//Noise Removal
frame._SmoothGaussian(5);
VideoBox.Image = Frame2;
Bgr drawColor = new Bgr(Color.Blue);
using (Image<Gray, byte> gray = frame.Convert<Gray, Byte>())
{
TextExtract.Recognize(gray);
Tesseract.Charactor[] charactors = TextExtract.GetCharactors();
foreach (Tesseract.Charactor c in charactors)
{
Frame2.Draw(c.Region, drawColor, 1);
}
}
cptrdImage.Image = frame;
String text = TextExtract.GetText();
//removal of noise in this section
Tags.Items.Add(text);
WriteData(text, fileName,frame);
fileName++;
}
else
{
MessageBox.Show("Done!");
FrameExtractor = null;
InProgress = false;
timer1.Elapsed -= Frame;
}
timesbetweenframes = 0;
}
}
帧函数被添加到定时器事件中,这会在每 500 毫秒后自动触发帧函数并每 10 帧提取一次。现在的问题是,在调用 queryframe() 函数后,程序崩溃并出现错误:“限制在0x7777f7a99 引用了 0x00000000 处的内存。一段时间后无法读取内存。
我是否以错误的方式使用它,或者有没有其他方法可以做到这一点而不会出现此错误。