BcmCalibrationFragment

The Calibration Fragment (BcmCalibrationFragment) is the Biocapture SDK's calibration Fragment and the main player in the calibration process. It internally manages a camera object and a calibration session.

The Calibration Fragment is configured using an instance of the BcmCameraConfig. When using the BcmCalibrationActivity, the configuration is automatically passed to the BcmCalibrationFragment.

Progress is reported to an object implementing the IBcmCalibrationDelegate interface. Please refer to the usage examples for a high-level overview of the Scan Fragment.

Caveats

Configure the SDK while no Calibration Fragment (BcmCalibrationFragment) is active to ensure that your configuration is applied to all calibration sessions.

Interface

Kotlin:

open class BcmCalibrationFragment(
    /**
     * Camera configuration interface; can be overwritten
     */
    cameraConfig: BcmCameraConfig = BcmCameraConfig(),

    /**
     * A delegate object for calibration events
     */
    calibrationDelegate: IBcmCalibrationDelegate? = null

) : CalibrationFragment(
    cameraConfig,
    calibrationDelegate
) {

    companion object {

        /**
         * Information about the required permissions.
         */
        fun getRequiredPermissions(): Array<String>? {
            return arrayOf(
                "android.permission.CAMERA",
                "android.permission.FLASHLIGHT")
        }

        /**
         * You get information about the devices pre-calibration.
         * The response will be null, if there is no pre-calibration available.
         */
        fun getDevicePreCalibrationData(): BcmDeviceCalibration? {
            return DeviceCalibrationDataMapper.getDevicePreCalibrationData()
        }

        fun getDevicePreCalibrationData(
            focusLensPosition: Float,
            cameraFrameResolution: BcmCameraConfig.CameraFrameResolution
        ): BcmDeviceCalibration? {
            return DeviceCalibrationDataMapper.getDevicePreCalibrationData(
                cameraFrameResolution,
                focusLensPosition)
        }

        fun getDevicePreCalibrationData(
            cameraFrameResolution: BcmCameraConfig.CameraFrameResolution
        ): BcmDeviceCalibration? {
            return DeviceCalibrationDataMapper.getDevicePreCalibrationData(
                cameraFrameResolution)
        }

    }
}

Java:

public class BcmCalibrationFragment extends CalibrationFragment {

    /**
     * Camera configuration interface; can be overwritten
     */
    public BcmCameraConfig cameraConfig = new BcmCameraConfig();

    /**
     * A delegate object for calibration events
     */
    public IBcmCalibrationDelegate calibrationDelegate = null;

}

Usage

Configuring the Calibration Fragment

The Calibration Fragment maintains the Biocapture SDK's calibration camera configuration using the BcmCameraConfig interface.

Assign a flowDelegate object to receive information about scan progress and the final result (IBcmCalibrationDelegate).

Kotlin:


class BcmCameraConfigOverride : BcmCameraConfig() {
    open fun frameResolution(): CameraFrameResolution? = ...
}

...

val calibrationFragment: CalibrationFragment = BcmCalibrationFragment(
    BcmGlobalConfigOverride(),
    this);

Java:

class BcmCameraConfigOverride extends BcmCameraConfig {
    @Nullable
    @Override
    public CameraFrameResolution frameResolution() {
        return ...;
    }
}

...

    BcmCalibrationFragment calibrationFragment=new BcmCalibrationFragment(
    new BcmCameraConfigOverride(),
    this);

The settings are applied for all future calibration sessions during your app's Calibration Activity lifetime.

Creating a Calibration Fragment Instance

Once configured, you are ready to calibration your phone by presenting BcmCalibrationFragment using the supportFragmentManager of the Activity:

Kotlin:

val calibrationFragment: BcmCalibrationFragment = BcmCalibrationFragment()
// configuration take place here; see next section

supportFragmentManager.beginTransaction().replace(
    R.id.content_frame,
    calibrationFragment)
    .addToBackStack("BcmCalibration")
    .commitAllowingStateLoss()

Java:

BcmCalibrationFragment calibrationFragment=new BcmCalibrationFragment();
// configuration take place here; see next section

    getSupportFragmentManager().beginTransaction().replace(
    R.id.content_frame,
    calibrationFragment)
    .addToBackStack("BcmCalibration")
    .commitAllowingStateLoss()

Calibration Session Management

The Calibration Fragment by default automatically manages calibration sessions, meaning it will start a calibration session when presented, stop it when hidden or dismissed, and restart a new calibration session after a calibration completes (unless dismissed by the Activity).

See Also

results matching ""

    No results matching ""