Skip to main content

Usage

Setup

val camera = YesidFaceEnrollment
val configuration =
FaceEnrollmentConfigurationBuilder.setUserLicense(stringResource(id = "LicenseKey"))

//Inside a composable function just do the following
@Composable
fun MyComposable() {
camera.FaceEnrollmentCamera(
configuration,
onResult = { FaceResults ->
})
}

Using Fragments in Kotlin or Java

In your activity_main.xml file add the following:


<androidx.fragment.app.FragmentContainerView android:layout_width="match_parent"
android:layout_height="match_parent" android:id="@+id/main_container" />
//Create a FaceDetectionFragment and call the Face Camera
class FaceDetectionFragment : Fragment() {
@RequiresApi(Build.VERSION_CODES.O)
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
val view = ComposeView(requireContext())
view.apply {
setContent {
Column(
modifier = Modifier.fillMaxSize(),
) {
MyComposable()
}
}
}
return view
}

@Composable
fun MyComposable() {
val camera = YesidFaceEnrollment
val configuration =
FaceEnrollmentConfigurationBuilder.setUserLicense(stringResource(id = "LicenseKey"))

camera.FaceEnrollmentCamera(
configuration,
onResult = { FaceResults ->
})
}
}

On your activity then call the FaceDetectionFragment

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
supportFragmentManager.beginTransaction()
.replace(R.id.main_container, FaceDetectionFragment()).commit()
}
}