title: Video frame capture in Android
body: <p>I'm trying to implement an Android app that captures about 1 picture per second, performs some processing on each picture and sends the output to a file for storage. My first pass at this tries something like the following:</p>
  
  <pre><code>public class MainActivity extends Activity {
  
      ...
      Handler loopHandler = new Handler();
      Runnable loopRunnable = new Runnable() {
  
          @Override
          public void run() {
              Thread pictureThread = new Thread(pictureRunnable);
              pictureThread.start();
              loopHandler.postDelayed(this, 1000);
          }
      };
  
      Runnable pictureRunnable = new Runnable() {
          @Override
          public void run() {
              mCamera.takePicture(null, null, mPicture);
          }    
      };
  
      private PictureCallback mPicture = new PictureCallback() {
          @Override
          public void onPictureTaken(byte[] data, Camera camera) {
          ... My processing code ...
          }
      }
  </code></pre>
  
  <p>The app freezes after taking about 4 pictures in this way. So, I'm guessing this is probably too naive an approach but would appreciate a deeper understanding of why this can't work. </p>
  
  <p>Is there any way to do this without engaging with video directly or will I ultimately have to create something that pulls frames out of a video stream? </p>