tensor
tensor

Reputation: 783

Firebase ML Kit giving different Face tracking ID even for same faces in Flutter app

I am passing images of the same person first by taking a selfie and the other pic is an existing profile pic of the user which I am converting to File data type because there is no way to directly detect faces from URL in flutter. Even when both faces are the same I am getting different face IDs, as 0 and 1 in print statements. What is the solution to overcome this?

Future verifyYourProfile(File image) async {

    final faceDetector = FirebaseVision.instance.faceDetector(
      FaceDetectorOptions(
          enableTracking: true, mode: FaceDetectorMode.accurate),
    );

    // Assign face ID to selfie from incoming File image called from App.
    final selfieVisionImage = FirebaseVisionImage.fromFile(image);
    final selfieFace = await faceDetector.processImage(selfieVisionImage);
    final int selfieId = selfieFace[0].trackingId;
    print(selfieId);

    // Assign face ID to profile Picture.

    // Convert URL Image to File data type
    final response = await get(_imageUrl);
    final documentDirectory = await getApplicationDocumentsDirectory();
    File file = new File(join(documentDirectory.path, 'verifyImage.png'));
    file.writeAsBytesSync(response.bodyBytes);

    print('Detecting second face');
    // Detect the face.
    final faceDetector2 = FirebaseVision.instance.faceDetector(
      FaceDetectorOptions(
          enableTracking: true, mode: FaceDetectorMode.accurate),
    );
    final profilePicVisionImage = FirebaseVisionImage.fromFile(file);
    final profilePicFace =
        await faceDetector2.processImage(profilePicVisionImage);
    final int profilePicId = profilePicFace[0].trackingId;
    print(profilePicId);
  }

Upvotes: 1

Views: 867

Answers (1)

Shiyu
Shiyu

Reputation: 935

Thanks for your question!

The face detection is not designed for face recognition, and it won't tell you whether these two faces belong to the same person or not. The face tracking ID can be used in streaming mode, where it helps to track the same face in the consecutive frames.

Upvotes: 1

Related Questions