houqp / leptess

Productive and safe Rust binding for leptonica and tesseract
https://houqp.github.io/leptess/leptess/index.html
MIT License
259 stars 29 forks source link

Some way of retrieving a LepTess' image dimensions? #16

Closed kangalio closed 4 years ago

kangalio commented 4 years ago

Would it be possible to add a way to retrieve the dimensions of the image which is currently loaded in a LepTess instance?

houqp commented 4 years ago

We could add a helper method that uses GetInputImage API (https://github.com/tesseract-ocr/tesseract/blob/master/include/tesseract/baseapi.h#L139) to get a Pix object, then use it to return the dimension.

kangalio commented 4 years ago

I had a go at implementing this. The Tesseract C++ library documentation was very hard to understand for me though, and I don't know if the code I wrote is sound.

Maybe you can be a better judge?

https://github.com/kangalioo/leptess/blob/master/src/tesseract.rs#L90-L100

kangalio commented 4 years ago

Oh damn, I misclicked on mobile 😅

houqp commented 4 years ago

@kangalioo that looks good to me, feel free to send a PR.