Class FaceApiServiceImpl
java.lang.Object
com.markvarga21.studentmanager.service.faceapi.impl.FaceApiServiceImpl
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final int
A simple multiplier for converting floating point percentage to decimal percentage, out of readability reasons. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
deleteFace
(String passportNumber) Deletes the facial validation data for the given passport number.getFaceIdForFile
(byte[] fileBytes) Returns the face ID for the given byte array.getFaceIdForFile
(org.springframework.web.multipart.MultipartFile file) Returns the face ID for the given file.Returns the list type for the face detection response.getValidityOfFaces
(byte[] passport, byte[] selfiePhoto) Compares the faces found on the passport and the selfie, and then sends it back to the client.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.boolean
validateFacesForPassportNumber
(String passportNumber, Long studentId) Validates the faces for the given passport number.
-
Field Details
-
PERCENT_MULTIPLIER
public static final int PERCENT_MULTIPLIERA simple multiplier for converting floating point percentage to decimal percentage, out of readability reasons.- See Also:
-
-
Constructor Details
-
FaceApiServiceImpl
public FaceApiServiceImpl()
-
-
Method Details
-
getFaceIdForFile
Returns the face ID for the given file.- Specified by:
getFaceIdForFile
in interfaceFaceApiService
- Parameters:
file
- The file to be processed.- Returns:
- The face ID for the given file.
-
getListType
Returns the list type for the face detection response.- Returns:
- The list type for the face detection response.
-
getFaceIdForFile
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 interfaceFaceApiService
- Parameters:
passport
- The student's passport image.selfiePhoto
- The selfie image of the student.- Returns:
- The validity and the percentage of the matching.
-
getValidityOfFaces
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
Validates the faces for the given passport number.- Specified by:
validateFacesForPassportNumber
in interfaceFaceApiService
- Parameters:
passportNumber
- The passport number.studentId
- The id of the student.- Returns:
true
if the faces are valid,false
otherwise.
-
deleteFace
Deletes the facial validation data for the given passport number.- Specified by:
deleteFace
in interfaceFaceApiService
- Parameters:
passportNumber
- The passport number.
-