0

I want to know how to get an array of pixels from the preview webcam (which I will run in a service). I've heard that the preview has to be displayed on a surface, but there will be no surface if I use a service.

I am very new to Android development, sorry for any misconceptions.

Thanks.

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
Ewen W.
  • 199
  • 1
  • 8
  • [This Google Search](https://www.google.com/#q=get%20camera%20preview%20pixels%20android) yielded [Android: Retrieving the Camera preview as a Pixel Array](http://www.41post.com/3470/programming/android-retrieving-the-camera-preview-as-a-pixel-array) as the first search result. – Robert Harvey Jun 27 '14 at 22:24
  • is it an external WebCam (USB or WiFi or BT), or the internal camera *used as* a WebCam? – Alex Cohn Jun 28 '14 at 09:34

1 Answers1

0
  Parameters parameters = camera.getParameters();
       Display display = ((WindowManager)getSystemService(WINDOW_SERVICE)).getDefaultDisplay();

       if(display.getRotation() == Surface.ROTATION_0)
       {
           parameters.setPreviewSize(640, 480);                           
           camera.setDisplayOrientation(90);
       }
      camera.setParameters(parameters);


      camera.setPreviewDisplay(cameraSurfaceHolder);
      camera.startPreview();
      previewing = true;