title: OCR: Difference between two frames
body: <p>I am trying to find an easy solution to implement the <strong>OCR algorithm from OPenCV</strong>. I am very new to Image Processing !
  I am playing a video that is decoded with specific codec using <strong>RLE algorithm</strong>.</p>
  
  <p><em>What I would like to do is that for each decoded frame, I would like to compare it with the previous one and store the pixels that have changed between the two frames.</em></p>
  
  <p>Most of the existing solutions gives a difference between the two frames but I would like to just keep the new pixels that have changed and store it in a table and then be able to analyze every group of pixels that have changed instead of analyzing the whole image each time.</p>
  
  <p>I planned to use the "<strong>blobs detection</strong>" algoritm mais I'm stuck before being able to implement it.</p>
  
  <p>Today, I'm trying this:</p>
  
  <pre><code>char *prevFrame;
  char *curFrame;
  QVector DiffPixel&lt;LONG&gt;;
  
  //for each frame
  DiffPixel.push_back(curFrame-prevFrame);
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Ys3i8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ys3i8.png" alt="enter image description here"></a></p>
  
  <p>I really want to have the "Only changed pixel result" solution. Could anyone give me some tips or correct me if I'm going to a wrong way ? </p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>New question, <strong>what if there are multiple areas of changed pixels</strong> ? Will it be possible to have one table per blocs of changed pixels or will it be only one unique table ? Take the example below: </p>
  
  <p><a href="https://i.stack.imgur.com/JzWd4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JzWd4.png" alt="Multiple Areas Pixels"></a></p>
  
  <p>The best thing as a result would be to have 2 mat matrices. The first matrix with the first orange square and the second matrix with the second orange square. This way, it avoids having to "scan" almost the entire frame if we store the result in one matrix only with a resolution being almost the same as the full frame.</p>
  
  <p>The main goal here is to minimize the area (aka the resolution) to analyze to find text. </p>