title: Camera frames in a service / background process
body: <p>For scientific measurements, I would like to access the camera frames from a service. The idea is to analyze the images coming from the camera in real-time under some conditions. Since the phone might be restarted or simply locked, it should be possible to start the process from a service.</p>
  
  <p>For now, I was satisfied by using a <code>Camera.Callback</code> and the <code>onPreviewFrame</code> callback, but it appears that it only works if my application is running in foreground. More precisely, the camera requires a valid <code>SurfaceView</code> in order to call the <code>onPreviewFrame</code> function. And a <code>SurfaceView</code> created in an Activity is destroyed when the activity is minimized / finished.</p>
  
  <p>I just cannot find a way to get the frames from a background process. Actually, it works on a <code>Galaxy Note 10.1</code>, but the <code>Galaxy S4</code> requires a valid SurfaceView. </p>
  
  <p>Is there a way to achieve this?</p>
  
  <p>There are many topics about this on StackOverflow, but none worked for me.</p>