我收到了上面的消息,而我正试图在26帧以上运行我的算法。
我的程序是在C#中,我在java(Android)中使用OpenCV的经验我知道我需要发布矩阵,我还需要在这里做吗?
这是问题的一部分:
private void toolStripButton2_Click(object sender, EventArgs e)
{
for (int i = 0; i < FRAME_SIZE; i++)
{
ColorImage = _Capture.QueryFrame();
if (ColorImage != null)
{
GrayImage = ColorImage.Convert<Gray, float>();
toolStripProgressBar1.Value = i;
if (i == 0)
{
Max_G2 = new Image<Gray, float>(GrayImage.Width, GrayImage.Height);
mainimage = new Image<Bgr, byte>(GrayImage.Width, GrayImage.Height);
}
FindMax(GrayImage.Copy());
}
else
{
toolStripStatusLabel1.Text = "The video is too short!";
break;
}
}
}
private void FindMax(Image<Gray, float> CurrGray)
{
Image<Gray, float> TempImg = new Image<Gray, float>(CurrGray.Width, CurrGray.Height);
Matrix<float> kernel1 = new Matrix<float>(new float[1, 2] { { -1, 1 } });
Matrix<float> kernel2 = new Matrix<float>(new float[2, 1] { { -1 }, { 1 } });
Point anchor = new Point(0, 0);
CvInvoke.cvFilter2D(CurrGray, TempImg, kernel1, anchor);
CvInvoke.cvFilter2D(CurrGray, CurrGray, kernel2, anchor);
TempImg = TempImg.Pow(2);
CurrGray = CurrGray.Pow(2);
CurrGray = CurrGray.Add(TempImg);
CurrGray = CurrGray.Pow(0.5);
Max_G2._Max(CurrGray);
}
还有一件事,我已经尝试处理所有矩阵和图像,但它对我不起作用。 我在这里想念什么?
谢谢!
编辑1 :(处置代码)
private void toolStripButton2_Click(object sender, EventArgs e)
{
for (int i = 0; i < FRAME_SIZE; i++)
{
ColorImage = _Capture.QueryFrame();
if (ColorImage != null)
{
GrayImage = ColorImage.Convert<Gray, float>();
toolStripProgressBar1.Value = i;
if (i == 0)
{
Max_G2 = new Image<Gray, float>(GrayImage.Width, GrayImage.Height);
TempImg = new Image<Gray, float>(GrayImage.Width, GrayImage.Height);
mainimage = new Image<Bgr, byte>(GrayImage.Width, GrayImage.Height);
}
FindMax(GrayImage);
ColorImage.Dispose();
ColorImage = null;
GrayImage.Dispose();
GrayImage = null;
Thread.Sleep(100);
}
else
{
toolStripStatusLabel1.Text = "The video is too short!";
break;
}
}
}
private void FindMax(Image<Gray, float> CurrGray)
{
Matrix<float> kernel1 = new Matrix<float>(new float[1, 2] { { -1, 1 } });
Matrix<float> kernel2 = new Matrix<float>(new float[2, 1] { { -1 }, { 1 } });
Point anchor = new Point(0, 0);
CvInvoke.cvFilter2D(CurrGray, TempImg, kernel1, anchor);
CvInvoke.cvFilter2D(CurrGray, CurrGray, kernel2, anchor);
TempImg.Pow(2);
CurrGray.Pow(2);
CurrGray.Add(TempImg);
CurrGray.Pow(0.5);
Max_G2._Max(CurrGray);
CurrGray.Dispose();
CurrGray = null;
}