|
|
|
@ -459,23 +459,36 @@ var T = (function createTesseractInstance(){
@@ -459,23 +459,36 @@ var T = (function createTesseractInstance(){
|
|
|
|
|
base.SetImage(Module.wrapPointer(ptr), width, height, 1, width) |
|
|
|
|
base.SetRectangle(0, 0, width, height) |
|
|
|
|
|
|
|
|
|
// base.Recognize(0);
|
|
|
|
|
|
|
|
|
|
var results = new Module.OSResults(); |
|
|
|
|
var success = base.DetectOS(results); |
|
|
|
|
console.log('detected os successfully', !!success); |
|
|
|
|
var charset = results.get_unicharset() |
|
|
|
|
results.print_scores() |
|
|
|
|
|
|
|
|
|
var best = results.get_best_result() |
|
|
|
|
var oid = best.get_orientation_id(), |
|
|
|
|
sid = best.get_script_id(); |
|
|
|
|
console.log('orientation id', oid, [0, 270, 180, 90][oid], best.get_oconfidence()) |
|
|
|
|
console.log('script id', sid, charset.get_script_from_script_id(sid), best.get_sconfidence()) |
|
|
|
|
// console.log(best)
|
|
|
|
|
cb(null, 'wolo') |
|
|
|
|
base.End(); |
|
|
|
|
Module._free(ptr); |
|
|
|
|
if(!success){ |
|
|
|
|
base.End(); |
|
|
|
|
Module._free(ptr); |
|
|
|
|
cb("failed to detect os") |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
var charset = results.get_unicharset() |
|
|
|
|
console.log(charset) |
|
|
|
|
// results.print_scores()
|
|
|
|
|
|
|
|
|
|
var best = results.get_best_result() |
|
|
|
|
var oid = best.get_orientation_id(), |
|
|
|
|
sid = best.get_script_id(); |
|
|
|
|
// console.log('orientation id', oid, [0, 270, 180, 90][oid], best.get_oconfidence())
|
|
|
|
|
// console.log('script id', sid, charset.get_script_from_script_id(sid), best.get_sconfidence())
|
|
|
|
|
// console.log(best)
|
|
|
|
|
|
|
|
|
|
cb(null, { |
|
|
|
|
tesseract_script_id: sid, |
|
|
|
|
script: charset.get_script_from_script_id(sid), |
|
|
|
|
script_confidence: best.get_sconfidence(), |
|
|
|
|
orientation_degrees: [0, 270, 180, 90][oid], |
|
|
|
|
orientation_confidence: best.get_oconfidence() |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
base.End(); |
|
|
|
|
Module._free(ptr); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|