ocrservice
Advanced tools
Comparing version 0.1.20 to 0.1.21
@@ -151,3 +151,3 @@ (function() { | ||
debug('erp', msg); | ||
return this.emit('loginError', data); | ||
return this.emit('loginError', msg); | ||
}; | ||
@@ -154,0 +154,0 @@ |
@@ -77,2 +77,7 @@ (function() { | ||
})(this)); | ||
socket.on('size', (function(_this) { | ||
return function(data) { | ||
return _this.onSize(socket, data); | ||
}; | ||
})(this)); | ||
socket.on('bad', (function(_this) { | ||
@@ -143,2 +148,8 @@ return function(data) { | ||
IO.prototype.onSize = function(socket, data) { | ||
socket.mywidth = data.width; | ||
socket.myheight = data.height; | ||
return debug('onSize', data); | ||
}; | ||
IO.prototype.onLogin = function(socket, data) { | ||
@@ -253,3 +264,3 @@ var me, options; | ||
recognizer.on('open', function(res) { | ||
var adr, cropped, item, r, ratio; | ||
var adr, cropped, item, r, ratio, ratioH, ratioW; | ||
r = recognizer.outerbounding(); | ||
@@ -279,4 +290,8 @@ item = { | ||
cropped.rotate(270); | ||
cropped.brightness - 30; | ||
cropped.equalizeHist(); | ||
if (typeof socket.mywidth === 'number') { | ||
ratio = socket.mywidth / r.width; | ||
ratioW = socket.mywidth / r.width; | ||
ratioH = socket.myheight / r.height; | ||
ratio = Math.max(ratioW, ratioH); | ||
cropped.resize(r.height * ratio, r.width * ratio); | ||
@@ -283,0 +298,0 @@ } |
@@ -225,3 +225,2 @@ (function() { | ||
pattern = variables.OCR_WATCH_PATTERN; | ||
debug('watch', 'glob'); | ||
return glob(pattern, options, function(err, matches) { | ||
@@ -260,11 +259,3 @@ if (err) { | ||
if (res.length === 0 || typeof res[0].box === 'undefined' || res[0].box.length === 0) { | ||
name = codes.join('.'); | ||
return fs.rename(file, path.join(me.pathName, 'noaddress', name + path.extname(file)), function(err) { | ||
if (err) { | ||
console.trace(err); | ||
return me.emit('error', err); | ||
} else { | ||
return setTimeout(me.nextFile.bind(me), 1); | ||
} | ||
}); | ||
return me.fullScann(codes); | ||
} else if (res.length === 1) { | ||
@@ -387,2 +378,61 @@ name = res[0].codes.join('.'); | ||
Watcher.prototype.fullScann = function(codes) { | ||
var file, me, recognizer; | ||
me = this; | ||
file = path.join(me.pathName, me.files[me.fileIndex]); | ||
debug('fullscann', file); | ||
recognizer = new Recognizer; | ||
recognizer.setDebug(false); | ||
recognizer.on('error', function(err) { | ||
return me.noAddress(codes); | ||
}); | ||
recognizer.on('open', function(res) { | ||
var adr, item, r; | ||
r = recognizer.outerbounding(); | ||
item = { | ||
rect: r | ||
}; | ||
recognizer.barcode(); | ||
recognizer.getText(item); | ||
data.codes = recognizer.barcodes; | ||
data.txt = recognizer.texts; | ||
data.zipCode = ""; | ||
data.town = ""; | ||
data.street = ""; | ||
data.housenumber = ""; | ||
data.housenumberExtension = ""; | ||
if (data.txt.length > 0) { | ||
adr = recognizer.getAddress(data.txt[0], true); | ||
data.adr = adr; | ||
data.zipCode = adr.zipCode; | ||
data.town = adr.town; | ||
data.street = adr.street; | ||
data.housenumber = adr.housenumber; | ||
data.housenumberExtension = adr.housenumberExtension; | ||
} | ||
debug('sortboxAfterText', data); | ||
recognizer.addresses.push(data); | ||
return recognizer.sortboxAfterText(); | ||
}); | ||
recognizer.once('boxes', function(boxes, codes) { | ||
console.log(boxes); | ||
return process.exit(); | ||
}); | ||
return recognizer.open(name, false); | ||
}; | ||
Watcher.prototype.noAddress = function(codes) { | ||
var file, name; | ||
file = path.join(me.pathName, me.files[me.fileIndex]); | ||
name = codes.join('.'); | ||
return fs.rename(file, path.join(me.pathName, 'noaddress', name + path.extname(file)), function(err) { | ||
if (err) { | ||
console.trace(err); | ||
return me.emit('error', err); | ||
} else { | ||
return setTimeout(me.nextFile.bind(me), 1); | ||
} | ||
}); | ||
}; | ||
return Watcher; | ||
@@ -389,0 +439,0 @@ |
@@ -9,3 +9,3 @@ { | ||
}, | ||
"version": "0.1.20", | ||
"version": "0.1.21", | ||
"engines": { | ||
@@ -12,0 +12,0 @@ "node": ">=0.12.0" |
@@ -11,2 +11,3 @@ # ocrservice | ||
``` | ||
npm install forever -g | ||
npm install ocrservice -g | ||
@@ -16,2 +17,3 @@ ``` | ||
## Usage | ||
@@ -28,3 +30,3 @@ | ||
``` | ||
ocrservice install --initscript myservicename /my/image/path/ | ||
ocrservice install --type init myservicename /my/image/path/ | ||
``` | ||
@@ -34,2 +36,3 @@ | ||
``` | ||
@@ -40,1 +43,5 @@ ocrservice variables | ||
The *systemd* service reads that variables from /etc/sysconfig/myservicename. The init.d script keeps that variables inside. | ||
##debian notes | ||
See [https://thomashunter.name/blog/running-a-node-js-process-on-debian-as-an-init-d-service/] |
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
149905
2358
43