4

I have a requirement to Capture the image without showing the Preview.. And i want to do it in the Background as a Service.

Is it possible to do that??

uday
  • 1,625
  • 3
  • 14
  • 16

1 Answers1

4

It is possible to achieve. You should define a class that handles the Camera object, as in calls on Camera.open() and such. Don't provide the camera object with the following lines in order to disable the preview -

mCamera.setPreviewDisplay(mTargetHolder);

Where mTargetHolder is the SurfaceView.

If you want to receive frame callbacks you can implement the Camera.PreviewCallback interface.

Now before you call on camera.startPreview() register you callback handler using setPreviewCallbackWithBuffer(Camera.PreviewCallback). Camera reference

With this frame data you receive from the callback you can do what ever you want. just remember that it is a raw data format. See also Camera.PictureCallback usage if you wish to take a picture.

I hope this helps. (even if not relevant)

Cheers

vbence
  • 20,084
  • 9
  • 69
  • 118
Ita
  • 1,282
  • 1
  • 15
  • 21
  • Are you sure that the picture will be taken without a call to `setPreviewDisplay`? Do you have any sample code? – vbence May 08 '11 at 17:41
  • removing this line, doesn't show the preview on the surface, but it still needs a surface, attached to the main window, to work.. so now instead of a preview, i can get a black surface :) do you maybe know of any way to work around this? – Vlad Jun 08 '12 at 15:14
  • To make it work on every device, surface must be added somewhere and actually created. See comments in http://stackoverflow.com/questions/2386025/android-camera-without-preview – Lucy Mar 20 '14 at 12:00