title: How to fix the insufficient memory error (openCV)
body: <p>Please help how to handle this problem:</p>
  
  <blockquote>
    <p>OpenCV Error: Insufficient memory (Failed to allocate 921604 bytes) in
    unknown function, file
    ........\ocv\opencv\modules\core\src\alloc.cpp, line 52</p>
  </blockquote>
  
  <p>One of my method using <code>cv::clone</code> and <code>pointer</code></p>
  
  <p>The code is:</p>
  
  <p>There is a timer every 100ms;
  In the timer event, I call this method:</p>
  
  <pre><code>void DialogApplication::filterhijau(const Mat &amp;image, Mat &amp;result) {   
     cv::Mat resultfilter = image.clone();
  
     int nlhijau = image.rows;
  
     int nchijau = image.cols*image.channels();;
  
      for(int j=0; j&lt;nlhijau; j++) {
         uchar *data2=resultfilter.ptr&lt;uchar&gt; (j);  //alamat setiap line pada result
         for(int i=0; i&lt;nchijau; i++) {
            *data2++ = 0;       //element B
            *data2++ = 255;     //element G  
            *data2++ = 0;       //element R
         }
       //  free(data2);   //I add this line but the program hung up
     }
  
     cv::addWeighted(resultfilter,0.3,image,0.5,0,resultfilter);
     result=resultfilter;
  }
  </code></pre>