FrontCamera picture to dark.

57 views
Skip to first unread message

cavalli...@bluewin.ch

unread,
May 14, 2021, 8:17:56 AMMay 14
to Android CameraX Discussion Group
Hi dear Devloppers

I have downnloaded the newest version "CameraX Basic".
-When i take a picture with the FrontCamera and the room light or the sun
  is in back of my head ( sun, light is shinig in the frontlens of the camera) my face was
  very dark and the top of the picture extremely bright.

- When the romlight or the sun is in front of my head the picture is ok.

 I have read a lot of articles but i can not solve the problem.

Tahnk you very much for your help.
Best regards, Mario

Patrick Liao

unread,
May 14, 2021, 10:59:55 AMMay 14
to Android CameraX Discussion Group, cavalli...@bluewin.ch
Hi Mario,

This is not a bug but a photography concept called "backlighting", where the main light is behind the subject.

In your situation, the back light (the sun) is SO MUCH stronger than the light casted on the subject (your face), and the AE algorithm would (most likely) try to make sure that the overall brightness of the picture is OK. I guess AE decided to prioritize the sunlight and make it not overexpose, which is almost impossible and would make your face appear very dark.

(In other words, you can reproduce the exact same "bug" with your DSLR with the same light setup)

The solution to this would be HDR, which enhances the dynamic range of the photo at the cost of time and possibly artifacts on your image.

Cheers,
Patrick Liao

Mario

unread,
May 14, 2021, 12:53:20 PMMay 14
to Android CameraX Discussion Group, lbypa...@gmail.com, Mario
Hi Patrick

Thank you very much for the answer.

I have understood. Is it easy to implent HDR ?  I am new in android.
I have tried out the sample HDR viewfinder but is very much of code and my Samsung  give: "No back-facing-sufficiently capable camera avaible!"

In the past i have find a solution that d'ont have this "bug" but is old and i think is based on "camera" (the codes are with: mCamera = camera, mHolder=getHolder,..........) How long is "camera" supported on the new phones?

Must i set all the codes of the "sample HDR", or is there a simple way to ad HDR?

Thanks in advance for the answer.
Best regards
Mario

Patrick Liao

unread,
May 15, 2021, 11:53:00 AMMay 15
to Android CameraX Discussion Group, cavalli...@bluewin.ch, Patrick Liao
Hi Mario,

Implementing HDR is...HARD (Google phones are known for having good HDR functionality in their stock camera app).

However, you can try to send a CaptureRequest to the CameraX to somehow enable the built-in HDR implemented by the phone manufacturer (if they have done so), otherwise you are on your own (for now, since CameraX doesn't really have a fallback HDR implementation...yet).

Alternatively, if you don't mind overexposing the background, always feel free to either set AE area to your face or use CameraControl.setExposureCompensationIndex(int) and set it to some positive number.

Good luck.

Cheers,
Patrick Liao

Mario

unread,
May 15, 2021, 3:01:33 PMMay 15
to Android CameraX Discussion Group, lbypa...@gmail.com, Mario
Hi Patrick

Thank you, I will try it.

Best regards
Mario

Scott Nien

unread,
May 16, 2021, 10:09:00 PMMay 16
to Mario, Android CameraX Discussion Group, lbypa...@gmail.com
Mario, 

If your device supports CameraX Vendor Extensions (check here for extension support devices),  you can also try it.  

CameraX Vendor Extensions allows applications to enable the HDR/Night / Portrait / Beauty effect that is available in native camera apps. 

See here for sample codes.   Please note that the Vendor Extensions APIs are subject to change.  




--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/8927406f-65d1-421f-bb31-d0c732117b47n%40android.com.

Mario

unread,
May 17, 2021, 9:59:46 AMMay 17
to Android CameraX Discussion Group, Scott Nien, Android CameraX Discussion Group, lbypa...@gmail.com, Mario
Hi Scott

Thank you.
I looked on the Vendor Extensions. But not all have this und for me is to hard to ad this codes.

In the past i have find a simple solution that d'ont have this "extrem backlighting" but is old and i think is based on "camera" (the codes are with: mCamera = camera, mHolder=getHolder,..........). 
How long is "camera" supported on the new phones?

Best regards
Mario

Scott Nien

unread,
May 19, 2021, 11:44:17 PMMay 19
to Mario, Android CameraX Discussion Group, lbypa...@gmail.com
I guess maybe CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES is causing the problem. 
The camera1 API might have different FPS setting than what CameraX/Camera2 set.  
The higher the fps is (meaning the shorter the frame duration it gets to be exposed), the darker the scene could be. 

Currently CameraX will tune the FPS on LEGACY level cameras but keep default FPS settings on other devices.   
You can try below code snippet to change the FPS using CameraX. 
// bind without use cases to get the camera instance without opening it. 
Camera camera = mCameraProvider.bindToLifecycle(this, mCurrentCameraSelector);
Camera2CameraInfo camera2CameraInfo = Camera2CameraInfo.from(camera.getCameraInfo());
Camera2CameraControl camera2CameraControl = Camera2CameraControl.from(camera.getCameraControl());
// get supported fps ranges list.
Range<Integer>[] fpsRangeList =
camera2CameraInfo.getCameraCharacteristic(CameraCharacteristics.CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES);
// Set the target FPS by some range which is in the supported fps ranges list.
camera2CameraControl.setCaptureRequestOptions(
new CaptureRequestOptions.Builder().setCaptureRequestOption(
CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, fpsRange/* select from fpsRangeList */).build());

// bind again with use cases to open camera
mCamera = mCameraProvider.bindToLifecycle(this, mCurrentCameraSelector, preview, imageAnalysis, imageCapture);

 
How long is "camera" supported on the new phones?
Sorry there is no guarantee for how long that camera1 API will be supported. 

Mario

unread,
May 22, 2021, 1:48:40 PMMay 22
to Android CameraX Discussion Group, Scott Nien, Android CameraX Discussion Group, lbypa...@gmail.com, Mario
Hi Scott
Thank you for the answer, I will try it.
Best regards
Mario
Reply all
Reply to author
Forward
0 new messages