-1

I'm developing an Android app to capture snapshots using camera2 and to draw graphs related to the picture taken in real-time.

Is it possible to retrieve the capture result as a SurfaceView (so to display it) and as RGB in order to calculate the points to draw the graph?

Mike Laren
  • 8,028
  • 17
  • 51
  • 70
ahakkal
  • 11
  • 1
  • 6
  • I think this is essentially the same as http://stackoverflow.com/questions/26293819/taking-a-screenshot-of-surfaceview-with-camera-preview-in-it , though you're capturing for analysis rather than storage. – fadden Jun 05 '15 at 21:04
  • sorry fadden, but i still dont know how to do it. – ahakkal Jun 08 '15 at 12:20
  • would it be possible that you clarify more please ? – ahakkal Jun 08 '15 at 12:36

1 Answers1

0

Camera hardware does not generally support RGB formats natively, only YUV.

You can either use:

  • An ImageReader as an additional output, with the ImageFormat#YUV_420_888 format, and convert to RGB yourself in Java or native code
  • Use a RenderScript YUV Allocation as an additional target and convert to RGB in RenderScript
  • Or you can use a SurfaceTexture output to the GPU, and then either read back the RGB data with glReadPixels, or do necessary processing/drawing for your graph in a GL shader directly.
Eddy Talvala
  • 17,243
  • 2
  • 42
  • 47
  • i will use renderscript for the conversion and also for the calculating stuff. the questionis is: is renderscript able to do the conversion and the calculating stuff all in a realtime. – ahakkal Jun 10 '15 at 08:44
  • i need to calculate the mean of the gray level on each column of pixels – ahakkal Jun 10 '15 at 08:45
  • If you need to calculate mean gray level, then use YUV! The Y luminance channel is pretty much exactly what you need, there's no need to convert to RGB for that. Then you have much less math you need to do. Whether there's enough CPU power on the device depends on the device and the resolution that you're trying to use, but removing the YUV->RGB conversion will certainly help. – Eddy Talvala Jun 10 '15 at 18:01
  • do i need the conversion for the display ? – ahakkal Jun 11 '15 at 07:36