This class provides a high-level Dart interface for accessing native face recognition functionality through platform channels using the PerchEye Android SDK.
Run this in your Flutter project:
flutter pub add perch_eyestatic const MethodChannel _channel = MethodChannel('perch_eye_method_channel');Internal method channel used for native communication (do not modify).
Initializes the underlying PerchEye native SDK. Must be called once before any recognition-related operations.
await PerchEye.init();Releases SDK resources and unloads the model. Call this when the app or session ends.
await PerchEye.destroy();Opens a new session for face processing.
This is required before addImage().
await PerchEye.openTransaction();Adds a face image to the current transaction for processing. Accepts a base64-encoded image string.
Returns:
- A string representing the result enum (
SUCCESS,FACE_NOT_FOUND, etc.)
final result = await PerchEye.addImage(base64Image);
if (result == 'SUCCESS') {
// Proceed with enroll or verify
}Generates a Base64-encoded face embedding hash from the previously added image.
Returns:
- A
Stringface hash
await PerchEye.openTransaction();
await PerchEye.addImage(base64Image);
final hash = await PerchEye.enroll();Verifies the last added image against a given face hash.
Returns:
- Similarity score (
0.0to1.0)
await PerchEye.openTransaction();
await PerchEye.addImage(base64Image);
final similarity = await PerchEye.verify(hash);Evaluates multiple images to produce a single aggregated face hash.
Returns:
- Combined hash as
String
final hash = await PerchEye.evaluate([base64Image1, base64Image2]);Compares a list of base64-encoded images against a face hash.
Returns:
- Similarity score (
0.0to1.0)
final sim = await PerchEye.compareList(
[base64Image1, base64Image2],
knownHash,
);Convenience method: Internally performs:
openTransaction()addImage(image1)→enroll()→openTransaction()→addImage(image2)→verify()
Returns:
- Similarity score (
0.0to1.0)
final similarity = await PerchEye.compareFaces(base64Image1, base64Image2);await PerchEye.init();
await PerchEye.openTransaction();
await PerchEye.addImage(base64Image1);
final hash = await PerchEye.enroll();
await PerchEye.openTransaction();
await PerchEye.addImage(base64Image2);
final similarity = await PerchEye.verify(hash);
await PerchEye.destroy();