Class FaceApiServiceImpl

java.lang.Object
com.markvarga21.studentmanager.service.faceapi.impl.FaceApiServiceImpl
All Implemented Interfaces:
FaceApiService

@Component @Generated public class FaceApiServiceImpl extends Object implements FaceApiService
A service which uses Azure's Face API to compare two faces. It is then used for comparing the face on the passport- and the students selfie image which has been uploaded.
  • Field Details

    • PERCENT_MULTIPLIER

      public static final int PERCENT_MULTIPLIER
      A simple multiplier for converting floating point percentage to decimal percentage, out of readability reasons.
      See Also:
  • Constructor Details

    • FaceApiServiceImpl

      public FaceApiServiceImpl()
  • Method Details

    • getFaceIdForFile

      public String getFaceIdForFile(org.springframework.web.multipart.MultipartFile file)
      Returns the face ID for the given file.
      Specified by:
      getFaceIdForFile in interface FaceApiService
      Parameters:
      file - The file to be processed.
      Returns:
      The face ID for the given file.
    • getListType

      public Type getListType()
      Returns the list type for the face detection response.
      Returns:
      The list type for the face detection response.
    • getFaceIdForFile

      public String getFaceIdForFile(byte[] fileBytes)
      Returns the face ID for the given byte array.
      Parameters:
      fileBytes - The file to be processed.
      Returns:
      The face ID for the given file.
    • getValidityOfFaces

      public FaceApiResponse getValidityOfFaces(org.springframework.web.multipart.MultipartFile passport, org.springframework.web.multipart.MultipartFile selfiePhoto)
      Compares the faces found on the passport and the selfie, and then sends it back to the client. It combines the predefined method(s).
      Specified by:
      getValidityOfFaces in interface FaceApiService
      Parameters:
      passport - The student's passport image.
      selfiePhoto - The selfie image of the student.
      Returns:
      The validity and the percentage of the matching.
    • getValidityOfFaces

      public FaceApiResponse getValidityOfFaces(byte[] passport, byte[] selfiePhoto)
      Compares the faces found on the passport and the selfie, and then sends it back to the client. It combines the predefined method(s).
      Parameters:
      passport - The student's passport image.
      selfiePhoto - The selfie image of the student.
      Returns:
      The validity and the percentage of the matching.
    • validateFacesForPassportNumber

      public boolean validateFacesForPassportNumber(String passportNumber, Long studentId)
      Validates the faces for the given passport number.
      Specified by:
      validateFacesForPassportNumber in interface FaceApiService
      Parameters:
      passportNumber - The passport number.
      studentId - The id of the student.
      Returns:
      true if the faces are valid, false otherwise.
    • deleteFace

      public void deleteFace(String passportNumber)
      Deletes the facial validation data for the given passport number.
      Specified by:
      deleteFace in interface FaceApiService
      Parameters:
      passportNumber - The passport number.