title: Motion detection using OpenCV
body: <p>I see queries related to opencv motion detection, but my requirement is much simpler , so i am asking the question again  .
  I would like to analyse video frames and see if something has changed in the frame. Any kind of motion occurring in the frame has be recognized. I just want to get notified if something happens. I don't need to track/ draw contours.</p>
  
  <p><strong>Attempts made</strong> :<br></p>
  
  <p>1) Template matching using OpenCV ( TM_CCORR_NORMED ).</p>
  
  <p>I get the similarity index using cvMinMaxLoc &amp;</p>
  
  <pre><code>if( sim_index &gt; threshold ) 
      "Nothing chnged"
     else
      "Changed
  </code></pre>
  
  <p><br/>
      <strong>Problem faced</strong> :</p>
  
  <p>I couldn't find a way  to decide on how to set thresholds. The values of false match and perfect were very close.</p>
  
  <p>2)  Method 2<br>
      a) Make running average<br>
      b) Take abs difference between current frame and moving average.<br>
      c) Threshold it and made it binary<br>
      d) Count the number of non zero values<br>
      Again am stuck with how to threshold it, because i am getting a large number of non zero values even for very similar frames.</p>
  
  <p>Please advice me on what approach i should take. Am i going in the right direction with the above two methods, or is there a simple method which can work in all most generic scenarios.</p>