New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ocrservice

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ocrservice - npm Package Compare versions

Comparing version 0.1.83 to 0.1.84

2

lib/classes/cbcocrmaster.js

@@ -42,3 +42,2 @@ (function() {

this.cluster.on('exit', function(worker, code, signal) {
console.log('worker ' + worker.process.pid + ' died');
return me.dispatchTask();

@@ -216,3 +215,2 @@ });

});
debug('cmaster', 'readDirectory, active clients ' + count);
if (this.run) {

@@ -219,0 +217,0 @@ options = {

1

lib/classes/db.js

@@ -33,2 +33,3 @@ (function() {

};
this.setMaxListeners(100);
this.limit = 10000;

@@ -35,0 +36,0 @@ this.connection = mysql.createConnection(options);

@@ -43,2 +43,4 @@ (function() {

};
this.processlist = path.resolve(__dirname, '../../process_list.json');
this.db = new DB(variables.OCR_DB_NAME, variables.OCR_DB_USER, variables.OCR_DB_PASSWORD, variables.OCR_DB_HOST);
discoverServer.setMessage(discoverMessage);

@@ -299,2 +301,3 @@ this.io.listen(variables.WEBSOCKET_PORT);

recognizer = new Recognizer;
this.recognizer = new Recognizer(this.db, this.processlist);
recognizer.setDebug(false);

@@ -301,0 +304,0 @@ recognizer.addresses.push(data);

(function() {
var CBcOcr, CBcOcrMaster, Command, DB, Extract, Recognizer, cluster, fs, glob, moveFile, path, spawn, variables,
var CBcOcr, CBcOcrMaster, Command, DB, Extract, OCR, Recognizer, cluster, cmWidth, cv, dinLANGXOffset, fs, glob, moveFile, path, spawn, variables, xocr,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },

@@ -28,2 +28,14 @@ hasProp = {}.hasOwnProperty;

cv = require('opencv');
OCR = require('wocr').OCR;
xocr = new OCR();
xocr.Init(variables.OCR_LANGUAGE);
cmWidth = variables.OCR_IMAGE_WIDTH_CM;
dinLANGXOffset = 16;
moveFile = function(orig, dest, cb) {

@@ -164,2 +176,3 @@ var source;

} else {
this.db = new DB(variables.OCR_DB_NAME, variables.OCR_DB_USER, variables.OCR_DB_PASSWORD, variables.OCR_DB_HOST);
exitfn = function() {

@@ -175,3 +188,3 @@ return process.exit();

}
return me.zbarimg();
return me.dinlang();
});

@@ -181,22 +194,160 @@ }

CBcOcr.prototype.zbarimg = function() {
var zb;
zb = spawn('zbarimg', ['-q', this.filename]);
zb.on('close', (function(_this) {
return function(code, signal) {
return _this.onZBarImageClose(code, signal);
CBcOcr.prototype.show = function(im) {
var scale, showImage, win;
if (parseInt(variables.OCR_DEBUG_WINDOW) === 1) {
win = new cv.NamedWindow("Debug" + (this.showCounter++), 0);
showImage = im.clone();
scale = 2;
while (showImage.width() > this.maxDisplayWidth) {
showImage.resize(showImage.width() / scale, showImage.height() / scale);
}
win.show(showImage);
return win.blockingWaitKey(parseInt(variables.OCR_DEBUG_WINDOW_TIMEOUT));
}
};
CBcOcr.prototype.appendBarcode = function(item) {
var code;
code = item.code;
if (code.indexOf('http://') === -1) {
if (item.type === 'I2/5') {
code = code.substring(0, code.length - 1);
}
return this.codes.push(code);
}
};
CBcOcr.prototype.dinlang = function() {
console.log(this.filename);
return cv.readImage(this.filename, (function(_this) {
return function(err, im) {
return _this.dinlangReaded(err, im);
};
})(this));
zb.stdout.on('data', (function(_this) {
return function(data) {
return _this.onZBarImage(data);
};
})(this));
return zb.stderr.on('data', (function(_this) {
return function(data) {
return _this.onZBarImageError(data);
};
})(this));
};
CBcOcr.prototype.dinlangReaded = function(err, im) {
var addressArea, adr, barcodeArea, code, codes, i, j, len, len1, me, norm, oneCM, searchtext, text;
me = this;
if (err) {
error('DIN LANG Read Error', err);
return process.exit();
} else {
im.resize(im.width() * parseFloat(variables.OCR_IMAGE_WIDTH_SCALE), im.height() * parseFloat(variables.OCR_IMAGE_HEIGHT_SCALE));
oneCM = im.width() / cmWidth;
barcodeArea = im.crop(oneCM * dinLANGXOffset, 0, oneCM * 3, im.height() / 2);
barcodeArea.convertGrayscale();
norm = barcodeArea.threshold(60, 140);
norm.normalize(0, 255);
barcodeArea = norm.clone();
barcodeArea.gaussianBlur();
xocr.SetMatrix(barcodeArea);
codes = xocr.GetBarcode();
if (codes.length > 0) {
for (i = 0, len = codes.length; i < len; i++) {
code = codes[i];
this.appendBarcode(code);
}
addressArea = im.crop(oneCM * (dinLANGXOffset + 5), im.height() / 2, oneCM * 6, im.height() / 2 - 1);
addressArea.convertGrayscale();
addressArea.gaussianBlur();
xocr.SetMatrix(addressArea);
text = xocr.GetText();
this.extract = new Extract;
adr = this.extract.extractAddress(text);
if (adr.state === true) {
searchtext = adr.street + ' ' + adr.zipCode + ' ' + adr.town;
this.db.once('ocrhash', function(rows) {
if (rows.length > 0) {
me.db.once('sortbox', function(boxes) {
if (boxes.length > 0) {
me.adressObject = {
name: adr.name,
street: boxes[0].strasse,
housenumber: adr.housenumber,
housenumberExtension: adr.housenumberExtension,
flatNumber: adr.flatNumber,
zipCode: boxes[0].plz,
town: boxes[0].ortsteil,
state: adr.state,
message: adr.message,
ocr_street: adr.ocr_street,
ocr_zipCode: adr.ocr_zipCode,
ocr_town: adr.ocr_town,
district: boxes[0].ortsteil
};
me.box = {
strid: boxes[0].strid,
mandant: boxes[0].mandant,
regiogruppe: boxes[0].regiogruppe,
bereich: boxes[0].bereich,
sortiergang: boxes[0].sortiergang,
sortierfach: boxes[0].sortierfach,
plz: boxes[0].plz,
ort: boxes[0].ort,
ortsteil: boxes[0].ortsteil,
hnvon: boxes[0].hnvon,
hnbis: boxes[0].hnbis,
zuvon: boxes[0].zuvon,
zubis: boxes[0].zubis,
gerade: boxes[0].gerade,
ungerade: boxes[0].ungerade,
strasse: boxes[0].strasse
};
return me.onGood();
} else {
return me.zbarimg();
}
});
return me.db.findSortbox(rows[0].ids, adr.housenumber);
} else {
return me.zbarimg();
}
});
return this.db.findText(searchtext);
} else {
return this.zbarimg();
}
} else {
barcodeArea = im.clone();
barcodeArea.convertGrayscale();
norm = barcodeArea.threshold(60, 140);
norm.normalize(0, 255);
barcodeArea = norm.clone();
barcodeArea.gaussianBlur();
xocr.SetMatrix(barcodeArea);
codes = xocr.GetBarcode();
for (j = 0, len1 = codes.length; j < len1; j++) {
code = codes[j];
this.appendBarcode(code);
}
return this.zbarimg();
}
}
};
CBcOcr.prototype.zbarimg = function() {
var zb;
if (this.codes.length === 0) {
zb = spawn('zbarimg', ['-q', this.filename]);
zb.on('close', (function(_this) {
return function(code, signal) {
return _this.onZBarImageClose(code, signal);
};
})(this));
zb.stdout.on('data', (function(_this) {
return function(data) {
return _this.onZBarImage(data);
};
})(this));
return zb.stderr.on('data', (function(_this) {
return function(data) {
return _this.onZBarImageError(data);
};
})(this));
} else {
return this.bardecode();
}
};
CBcOcr.prototype.bardecode = function() {

@@ -293,3 +444,2 @@ var bd;

if (this.codes.length === 0) {
this.db = new DB(variables.OCR_DB_NAME, variables.OCR_DB_USER, variables.OCR_DB_PASSWORD, variables.OCR_DB_HOST);
this.recognizer = new Recognizer(this.db, this.processlist);

@@ -296,0 +446,0 @@ this.recognizer.setDebug(this.debug || false);

@@ -13,2 +13,3 @@ (function() {

OCR_RELATIVEAREAMAXIMUM: 0.4,
OCR_IMAGE_WIDTH_CM: 28,
OCR_IMAGE_HEIGHT_SCALE: 1,

@@ -15,0 +16,0 @@ OCR_IMAGE_WIDTH_SCALE: 1.6,

@@ -16,3 +16,3 @@ {

},
"version": "0.1.83",
"version": "0.1.84",
"engines": {

@@ -19,0 +19,0 @@ "node": ">=0.12.0"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc