hutts_verification.verification package

Submodules

hutts_verification.verification.controllers module

Handles all requests relevant to the verification service of the API.

manage_text_extractor(image_of_id)[source]

This function manages the text extraction from an ID images. Management includes preparing text extraction preferences and receiving extracted text.

Parameters:(obj) (image_of_id) – An image of an ID that text must be extracted from.
Returns:
  • preferences (dict): Prepared list of preferences. May contain additional text extraction or logger preferences.
  • extracted_text (json object): A collection of text extracted from the ID.
manage_text_verification(preferences, extracted_text, entered_details)[source]

The function manages the preparation before text verification and result of the text verification it self Management includes preparing logger functionality and controlling match percentages and messages.

Parameters:
  • (list) (preferences) – A list of preferences containing details about logger functionality.
  • (JSON object) (extracted_text) – Contains text extracted from ID image.
  • (dict) (entered_details) – Dictionary containing information that needs to be verified.
Returns:
  • (float): Value representing the accuracy with which the entered details matches that of the extracted text.
  • (dict): Contains individual match percentages for different fields.
  • (boolean): Indicates if text_verification passes based on the threshold value.
match_faces(image_of_id, face)[source]

This function receives two images that receive images of faces that need to be verified. It is expected that an image of an ID and an image of a Profile picture will be received. Even if the expected images are not received the function will still apply a best effort solution.

Parameters:
  • (obj) (face) – An image of an ID that contains a face that needs to be verified.
  • (obj) – A image of a face that needs to be verified.
Returns:
  • boolean: Whether the two faces match (the distance between them is above the threshold value).
  • float: Return Euclidean distance between the vector representations of the two faces.
receive_details()[source]

This function receives the details that need to be verified from the flask handler.

Returns:
  • (dict): Details that need to be verified with that extracted from image.
receive_faces(match_face=True)[source]

This function receives faces/ID from request flask handler. The function checks for multiple means of receiving the faces/ID. These include

  • Receiving image by file path
  • Receiving image by URL
  • Receiving image by file Stream

It is expected that an image of a face and an image of an ID will be sent. However, if the order is not followed that system will still be able to return the best effort result without loss of accuracy.

Parameters:(boolean) (match_face) – Indicates if an additional profile of a face should be extracted. If an additional face should not be extracted simply return the ID image.
Returns:
  • (obj): An image of a ID.
  • (obj): An image of a face if match_face is set to True.
verify_faces()[source]

Sample function to return a match percentage of an ID face image and picture of face.

URL: http://localhost:5000/verifyFaces.

verify_id()[source]

Sample function to return a match percentage of an ID image and provided personal information and picture of face.

URL: http://localhost:5000/verifyID.

verify_info()[source]

Sample function to return a match percentage of an ID image and provided personal information.

hutts_verification.verification.face_verify module

A class that is used to extract and compare two images of faces and calculate the resulting match.

class FaceVerify(shape_predictor_path, face_recognition_path)[source]

Bases: object

The FaceVerify class is responsible for

  1. Detecting the face.
  2. Generating a threshold value that determines the likeness of two individuals in an image.
verify(face1, face2, threshold=0.55)[source]

This function determines a percentage value of how close the faces in the images passed are to each other if the determined value if below the threshold value passed by the user a boolean value of True is returned indicating that the faces in the images passed indeed match.

The verify function makes use of the dlib library which guarantees 99.38% accuracy on the standard Labeled Faces in the Wild benchmark.

Parameters:
  • (obj) (face2) – The first image containing the face that should be compared.
  • (obj) – The second image containing the face that should be compared.
  • (float) (threshold) – The threshold value determines at what distance the two images are considered the same. If a verify score is below the threshold value the faces are considered a match. The Labled Faces in the Wild benchmark recommend a default threshold of 0.6 but a threshold of 0.55 was decided on to ensure higher confidence in results.
Returns:
  • (boolean): Represents if two face indeed match.
  • (float): The Euclidean distance between the vector representations of the two faces.
Raises:
  • ValueError: If no face can be detected then no faces can be matched and the operation should be aborted.

hutts_verification.verification.text_verify module

Contains the logic used to verify the extracted text from a form of ID.

class TextVerify[source]

Bases: object

This class is responsible for the verification of text that is extracted from an ID.

validate_id_number(id_number, valid_length=13)[source]

Determines whether a given id number is valid or not.

Parameters:
  • (str) (id_number) – The ID number that has to be validated.
  • (int) (valid_length) – Specifies the length of a given id number to be considered as valid.
Returns:
  • (boolean): True if the id number is valid, False otherwise.
Raises:
TypeError: If id_number is not a string containing only numeric characters. TypeError: If valid_length is not an integer.
verify(extracted, verifier, threshold=75.0, min_matches=4, verbose=False)[source]

This function is responsible for the verification of text that is extracted from an ID and is passed in, along with information that is to be used to verify the extracted text.

Parameters:
  • (dict) (verifier) – The information that was extracted from an ID.
  • (dict) – The information against which the extracted data is to be verified.
  • (float) (threshold) – A percentage used to determine if the match percentage is accepted as verified.
  • (int) (min_matches) – The minimum number of matches needed to allow a positive match.
  • (boolean) (verbose) – Indicates whether or not to return all of the calculated match percentages.
Returns:
  • ((bool, float) | dict): The first value returned is a bool that indicates whether or not the total
    percentage match is above the specified threshold value, while the second return value is the total percentage match value if verbose is False, or returns a dict of all the determined percentage match values if verbose is True.
Raises:
TypeError: If any parameter is not of the correct type.

Module contents