简体   繁体   中英

How to get a camera preview's pixels in Android?

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.

  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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM