Android Question Cameraex Class: front camera pictures are very dark

mitobobo

Member
Licensed User
Longtime User
Dear,

Pictures took with front camera through Cameraex class are very dark. However, if I use the default Android camera or any other app which takes picture, the pictures are fine. I think it's a problem of exposure, so I tried to add this in the Cameraex class:

B4X:
Public Sub SetExposureCompensation(Value1 As Int)
  r.target = parameters
  r.RunMethod4("setExposureCompensation", Array As Object(Value1), _
      Array As String("java.lang.int"))
End Sub

and I use this in my activity to set exposure:

B4X:
camEx.SetExposureCompensation(2)
(I know "2" is a supported value on my phone)

However, nothing changes: picture is still as dark as before

B4X:
camEx.SetParameter("setExposureCompensation", "2")
doesn't work as well.

Any idea how can I solve it?

Any help would be much much much appreciated! Thanks so much.
 

mitobobo

Member
Licensed User
Longtime User
I'll never stop saying how helpful this forum is! Thank you so much, Erel. I just had to start camera preview and then let the app wait for 2 seconds so that it can adjust while level, I suppose. If you take a photo immediately after the preview is started, the photo will be dark. So a timer is just the solution. Thank you again! Happy Easter.
 
Upvote 0

mitobobo

Member
Licensed User
Longtime User
Nothing hard. I didn't even need to set WHITE_BALANCE_AUTO = "auto" or SCENE_MODE_AUTO = "auto".
B4X:
camEx.Initialize(pnlContent, frontCamera, Me, "Camera1")

Sub Camera1_Ready (Success As Boolean)
Log("Camera1_Ready?" & Success)
    If Success Then
camEx.StartPreview
Timer1.Initialize("CameraTimer", 2000)
Timer1.Enabled = True

End Sub

Sub CameraTimer_Tick

camEx.TakePicture
Timer1.Enabled = False

End Sub

In my case, a 2 seconds timer is just enough for the camera to auto-balance.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…