Android Question Camera2 - Sometimes Dark Pictures

artsoft

Active Member
Licensed User
Longtime User
Hi!

CamEx2 (and lib Camera2) is currently included in my app.

All is running ok, except two things:

I listed all capture sizes by this command

B4X:
Private cSizes As List = camEx.SupportedCaptureSizes

and I provide the user the list on GUI in order to select and choose a specific size from GUI.

So far so good...

But after taking the picture, I show the bitmap to the user (in a separate ImageView control) in order to be able to confirm if the picture (coming from CamEx2) is ok or not.

There are 2 problems currently:

1. Problem:

In the size list, I miss my biggest 4:3 - picture size 4000 x 3000 Pixels. With the older CamEx, this size was always listed and could be selected by the users. Also when I run the internal smartphone camera app, I can select this 4000 x 3000 pixels size. All other sizes are listed - but this size is missing. Thats not good and I am asking myself why!? So currently, my users cannot choose this sizes which should normally be provided by the device camera.

2. Problem:

If the user selects one of some other sizes (i. e. 3264 x 1840 or 1920 x 1920 (1:1) or some others in format 16:9), the the result is a very dark bitmap (nearly black). When I select the size 1920 x 1080 (the default size provided by CamEx2 after starting the previewing) then the brightness of the picture is perfect again. So, what could be the reason for this dark picture effect. The preview panel shows a good result with a good lighting.

I hope, somebody can help me very quickly.
Thx in advance.

Best regards
ARTsoft
 

artsoft

Active Member
Licensed User
Longtime User
CameraEx is based on the old Camera API which is deprecated by Google.

In other posts you have recommended that users should use the Camera2 lib instead 🤔

Thats the reason why I switched to Camera2.

See this: https://developer.android.com/reference/android/hardware/Camera.html

2021-03-22 12_54_45-Window.png


Therefore my question:

Why CamEx2 (or Camera2) is not able to list simply all available capture-sizes of a device, when cameraEx is able to do this - although this lib is deprecated.

So you guess, my device (Oppo Reno2Z - which is a very new and modern smartphone with Android 10) is not able to provide the correct list when using Camera2 API?

For me, it is not a good style to use a mix the two libs - only for having a correct list of picture sizes.

In the CamEx2 Lib I see this:

B4X:
'Opens the camera and returns the "TaskIndex" number. You need to keep it and use it in future calls.
'Returns 0 if failed to open the camera.
Public Sub OpenCamera (Front As Boolean) As ResumableSub
    TaskIndex = TaskIndex + 1
    If Camera.IsCameraOpen Then
        Stop
    End If
    mFront = Front
    id = Camera.FindCameraId(mFront)
    If id = "" Then
        Log("Camera not found.")
        id = Camera.CameraIDs(0)
    End If
    
    Try
        Camera.OpenCamera(id)
    Catch
        Log(LastException)
        Return 0
    End Try
    ...

Especially this line: id = Camera.CameraIDs(0)

What happened, if the device has 4 back cameras and 1 front camera?
Is the CameraIDs an array of all available cameras?

Regards
ARTsoft
 
Upvote 0

artsoft

Active Member
Licensed User
Longtime User
Additional Info:

The Camera2 support level of the Camera Oppo Reno 2Z is:

B4X:
Private Sub camPanel_Click
    log(camEx.getSupportedHardwareLevel)
End Sub

==> FULL

Best regards
ARTsoft
 
Upvote 0

artsoft

Active Member
Licensed User
Longtime User
Yes, I saw it already :confused:🤔

You redirect the command directly to Camera2 API.
Very strange, Erel.

Why Camera2-API should ignore the 4000 x 3000 pixel size when older Camera (1)-API doesn't.

Regards
ARTsoft
 
Upvote 0

artsoft

Active Member
Licensed User
Longtime User
But ok, I can live with this issue ... The users can select a size which is ok and available. I also provide a compression level and the users can select from 5% jpeg quality until best quality of 100%. The old camera1 API had provided such a feature. With Camera2 level is take the bitmap and write it in a compressing ways to storage - and after this I reload and show the compressed bitmap to the user in order to see the quality level. This runs perfectly.

BUT - More important is the fact, that some pictures - took by CamEx2 - are nearly black! Independend from compression level. So when I selected a "bad" camera size, the original bitmap provided from Camera is nearly black.

This makes me very sad while developing my app ... 😩

Regards
ARTsoft
 
Upvote 0

artsoft

Active Member
Licensed User
Longtime User
Additional info for Oppo Reno 2Z device and the missing 4000 x 3000 pixel capture mode:

I checked the properties of the device while using the keys for the CameraMap and I see now this:

2021-03-22 16_57_42-Window.png


There is exactly this 4000 x 3000 mode which is different from other modes!!!

See above in the figure please.

So, what is exactly a RAW SENSOR (32) mode ???????

Camera1 API lists this mode as a normal capture mode and Camera2 ignores it.... :-(

Regards
ARTsoft
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
It is what it says. The raw unprocessed data from the sensor array. Generally known as RAW format it is common on actual cameras but unusual on phones. It relies on special software in higher end photo apps, like Photoshop, to do the Bayer colour extraction and other image calculations to get the final image.

Raw image format - Wikipedia
 
Upvote 0

artsoft

Active Member
Licensed User
Longtime User
Thanks for this information 👍👏

Curiously, the camera1 API allows or better: provides this format. Camera2 ignores it ... so I cannot make full pictures in full format.
 
Upvote 0

artsoft

Active Member
Licensed User
Longtime User
Try it on another phone.

Update regarding test on Samsung S6 Edge:

On this device the listed capture sizes are:

2021-03-22 19_37_16-Window.png


Within the internal device camera (Samsung camera app) I can choose between these sizes:

2021-03-22 19_41_04-Window.png


The output properties (logged by CamEx2) of Samsung S6 Edge are:

android.scaler.streamConfigurationMap: StreamConfiguration(
Outputs(
[w:5312, h:2988, format:RGBA_8888(1), min_duration:33331760, stall:0],
[w:3984, h:2988, format:RGBA_8888(1), min_duration:33331760, stall:0],

[w:3264, h:2448, format:RGBA_8888(1), min_duration:33331760, stall:0],
[w:3264, h:1836, format:RGBA_8888(1), min_duration:33331760, stall:0],

[w:2976, h:2976, format:RGBA_8888(1), min_duration:33331760, stall:0],
[w:2048, h:1152, format:RGBA_8888(1), min_duration:33331760, stall:0],

[w:1920, h:1080, format:RGBA_8888(1), min_duration:33331760, stall:0],
[w:1280, h:720, format:RGBA_8888(1), min_duration:33331760, stall:0],
[w:960, h:720, format:RGBA_8888(1), min_duration:33331760, stall:0],
[w:640, h:480, format:RGBA_8888(1), min_duration:33331760, stall:0],
[w:320, h:240, format:RGBA_8888(1), min_duration:33331760, stall:0],

[w:256, h:144, format:RGBA_8888(1), min_duration:33331760, stall:0],
-----------------------------------------------------------------------------------------------------------

[w:5328, h:3000, format:RAW_SENSOR(32), min_duration:33331760, stall:0],
[w:3264, h:2448, format:JPEG(256), min_duration:50000000, stall:0],

[w:3264, h:1836, format:JPEG(256), min_duration:50000000, stall:0],
[w:2048, h:1152, format:JPEG(256), min_duration:50000000, stall:0],
[w:1920, h:1080, format:JPEG(256), min_duration:33331760, stall:0],
[w:1280, h:720, format:JPEG(256), min_duration:33331760, stall:0],
[w:960, h:720, format:JPEG(256), min_duration:33331760, stall:0],
[w:640, h:480, format:JPEG(256), min_duration:33331760, stall:0],
[w:320, h:240, format:JPEG(256), min_duration:33331760, stall:0],

[w:256, h:144, format:JPEG(256), min_duration:33331760, stall:0],

The RED entries above are currently missing in the Camer2 capture sizes list.

==> It seems that Camera2 API only provides the BLUE entries above with JPEG(256) format !!!!

Very, very strange !!!!!!

This means that all (or better: many) Camera2 (CamEx2) apps are not able to take pictures in the biggest resolution. Or I am wrong?

Regards
ARTsoft
 
Upvote 0
Top