ID card recognition settings

Aspose.OCR for Java allows for very flexible customization of ID card recognition accuracy, performance, and other settings using IDCardRecognitionSettings object.

These settings are specifically tailored for processing scanned or photographed ID cards.

Method Parameter Default state Description
setAllowedCharacters Case-sensitive string of characters or one of the predefined character sets:
  • CharactersAllowedType.ALL - try to recognize all characters.
  • CharactersAllowedType.LATIN_ALPHABET - only recognize case-insensitive Latin / English text (A to Z and a to z), without accented characters.
  • CharactersAllowedType.DIGITS - recognize only binary, octal, decimal, or hexadecimal numbers (0-9 and A to F).
All characters from the selected recognition language. The whitelist of characters Aspose.OCR engine will look for.
setIgnoredCharacters Case-sensitive string of characters All characters are recognized A blacklist of characters that are ignored during recognition.
setLanguage Recognition language Extended Latin characters, including diacritics Specify a language for recognition.
setThreadsCount Number of threads, int Automatic The number of CPU threads used for recognition.
setAutomaticColorInversion boolean true Set the method parameter to true automatically detect white text on a dark/black background and use a special OCR algorithm to improve ID card recognition accuracy. Call this method with the parameter set to “false” to explicitly disable inverted text detection to save resources.

Applicable to

Example

The following code example shows how to fine-tune ID card recognition:

AsposeOCR api = new AsposeOCR();
// Add images to the recognition batch
OcrInput images  = new OcrInput(InputType.SingleImage);
images.add(os.path.join(self.dataDir, "ID1.png"));
images.add(os.path.join(self.dataDir, "ID2.png"));
// Recognition settings
IDCardRecognitionSettings recognitionSettings = new IDCardRecognitionSettings();
recognitionSettings.setLanguage(Language.Ukr);
// Recognize ID cards
ArrayList<RecognitionResult> results = api.RecognizeIDCard(input, recognitionSettings);
results.forEach((result) -> {
	System.out.println(result.recognition_text);
});