Jump to content
TurboMagic

Reading and changing capabilities of Android Camera2 API

Recommended Posts

Hello,

 

I'm currently playing with Kastri's Camera demo, which is based on the Android Camera2 API.

Now I'm struggeling with getting capabilities of the camera used and later on I even need to change some settings.

After finding out how the basic structure of this demo works I added this method to get some capabilities as string to
get started:

 

function TPlatformCamera.GetCapabilities: string;
var
  LCharacteristics : JCameraCharacteristics;
  Orientation      : Integer;
  Obj              : JObject;
  IntArray         : TJavaObjectArray<integer>;
  i                : Integer;
begin
  LCharacteristics := FCameraManager.getCameraCharacteristics(FSelectedCamera);
  Obj := LCharacteristics.get(TJCameraCharacteristics.JavaClass.LENS_FACING);
  Orientation := TJInteger.Wrap(Obj).intValue;

   if (Orientation = TJCameraMetadata.JavaClass.LENS_FACING_FRONT) then
     Result := 'Camera: front' + sLineBreak
   else
     Result := 'Camera: back' + sLineBreak;

  Obj := LCharacteristics.get(TJCameraCharacteristics.JavaClass.CONTROL_AE_AVAILABLE_ANTIBANDING_MODES);
end;

FSelectedCamera is a JString and assigned where the component goes through the list of available cameras and selects the desired one.

Reading which camera is selected already seems to work, since this just returns a simple integer value.

 

But how to deal with CONTROL_AE_AVAILABLE_ANTIBANDING_MODES, which, according to the API docs API docs returns int[], which
is some kind of array? How to access this from Delphi?

 

And even more: CONTROL_AE_COMPENSATION_RANGE, which returns an array (with two elements) of Range<Integer>?
And CONTROL_AE_COMPENSATION_STEP which returns a Rational? I haven't found the definition of this Rational type in
Androidapi.JNI.JavaTypes or Androidapi.JNIBridge.

Share this post


Link to post

Meanwhile I learned that there's no support in the Java bridge yet to get access to these data types, which means one must implement some things on "the Java side".

Edited by TurboMagic

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×