0

Here is my camera setup:

param = camera.getParameters();              
param.setPictureFormat(ImageFormat.YV12); // Removing this line fixes the error
param.setPreviewSize(800, 480)   
param.setPictureSize(800, 480);
camera.setDisplayOrientation(90);
camera.setParameters(param);

Setting the ImageFormat causes setParameters failed error. So its clearly not the resolution thats the problem. I've also checked supported picture/preview resolutions on the device so there is definitely no problem there.

This Image Format is supposed to be compatible on all devices... whats the story?

Greg Peckory
  • 7,700
  • 21
  • 67
  • 114

1 Answers1

1

This Image Format is supposed to be compatible on all devices

Only for previews; you are trying to use it for pictures. Quoting the documentation:

For the older camera API, this format is guaranteed to be supported for Camera preview images since API level 12

The documentation for setPictureFormat() states that the three formats you can use are ImageFormat.NV21, ImageFormat.RGB_565, or ImageFormat.JPEG.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • I get the same error when I use `setPictureFormat(ImageFormat.NV21)`. There must be something else wrong. Also I need YUV so I can extract RGB values as shown here: http://stackoverflow.com/a/2164906/1449637 – Greg Peckory Jan 24 '16 at 13:10
  • @GregPeckory: I have only ever used `JPEG`, so I have no idea how popular `NV21` is. Besides, you should be checking it against `getSupportedPictureFormats()`, anyway. "Also I need YUV so I can extract RGB values" -- well, `RGB_565` would seem to have RGB values. The answer that you cite is working off of preview frames, not pictures. If you insist on YUV, you will need to work off of preview frames, not pictures. – CommonsWare Jan 24 '16 at 13:15
  • Cool, thanks for the help! So basically, if I stick to picture frames and use RGB_565 I should be fine? – Greg Peckory Jan 24 '16 at 13:23
  • @GregPeckory: Only for those devices that support `RGB_565`. That will be some, but not all. The values documented for `setPictureFormat()` are the *possible* values, not guarantees. That's what `getSupportedPictureFormats()` is for. – CommonsWare Jan 24 '16 at 13:36