Skip to content

Scan Business Card

Sends a Business Card image to the Business Card Analyzer and returns the extracted business card information.

It's possible to retrieve the output back in two ways, either in CLOB (character large object) format or in PL/SQL record format.

The method with CLOB output accepts the following parameters:

  • response_, out parameter of type CLOB, to which the response will be written.
  • image_data_, required parameter of type BLOB to pass the binary image data to the Business Card Analyzer.
  • response_format_, optional parameter to specify the response format. Possible values are 'JSON' and 'IFS_MESSAGE'. If not specified 'IFS_MESSAGE' will be used as the default format.
  • ml_configuration_id_, optional parameter to specify the Configuration ID from Machine Learning Configuration (link to be added) to use. If not specified, the configuration specified in Machine Learning Pre-trained Models (link to be added) for the corresponding Model Name will be used.
DECLARE
   response_   CLOB;
   image_data_ BLOB;
BEGIN  
   Ml_Service_Util_API.Scan_Business_Card(
      response_            => response_,   -- Clob parameter to accept response data.
      image_data_          => image_data_, -- Blob parameter to pass the binary image data.
      response_format_     => 'JSON',      -- Response format ('JSON' / 'IFS_MESSAGE').
      ml_configuration_id_ => 'DEFAULT');  -- Configuration ID to use.
END;

For the above call, the response may look as following. The response may vary depending on the IFS Machine Learning Service version being used.

{
  "Entities": [
    {
      "Id": "raw_text",
      "Value": "JAYTIC VALE Fashion Designer\nKLAMBI\nGedong 8,2 Tampingan street Melbune, AU 10012\n+62 0300 345 678 faddey.vale@klambi.com klambi.com",
      "Probability": 1,
      "EntityGroupId": "Main"
    },
    {
      "Id": "vendor_address",
      "Value": "Gedong 8,2 Tampingan street Melbune, AU 10012",
      "Probability": 0.79,
      "EntityGroupId": "Main"
    },
    {
      "Id": "vendor_address_recipient",
      "Value": "KLAMBI",
      "Probability": 0.517,
      "EntityGroupId": "Main"
    },
    {
      "Id": "vendor_name",
      "Value": "KLAMBI",
      "Probability": 0.517,
      "EntityGroupId": "Main"
    }
  ],
  "EntityGroups": [
    "Main"
  ]
}

Tip: The IFS Message response format ('IFS_MESSAGE') allows using existing methods in Message_SYS package to handle the response which may be simpler to use in the PL/SQL code than 'JSON'.

The method with PL/SQL record output accepts the following parameters:

  • response_rec_, out parameter of type record, to which the response will be written.
  • image_data_, required parameter of type BLOB to pass the binary image data to the Business Card Analyzer.
  • ml_configuration_id_, optional parameter to specify the Configuration ID from Machine Learning Configuration (link to be added) to use. If not specified, the configuration specified in Machine Learning Pre-trained Models (link to be added) for the corresponding Model Name will be used.
DECLARE
   response_rec_ Ml_SYS.Doc_Scan_Response_Rec;
   image_data_   BLOB;
BEGIN
   Ml_Service_Util_API.Scan_Business_Card(
      response_rec_        => response_rec_, -- Record parameter to accept response data.
      image_data_          => image_data_,   -- Blob parameter to pass the binary image data.
      ml_configuration_id_ => 'DEFAULT');    -- Configuration ID to use.

   -- Example of handling response
   IF (response_rec_.entities.count > 0) THEN
      FOR i_ IN response_rec_.entities.first..response_rec_.entities.last LOOP
         Dbms_Output.Put_Line('Id:'||response_rec_.entities(i_).id);
         Dbms_Output.Put_Line('Value:'||response_rec_.entities(i_).value);
         Dbms_Output.Put_Line('Probability:'||response_rec_.entities(i_).probability);
         Dbms_Output.Put_Line('EntityGroupId:'||response_rec_.entities(i_).entity_group_id);
      END LOOP;
   END IF;
   IF (response_rec_.entity_groups.count > 0) THEN
      FOR i_ IN response_rec_.entity_groups.first..response_rec_.entity_groups.last LOOP
         Dbms_Output.Put_Line('EntityGroupId:'||response_rec_.entity_groups(i_));
      END LOOP;
   END IF;
END;

The Doc_Scan_Response_Rec response record type has the following format:

TYPE Doc_Scan_Response_Rec IS RECORD (
   entities                         Entity_Arr,
   entity_groups                    Entity_Group_Arr);

The Entity_Arr array type has the following format:

TYPE Entity_Arr IS TABLE OF Entity_Rec;

The Entity_Rec record type has the following format:

TYPE Entity_Rec IS RECORD (
   id                               VARCHAR2(100),
   value                            VARCHAR2(4000),
   probability                      NUMBER,
   entity_group_id                  VARCHAR2(100));

The Entity_Group_Arr array type has the following format:

TYPE Entity_Group_Arr IS TABLE OF VARCHAR2(100);

For more details about the Business Card Analyzer please see the Machine Learning Service documentation.