2

I'm building a camera up designed to work exclusively on Pixel 3 XL. I'm using camera2 API and would like to take a picture using front facing camera with HDR and/or Night Mode enabled. This is a code snipped where I setup my capture request:

 final CaptureRequest.Builder captureBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
 captureBuilder.addTarget(mStillImageReader.getSurface());
 captureBuilder.set(CaptureRequest.CONTROL_SCENE_MODE, CameraMetadata.CONTROL_SCENE_MODE_HDR);
 captureBuilder.set(CaptureRequest.CONTROL_AWB_MODE, CameraMetadata.CONTROL_AWB_MODE_AUTO);
 captureBuilder.set(CaptureRequest.CONTROL_AE_MODE, CameraMetadata.CONTROL_AE_MODE_ON);
 captureBuilder.set(CaptureRequest.CONTROL_AF_MODE, CameraMetadata.CONTROL_AF_MODE_AUTO);
 captureBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_SCENE_MODE_NIGHT);
 captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, 0);

...
 mCaptureSession.capture(captureBuilder.build(), CaptureCallback, mBackgroundHandler);

I was hoping to get something close to what Android's native camera app is doing when it's set to shoot in Night Mode or HDR+. Does anybody know if I need to do more than just setting flags in capture request to get the desired behavior?

Levon Shirakyan
  • 188
  • 2
  • 11
  • I do believe that some features (especially Night Mode) are exclusive for Google camera app. They depend on custom algorithms, not features of physical camera component (like controling focus, white balance or ISO - `SCENE_MODE_NIGHT`). HDR mode may be supported by hardware - its a common algorithm implemented on lower abstraction layers for best performance. Note that hardware producers advertising their devices as HDR+ etc. so they are also implementing some boosted up HDR mode. Oftenly there is a problem with accessing custom-per-device features – snachmsm Feb 06 '20 at 07:45
  • what are you doing - `CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_SCENE_MODE_NIGHT);`? you can't use `CONTROL_SCENE_MODE_NIGHT` for `CONTROL_MODE`, omg! – user924 Dec 03 '20 at 16:07

2 Answers2

3

In Android the image processing algorithms can be implemented at HAL level as well as at application level. Android framework sits between HAL and application and provide an interface to interact with camera. When you call the set method:

captureBuilder.set(
    CaptureRequest.CONTROL_SCENE_MODE,
    CameraMetadata.CONTROL_SCENE_MODE_HDR);

You request the HAL to perform HDR before returning the image to application. Note that: HAL is implemented by OEMs (or the vendors) (can consider Pixel to be an OEM) and it's upto the implementer to implement different CONTROL_SCENE_MODES. You can and should query the available control modes using:

// Get the camera charecteristics for current camera
CameraCharacteristics cameraCharacteristics = getCameraCharecteristics(cameraFacing);

int[] modes = cameraCharacteristics.get(
                CameraCharacteristics.CONTROL_AVAILABLE_SCENE_MODES);

// Check if the modes array has the SCENE MODE you wish to apply
// ... by iterating through the list.

If you run this on Pixel 3 XL, you may not get HDR supported. Correct me if I am wrong.

If you do not wish to write your own algorithms for HDR and Night Mode, you'd have to rely on available scene modes, and for that best would be to query and validate. Alternatively you can request YUV or RAW image from camera 2 and run them through HDR or Night Mode algorithms at application level.

TL;DR; The Google Pixel's native camera is most likely doing more image processing on top of image returned by camera2 and hence it cannot be replicated by leveraging camera2 alone by setting any configurations.

Minhaz
  • 937
  • 1
  • 10
  • 25
0

HDR+ / HDR does not seem supported on Google's own Pixel phones, even with CameraX (and of course not with Camera2)

Myabe worth trying CameraX with a 3rd party extension, like this.

Problem is, CameraX is in a (very) alpha state as of now, and its fate is not clear either.

user2349195
  • 62
  • 1
  • 8
  • `even with CameraX (and of course not with Camera2)` - CameraX uses Camera2 API, it's just a wrapper of it – user924 Dec 03 '20 at 16:09