title: Picamera - Optimized way to do motion detection
body: <p>The <a href="https://picamera.readthedocs.org" rel="nofollow">Picamera documentation</a> provides examples on how one would go about implementing motion detection, without the actual motion detection algorithm itself.</p>
  
  <p>Although I am sure there are many more, I have thought about three ways of doing the motion detection algorithm:</p>
  
  <ol>
  <li><a href="http://picamera.readthedocs.org/en/release-1.10/recipes2.html#splitting-to-from-a-circular-stream" rel="nofollow">This example</a> suggests that we compare two PIL images.</li>
  <li>With the same example as above, could we simply use the frames for the comparison? </li>
  <li><a href="http://picamera.readthedocs.org/en/release-1.10/api_array.html#picamera.array.PiMotionAnalysis" rel="nofollow">This other example</a> suggests that we use a built-in feature of <a href="https://picamera.readthedocs.org" rel="nofollow">Picamera</a> called <code>motion_output</code> and <a href="http://www.numpy.org" rel="nofollow">NumPy</a> arrays.</li>
  </ol>
  
  <p>As you can see, the example of #1 and #2 is part of a section in the documentation that provides common recipes. The example of #3 is part of the actual API documentation.</p>
  
  <p>If they don't even use their built-in <code>motion_ouput</code> feature in the recipe section for their motion detection algorithm, and use PIL images instead, it must mean that their <a href="http://picamera.readthedocs.org/en/release-1.10/api_array.html#picamera.array.PiMotionAnalysis" rel="nofollow">PiMotionAnalysis</a> class (used with <code>motion_ouput</code>) isn't really optimized? </p>
  
  <p>What is the best way to do a motion detection algorithm? And as a bonus, you can also include a motion detection algorithm if you want :).</p>
  
  <p>Cheers!</p>