question

Rafael Wolf de Goes avatar image
Rafael Wolf de Goes asked acastaneda answered

How to use CameraX on Clover Station Duo and select the correct Camera Lens

As far as I could understand from the docs, Clover Station Duo has 2 cameras, and it's possible to use the cameras with an Intent which would open another app, selecting the appropriate camera based on the CAMERA_ID extra.

static int CAMERA_ID_MERCHANT_FACING = 1;
static int CAMERA_ID_CUSTOMER_FACING = 0;

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra("android.intent.extra.CAMERA_ID", CAMERA_ID_MERCHANT_FACING);
startActivity(cameraIntent);

However, we need to use the camera inside our app, and in order to do that, we are using a well known and well supported library developed by Google, called CameraX.

Is there any way that we can identify the CAMERA_ID_MERCHANT_FACING using CameraX? If yes, how can we achieve that? Could you please provide an example?

Also, are both CAMERA_ID_MERCHANT_FACING and CAMERA_ID_CUSTOMER_FACING considered as LENS_FACING_FRONT?

Thank you!

Clover StationMerchantClover Station 2018
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
acastaneda avatar image
acastaneda answered

Hi Rafael,

Yes, both CAMERA_ID_MERCHANT_FACING and CAMERA_ID_CUSTOMER_FACING are considered as LENS_FACING_FRONT because the screen that shows the picture taken by the lens is on the same side as the lens for each of them. A way to check for a front-facing camera is

int numCameras= Camera.getNumberOfCameras();
for(int i=0;i<numCameras;i++){
    Camera.CameraInfo info = new CameraInfo();
    Camera.getCameraInfo(i, info);
    if(CAMERA_FACING_FRONT == info.facing){
        return true;
    }
}
return false;

return i to get the number of the front-facing camera or 0 if not found.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community