www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Binding for tesseract

reply "Andrea Fontana" <nospam example.com> writes:
I need a binding for tesseract.  It has a C interface, so it 
should be doable.

Has anyone already done it?

Is there a tutorial on how to create a binding? I've seen bcd.gen 
but it seems old: it won't compile with my dmd version.
Feb 06 2013
next sibling parent reply David <d dav1d.de> writes:
Am 06.02.2013 13:16, schrieb Andrea Fontana:
 I need a binding for tesseract.  It has a C interface, so it should be
 doable.
 
 Has anyone already done it?
 
 Is there a tutorial on how to create a binding? I've seen bcd.gen but it
 seems old: it won't compile with my dmd version.
 
Translating this file: http://code.google.com/p/tesseract-ocr/source/browse/trunk/api/capi.h Into D, wrapped with extern(C) should do it. I played around with pytesser a while ago: http://code.google.com/p/pytesser/source/browse/trunk/pytesser.py This calls the tesseract executable, maybe that is easier.
Feb 06 2013
parent reply "Andrea Fontana" <nospam example.com> writes:
Yes, but I never did a "translation". Any manual/tutorial/help 
about this?

On Wednesday, 6 February 2013 at 12:25:37 UTC, David wrote:
 Am 06.02.2013 13:16, schrieb Andrea Fontana:
 I need a binding for tesseract.  It has a C interface, so it 
 should be
 doable.
 
 Has anyone already done it?
 
 Is there a tutorial on how to create a binding? I've seen 
 bcd.gen but it
 seems old: it won't compile with my dmd version.
 
Translating this file: http://code.google.com/p/tesseract-ocr/source/browse/trunk/api/capi.h Into D, wrapped with extern(C) should do it. I played around with pytesser a while ago: http://code.google.com/p/pytesser/source/browse/trunk/pytesser.py This calls the tesseract executable, maybe that is easier.
Feb 06 2013
parent reply David <d dav1d.de> writes:
Am 06.02.2013 14:29, schrieb Andrea Fontana:
 Yes, but I never did a "translation". Any manual/tutorial/help about this?
 
Well, you need a basic C knowledge to translate it and there is this guide: http://dlang.org/interfaceToC.html If you need more help you can join #D on irc.freenode.net, helping with a realtime chat is easier than over these "forums"
Feb 06 2013
parent "Andrea Fontana" <nospam example.com> writes:
That seems useful, thank you :)
In the meantime, I've started a ec2 micro instance 32bit and I'm
trying to compile stuff for dstep :)

On Wednesday, 6 February 2013 at 18:35:30 UTC, David wrote:
 Am 06.02.2013 14:29, schrieb Andrea Fontana:
 Yes, but I never did a "translation". Any manual/tutorial/help 
 about this?
 
Well, you need a basic C knowledge to translate it and there is this guide: http://dlang.org/interfaceToC.html If you need more help you can join #D on irc.freenode.net, helping with a realtime chat is easier than over these "forums"
Feb 06 2013
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2013-02-06 13:16, Andrea Fontana wrote:
 I need a binding for tesseract.  It has a C interface, so it should be
 doable.

 Has anyone already done it?

 Is there a tutorial on how to create a binding? I've seen bcd.gen but it
 seems old: it won't compile with my dmd version.
There's a tool for that: https://github.com/jacob-carlborg/dstep -- /Jacob Carlborg
Feb 06 2013
parent reply "Andrea Fontana" <nospam example.com> writes:
It won't compile on ubuntu 12.10 64bit alternatives?

On Wednesday, 6 February 2013 at 13:46:11 UTC, Jacob Carlborg 
wrote:
 On 2013-02-06 13:16, Andrea Fontana wrote:
 I need a binding for tesseract.  It has a C interface, so it 
 should be
 doable.

 Has anyone already done it?

 Is there a tutorial on how to create a binding? I've seen 
 bcd.gen but it
 seems old: it won't compile with my dmd version.
There's a tool for that: https://github.com/jacob-carlborg/dstep
Feb 06 2013
parent reply Jacob Carlborg <doob me.com> writes:
On 2013-02-06 15:45, Andrea Fontana wrote:
 It won't compile on ubuntu 12.10 64bit alternatives?
Use the pre-compiled binary for 32bit. -- /Jacob Carlborg
Feb 06 2013
parent reply Fred <honohanf gmail.com> writes:
On Thursday, 7 February 2013 at 07:36:18 UTC, Jacob Carlborg 
wrote:
 On 2013-02-06 15:45, Andrea Fontana wrote:
 It won't compile on ubuntu 12.10 64bit alternatives?
Use the pre-compiled binary for 32bit.
On Thursday, 7 February 2013 at 07:36:18 UTC, Jacob Carlborg wrote:
 On 2013-02-06 15:45, Andrea Fontana wrote:
 It won't compile on ubuntu 12.10 64bit alternatives?
Use the pre-compiled binary for 32bit.
Hey Jacob & Andrea, I hate to drag this up from so long ago but I am very new to D and have used your tool to convert the latest capi.c from the tesseract-ocr library (https://github.com/tesseract-ocr/tesseract/blob/master/src/api/capi.h) And I am wondering how I go about simply importing it and using it in my D project. Here is the converted file, it worked with dstep with no errors: https://pastebin.com/x1FgWjGj And I called the output file tesseract_capi.d and put it in the source directory of my project and am trying to import it into one of my apps files named ocr.d as follows: module ocr; import std.stdio; import tesseract_capi; class ocr{ TessBaseAPI *api; this(){ this.api = TessBaseAPICreate(); } } And any attempt to build and run returns an: undefined reference to `TessBaseAPICreate' Should I be linking to the actual library in the dub.json? I cannot seem to find any straightforward tutorial about importing dstep converted files unfortunately. Any help would be greatly appreciated. Thank you
May 08 2019
parent reply Fred <honohanf gmail.com> writes:
On Thursday, 9 May 2019 at 00:30:04 UTC, Fred wrote:
 Should I be linking to the actual library in the dub.json? I 
 cannot seem to find any straightforward tutorial about 
 importing dstep converted files unfortunately.

 Any help would be greatly appreciated.
 Thank you
Turns out, yes, all I needed to do was check for the location of the library tesseract -v tesseract 4.0.0 leptonica-1.75.3 libgif 5.1.4 : libjpeg 8d (libjpeg-turbo 1.5.2) : libpng 1.6.34 : libtiff 4.0.9 : zlib 1.2.11 : libwebp 0.6.1 : libopenjp2 2.3.0 Found SSE And add "-ltesseract" to my projects lflags in the dub.json! Sorry for the notification folks +1
May 08 2019
parent Jacob Carlborg <doob me.com> writes:
On 2019-05-09 02:41, Fred wrote:

 And add "-ltesseract" to my projects lflags in the dub.json!
Yeah, that's correct.
 Sorry for the notification folks +1
No worries. -- /Jacob Carlborg
May 14 2019