Skip to content

Commit

Permalink
version 0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
GaspareG committed Apr 16, 2019
1 parent 4bf76d2 commit e3600f1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [Javascript BCR Library](https://github.com/syneo-tools-gmbh/Javascript-BCR-Library) 0.0.4
# [Javascript BCR Library](https://github.com/syneo-tools-gmbh/Javascript-BCR-Library) 0.0.5
## Authors: Gaspare Ferraro, Renzo Sala, Simone Ponte, Paolo Macco

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.
Expand Down
14 changes: 11 additions & 3 deletions src/bcr.cleaning.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function loadAndProcess(b64, callback, progress) {
}

// ****************************************************************************
// preprocessing pipeline
// Preprocessing pipeline
// ****************************************************************************
function pipeline(img, progress, callback) {
prepareImage(img, progress, function (data) {
Expand Down Expand Up @@ -91,7 +91,7 @@ function pipeline(img, progress, callback) {
}

// ****************************************************************************
// image preparation pipeline
// Image preparation pipeline
// ****************************************************************************
function prepareImage(b64image, progress, callback) {

Expand Down Expand Up @@ -148,6 +148,7 @@ function normalizeSize(canvas) {
return canvas;
}

// TODO: Replace with OpenCV.js smart crop
// ****************************************************************************
// isolate card and crop
// ****************************************************************************
Expand Down Expand Up @@ -214,9 +215,16 @@ function getPixel(data, y, x, width) {
// set pixel function
// ****************************************************************************
function setPixel(data, y, x, width, r, g, b, a) {

if (typeof a === "undefined") {
a = 255;
}

r = Math.min(255, Math.max(r, 0));
g = Math.min(255, Math.max(g, 0));
b = Math.min(255, Math.max(b, 0));
a = Math.min(255, Math.max(a, 0));

let baseIdx = (y * width + x) * 4;
data[baseIdx] = r;
data[baseIdx + 1] = g;
Expand Down Expand Up @@ -439,7 +447,7 @@ function boundingBox(ccs, canvas) {
let BlockW = Math.floor(W / 64);
let BlockH = 2;

let minX = 999999, minY = 999999, maxX = 0, maxY = 0;
let minX = 10e9, minY = 10e9, maxX = 0, maxY = 0;

for (let k = 0; k < ccs.length; k++) {
let cc = ccs[k];
Expand Down

0 comments on commit e3600f1

Please sign in to comment.