Note that there are some explanatory texts on larger screens.

plurals
  1. POEMGU -" Exception of type 'System.OutOfMemoryException' was thrown."
    text
    copied!<p>I've got the message above, while I'm trying to run my algorithm on more than 26 frames.</p> <p>My program is in C#, with my experience with OpenCV in java(Android) I know that I need to release the matrix, do I need to do it here also?</p> <p>this is the part with the problem:</p> <pre><code> private void toolStripButton2_Click(object sender, EventArgs e) { for (int i = 0; i &lt; FRAME_SIZE; i++) { ColorImage = _Capture.QueryFrame(); if (ColorImage != null) { GrayImage = ColorImage.Convert&lt;Gray, float&gt;(); toolStripProgressBar1.Value = i; if (i == 0) { Max_G2 = new Image&lt;Gray, float&gt;(GrayImage.Width, GrayImage.Height); mainimage = new Image&lt;Bgr, byte&gt;(GrayImage.Width, GrayImage.Height); } FindMax(GrayImage.Copy()); } else { toolStripStatusLabel1.Text = "The video is too short!"; break; } } } private void FindMax(Image&lt;Gray, float&gt; CurrGray) { Image&lt;Gray, float&gt; TempImg = new Image&lt;Gray, float&gt;(CurrGray.Width, CurrGray.Height); Matrix&lt;float&gt; kernel1 = new Matrix&lt;float&gt;(new float[1, 2] { { -1, 1 } }); Matrix&lt;float&gt; kernel2 = new Matrix&lt;float&gt;(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); } </code></pre> <p>1 more thing, I already tried to dispose all the matrix and images, but it doesn't work for me. What do I miss here? </p> <p>Thanks!</p> <p><strong>EDIT 1: ( Code with dispose)</strong></p> <pre><code>private void toolStripButton2_Click(object sender, EventArgs e) { for (int i = 0; i &lt; FRAME_SIZE; i++) { ColorImage = _Capture.QueryFrame(); if (ColorImage != null) { GrayImage = ColorImage.Convert&lt;Gray, float&gt;(); toolStripProgressBar1.Value = i; if (i == 0) { Max_G2 = new Image&lt;Gray, float&gt;(GrayImage.Width, GrayImage.Height); TempImg = new Image&lt;Gray, float&gt;(GrayImage.Width, GrayImage.Height); mainimage = new Image&lt;Bgr, byte&gt;(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&lt;Gray, float&gt; CurrGray) { Matrix&lt;float&gt; kernel1 = new Matrix&lt;float&gt;(new float[1, 2] { { -1, 1 } }); Matrix&lt;float&gt; kernel2 = new Matrix&lt;float&gt;(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; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload