DOT Android Face 7.0.0

This guide describes how to migrate DOT Android Face version 6.x to version 7.0. Only the most important changes are highlighted in this guide. For more details, see the Android Samples.

Migration Steps (Kotlin)

Basic Setup

  • Replace DotFaceLibrary.initializeAsync() with DotSdk.initialize(). This operation should be called on background thread. DOT Android SDK Samples shows how to do it.
  • Replace DotFaceLibrary.deinitializeAsync() with DotSdk.deinitialize().
  • Replace DotFaceLibrary.isInitialized() with DotSdk.isInitialized().

Before

// Initialize DOT Face Library
fun initialize(context: Context, onFinished: (DotFaceLibrary.Result) -> Unit) {
  val license = readLicenseBytes(context.resources)
  val modules = createDotFaceLibraryModules()
  val configuration = DotFaceLibraryConfiguration.Builder(context, license, modules).build()
  DotFaceLibrary.initializeAsync(configuration, onFinished)
}

private fun createDotFaceLibraryModules() = listOf(
  DotFaceDetectionFastModule.of(),
  DotFaceVerificationModule.of(),
  DotFacePassiveLivenessModule.of(),
)

// Deinitialize
DotFaceLibrary.deinitializeAsync(onFinished)

// Check if the DOT Face Library is initialized
val isDotFaceLibraryInitialized = DotFaceLibrary.isInitialized()

After

// Initialize DOT SDK (including DOT Face Library)
fun initialize(context: Context) {
  val configuration = createDotSdkConfiguration(context)
  DotSdk.initialize(configuration)
}

private fun createDotSdkConfiguration(context: Context) = DotSdkConfiguration(
  context = context,
  licenseBytes = readLicenseBytes(context.resources),
  libraries = listOf(
    createDotFaceLibrary(),
  ),
)

private fun createDotFaceLibrary(): DotFaceLibrary {
  val modules = createDotFaceLibraryModules()
  val configuration = DotFaceLibraryConfiguration(modules)
  return DotFaceLibrary(configuration)
}

private fun createDotFaceLibraryModules() = listOf(
  DotFaceDetectionFastModule.of(),
  DotFaceVerificationModule.of(),
  DotFacePassiveLivenessModule.of(),
)

// Deinitialize
DotSdk.deinitialize()

// Check if the DOT SDK is initialized
val isDotSdkInitialized = DotSdk.isInitialized()