Qt: How to use Leptonica?
I need to write a program which will deskew scanned images. I've chosen Qt due to easy UI creation. I've tried to create deskew algorithm by myself, but then found interesting and well-known (to others) "Leptonica"开发者_StackOverflow社区. And i have 2 problems (googling dont help):
- How i can include Leptonica lib to my Qt project?
- I can't find any code examples for using it in C++ (found just some for Ruby).
Sorry for maybe stupid questions but i'm new to Qt and for me it's difficult even after reading official documentation.
=================================================
After adding leptonlib-1.67 directory to Qt Creator and editing .pro file, i can't build it. At first there is error like: "allheaders.h no such file or directory". When i've included scr folder to INCLUDEPATH in .pro file this error gone, but i get many many others. There should be some tutorials. Please, help!
To use Leptonica from C++, simply call it like you would in C. You can use the existing Leptonica samples as a starting point for calling the routines. You will want to look at ...\leptonlib-1.xx\prog\skewtest.c for a pretty complete example of how the skew routines are used.
In fact, you could probably just compile the skewtest program and drive it using your Qt GUI. The algorithm is pretty simple: rotate the image by a test angle, then compute the average intensity of each scanline, then find the variance of all these averages. The best deskew angle is (in theory) achieved when the variance is at a maximum. The different search algorithms used in skewtest take different approaches to finding this point of maximum variance.
精彩评论