Javascript BCR Library 1.0.12
BCR Library is a javascript library, using the OCR engine Tesseract.JS, that extracts name, company name, job, address, phone numbers, email and web address out of a business card picture.
The library is written in Javascript and can be used in any Javascript project (included in projects using frameworks for hybrid mobile applications, like Apache Cordova, Phonegap or Ionic).
The library can be used offline, no online dependencies are required.
Copy the content of the repository and reference bcr via script
tag in your HTML project:
<script type="text/javascript" src="src/bcr.js"></script>
The sample application in the repository must be executed on a web server.
If you have python it's enough to run python -m http.server 8000
in the project folder.
If you use cordova, you can add the browser
platform and run it (it works on other platforms like Android or iOS too).
bcr.initialize(ocrEngine, crop, language, width, height, QRScanner, dynamicInclude);
Initialize the bcr reader. If ocrEngine is set to ocrEngines.TESSERACT, initialize the tesseract engine. If ocrEngine is set to ocrEngines.GOOGLEVISION, initialize bcr reader given the ocr from google mobile vision text recognition API (cordova-plugin-mobile-ocr).
Where:
- STRING
ocrEngine
the selected engine (see ocrEngines), defaultocrEngines.TESSERACT
. - STRING
crop
: the crop strategy (see languages), defaultlanguages.GERMAN
. - STRING
language
: the language trained data (see cropStrategy), defaultcropStrategy.SMART
. - NUMBER
width
: max internal width, default2160
. - NUMBER
height
: max internal height, default1440
. - BOOLEAN
QRScanner
: check first for VCard QR Code in image, defaulttrue
. - BOOLEAN
dynamicInclude
: if the references are not included externally, defaulttrue
. - Return Promise about JS loading.
bcr.recognize(base64image, displayResultCallback, displayProgressCallback, ocr);
Where:
- STRING
base64image
: base64 string of the image to analyze. - FUNCTION
displayResultCallback(result_data)
function called when the analysis of the business card is completed. - FUNCTION
displayProgressCallback(progress_data)
function called after each progress in the analysis. - OBJECT
ocr
: object containing ocr results data from google mobile vision (optional, default ``).
bcr.cropStrategy()
- Return the strategy label internally set.
bcr.maxWidth()
- Return the value of the max width used internally to normalize the resolution.
bcr.maxHeight()
- Return the value of the max height used internally to normalize the resolution.
bcr.language()
- Return the value of the language trained data.
bcr.tesseract()
- Return the initialized tesseract worker.
bcr.ocr()
- Return the ocr passed.
bcr.ocrEngine()
- Return the ocr engine selected.
bcr.qrScanner()
-if VCard QRScanner read is enabled.
JSON object in the format:
{
"Company": "STRING",
"Email": "STRING",
"Address": {
"StreetAddress": "STRING",
"ZipCode": "STRING",
"Country": "STRING",
"Text": "STRING",
"City": "STRING"
},
"Web": "STRING",
"Phone": "STRING",
"Text": "STRING",
"Fax": "STRING",
"Job": "STRING",
"Mobile": "STRING",
"Name": {
"Text": "STRING",
"Surname": "STRING",
"Name": {
"FirstName": "STRING",
"Text": "STRING",
"MiddleName": "STRING",
"ExtraName": "STRING"
}
}
}
JSON object in the format:
{
"section": "STRING",
"progress": {
"status": "STRING",
"progress": "FLOAT"
}
}
languages.DANISH
: Danish languagelanguages.GERMAN
: German languagelanguages.ENGLISH
: English languagelanguages.FRENCH
: French languagelanguages.ITALIAN
: Italian languagelanguages.SPANISH
: Spanish languagelanguages.SWEDISH
: Swedish language
cropStrategy.SMART
: clean the image
ocrEngines.TESSERACT
: use the tesseract internal engineocrEngines.GOOGLEVISION
: use Google Mobile Vision external engine
- Tesseract.JS - 1.0.19
Tesseract.js wraps an emscripten port of the Tesseract OCR Engine.
- cordova-plugin-ionic-webview - 4.0.0
A Web View plugin for Cordova, focused on providing the highest performance experience for Ionic apps (but can be used with any Cordova app).
The current status of the library is alpha. Looking forward for your contribution to make the first release.