from Hacker News

Show HN: Gogosseract, a Go Lib for CGo-Free Tesseract OCR via Wazero

by dlock17 on 11/4/23, 11:06 PM with 24 comments

Tesseract is one of the largest Open Source OCR (Optical Character Recognition) projects. There is already a Go library for using Tesseract from Go with CGo, called Gosseract.

However if you are interested in OCR from Go without C complicating building and cross-compiling, there aren't any other options.

Wazero is a Go WASM runtime that doesn't have any CGo dependencies. With Emscripten Tesseract has been compiled to WASM and ran within Wazero.

Gogosseract provides a simple API on top of this. This project has been an interesting delve into the world of WASM.

  • by yklcs on 11/5/23, 8:03 AM

    I wrote a short blog post[1] on this method a while ago. I do think running WASM in embedded runtimes is a pretty good option, but overhead remains high, and WASI remains somewhat fragmented between compilers and runtimes.

    I think this method really shines in Go as not having CGo simplifies a lot of things, and as a decently performant JITed runtime exists in the form of wazero.

    [1]: https://yklcs.com/blog/universal-libs-with-wasm

  • by iampims on 11/5/23, 1:57 AM

    To me, this is the real value of Wasm: platform independent libraries with a standard interface that doesn’t require C.
  • by richieartoul on 11/5/23, 2:00 AM

    This is awesome and one of the things I’m really excited about with WASM, and specifically Wazero. The Wazero team is top notch. Now someone just needs to do this with zstd and make it fast…
  • by mappu on 11/5/23, 6:23 AM

    Another really interesting way to approach this problem would be to adapt wasm2c to emit Go output. It should result in better performance than wazero.
  • by donatj on 11/5/23, 4:56 AM

    Oh awesome. I was really hoping a native OCR would pop up but this really is the next best thing and a more realistic avenue.
  • by tommiegannert on 11/5/23, 8:01 AM

    Thanks for sharing!

    Since OCR is a somewhat slow process, how does the WASM approach compare to running libtesseract in a subprocess and use some IPC layer to talk to Go? It would require a separate C++ compiler, but not CGo.

    > one of the largest Open Source OCR

    Tangential, but are there others as large as Tesseract? It seems to pop up anywhere I look.

  • by abdullahkhalids on 11/5/23, 9:11 AM

    Is Tesseract currently the best open source OCR library? Best in terms of accuracy.

    How much difference is there between Tesseract and the best proprietary solutions?

  • by honkotime on 11/5/23, 2:09 PM

    It mentions that this is a rewrite of gosseract, however it is not a drop in replacement, so its more of a separate library in my opinion
  • by technics256 on 11/5/23, 8:26 AM

    Off topic but in general how does something like this compare to cloud hosted ocr solutions?
  • by breadchris on 11/5/23, 2:05 AM

    this is sick