/
Steps to fix packets with inverted biometric images

Steps to fix packets with inverted biometric images

The following article describes how to correct the biometric image of a resident that was flipped during the registration process.

 Instructions

Step I: Removing affected  Biometric Records from ABIS

  1. Identify affected RIDs

  2. Retrieve the biometric reference ID for each of the affected RIDs

Database: mosip_regprc
Table: reg_bio_ref
Query: select bio_ref_id from reg_bio_ref where reg_id in ('', '', '');

  1. Delete the record from abis using the biometric reference ID.

curl --location '{{url}}/T5CloudService/1.0/processRequest' \
--header 'Content-Type: application/json' \
--header 'Cookie: Authorization={{token}}' \
--data '{
    "tid": "{{Bio_Ref_ID}}",
    "encounter_id": "{{Bio_Ref_ID}}",
    "response": true,
    "request_type": "Delete"
}'

Step II: Updating Biometrics

  1. Read the biometrics from the packet manager by RID

curl --location '{{url}}/commons/v1/packetmanager/biometrics' \
--header 'Content-Type: application/json' \
--header 'Cookie: Authorization={{token}}' \
--data '{
    "id": "string",
    "metadata": {},
    "request": {
        "bypassCache": true,
        "id": "10002120120000520240510040114",
        "person": "individualBiometrics",
        "process": "NEW",
        "source": "REGISTRATION_CLIENT"
    },
    "requesttime": "2024-05-10T17:49:49.753Z",
    "version": "string"
}'

  1. Get UIN from IDRepo using the RID

curl --location --request GET '{{url}}/idrepository/v1/identity/idvid/10002120120000520240510040114?idType=rid' \
--header 'Content-Type: application/json' \
--header 'Cookie: Authorization={{token}}' \
--data '{
    "id":"string",
    "metadata": {},
    "request": {
        "appId": "regproc",
        "clientId": "mosip-regproc-client",
        "secretKey": "{{procSecretKey}}"
    },
    "version": "string"
}'

  1. Write a program that can create an update packet similar to the one found in registration-client or resident services. This program will need:

    1. Integrate biometric image flipper. Refer:  How to use the image flipper.

    2. Include packet-manager v1.1.5.5-P1 to construct the packet.

Refer to the resident services codebase on how to create the packet.

  1. Sync and upload the packets to the server.

  2. This packet now needs to be tagged to skip the “BIOMETRIC_AUTHENTICATION” stage due to the modification of the biometric images. To do this, a new tag will be introduced after the packet has reached the server.

    1. After the packet has been uploaded, the packet needs to be paused long enough to execute the “addTag” API before it reaches biometric authentication. A good way to do this would be to disable packet routing from securezone notifications.

To pause the packets at secure zone notification:

  1. Update the following property in  registration-processor-mz.properties as follows:

securezone.routing.enabled=false

  1. Restart the securezonenotification stage and config server

  2. To set the number of records fetched by the preprocessor, modify the following property.

registration.processor.reprocess.fetchsize=500

  1. Execute the following query to add the new tag before the packet reaches the Biometric Authentication stage using the packetmanager API.

curl --location '{{url}}/commons/v1/packetmanager/addTag' \
--header 'Content-Type: application/json' \
--header 'Cookie: Authorization={{token}}' \
--data '{
  "id": "string",
  "version": "string",
  "requesttime": "2024-05-09T10:01:03.318Z",
  "metadata": {},
  "request": {
    "id": "10006100000000520240509095659",
    "tags": {
     "MOSIP_IMAGE_FLAP": "true"
    }
  }
}'

  1. Modify the camel route of the registration process for the UPDATE flow (registration-processor-camel-routes-update.xml) in mosip-config repository to skip the authentication if the tag MOSIP_IMAGE_FLAP is present and it is set to true.

<when>
            <jsonpath suppressExceptions="true">$.[?(@['tags']['MOSIP_IMAGE_FLAP'] == true)]</jsonpath>
            <to uri="eventbus://demo-dedupe-bus-in" />
</when>
<when>
            <jsonpath suppressExceptions="true">$.[?(@['tags']['Biometric_Quality-Iris'] in ['level-4','level-5','level-6','level-7','level-8','level-9','level-10','--Biometrics-Not-Available--'] &amp;&amp; @['tags']['Biometric_Quality-Finger'] in ['level-4','level-5','level-6','level-7','level-8','level-9','level-10','--Biometrics-Not-Available--'] &amp;&amp; @['tags']['Biometric_Quality-Face'] in ['level-4','level-5','level-6','level-7','level-8','level-9','level-10','--Biometrics-Not-Available--'])]</jsonpath>
            <to uri="eventbus://biometric-authentication-bus-in" />
</when>

Step III: Monitor registration packets and make decisions accordingly.

  1. Packets that have successfully passed ABIS can proceed with the update process until completion.

  2. For packets that have been matched with a previous registration or registrations and are paused for manual adjudication:

    1. Confirm whether or not registration is a true duplicate. There may be false duplicates, so it would be better to treat this adjudication the same as one would encounter in the regular registration flow.

    2. If it is:

      1. Deactivate UIN in the ID-Repo table.

      2. Set the status_code of registration to ‘DEACTIVATED’ in the registration table.

      3. Set the status_code of registration to ‘DEACTIVATED’ in the manual verification table.

      4. Remove the adjudication record from the ABIS MA. database.

For detailed instructions on how to deactivate a registration, please refer to the attached document on the JIRA case [ET-68].

How to use the image flipper

This code can be used to invert biometric images.

Please note that this tool can only be used for greyscale images, not RGB. It also does not provide metadata like DPI.

  1. Add the following dependencies:

    1. OpenCV - 4.9.0

    2. Slf4j-api - 1.7.30

    3. Jai-imageio-jpeg2000 - 1.3.0

  2. Expected arguments 

    1. "io.mosip.biometrics.util.image.type.jp2000=io.mosip.biometrics.util.image.type.jp2000": This argument expects the user to provide the biometric image type.

    2. "mosip.mock.sbi.biometric.type.finger.folder.path=\Finger": This argument expects the user to provide the relative path of the original biometric images from the project path. Note: The original code expects the biometric images to be found in a folder called either Finger, Face, or Iris.

    3. "mosip.mock.sbi.biometric.type.file.image=\FINGER-Left_IndexFinger-75.jp2": This argument expects the user to provide the file name of the original biometric image.

    4. "io.mosip.biometrics.image.rotation=90": This argument expects the user to provide the degree to which the original image needs to be rotated.

  3. After completion, the tool will output the modified image in the same folder path provided in the argument.

  4. The codebase for the image flipper can be found at the following link: Image Rotator

 Related articles

Related content