Skip to content

Repository files navigation

msocr

Clone

  • install git-lfs
  • git pull && git lfs pull

Build

  • install Android NDK
  • build standalone toolchains for x86 and x86_64
  • /opt/android-ndk/build/tools/make_standalone_toolchain.py --arch x86 --api 16 --install-dir=/opt/android-ndk-x86
  • /opt/android-ndk/build/tools/make_standalone_toolchain.py --arch x86_64 --api 21 --install-dir=/opt/android-ndk-x86_64
  • build anlog
  • cd anlog && ndk-build
  • build msocrw
  • cd msocrw && ndk-build
  • build nodeocr (requires standalone toolchains created above)
  • cd nodeocr/jni && make

Run

  • Extract android-x86_64 rootfs from http://www.android-x86.org/download
  • rpm2cpio - system.sfs - system.img - /{bin,xbin,lib,lib64,etc,usr}
  • ln -s /system /
  • create /proc, /sys, /dev, ...
  • Copy this directory after compiling to /ocr under rootfs
  • Enter rootfs
  • systemd-nspawn (debian package in systemd-container)
  • cd /ocr
  • LD_PRELOAD=anlog/libs/x86_64/libanlog.so LD_LIBRARY_PATH=mslib/x86_64:msocrw/libs/x86_64:opencv/sdk/native/libs/x86_64:zxing/lib/x86_64 node/x86_64/bin/node

Usage

constocr=require("/ocr/nodeocr/libs/x86_64/nodeocr");// node module pathconsole.log(ocr);ocr.init('/ocr/res');// MsOcrRes.orp directoryconstfs=require('fs');constbuf=fs.readFileSync('/example.jpg');constres=ocr.recognize_image(buf);console.log(res);

Credits

About

node.js OCR and QR scanning module from Android, for Linux

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Contributors

Languages