I can post the source code, but I hate doing that without also posting an out-of-the-box working version. It's like we're back in 1992, and software is delicate and you need to config
I will post the code, but I will also start working on a 100% Java version. I've been trying to work on compiling Leptonica for architectures other than Mac Intel, but it's proving to be an enormous pain, as well as reminding me why I abandoned C back in 1999. Not only that, and you Core 2 Duo owners might know what I'm talking about -- you have to choose whether to run 64-bit Java or 32-bit Java, and then when you hit a native C library for Java to load, if you don't match the C library's architecture, you are screwed.
So, here's what you need to do to compile. If you don't know how to do both Java and C development, don't attempt this! Wait for the 100% Java version.
1. Install libjpeg
2. install libz
3. Install libtiff (this library depends on libjpeg and libz, so install it after libjpeg and libz).
4. Perhaps needless to say, get Java 5 or Java 6. These should theoretically already be installed on your machine.
5. Get Leptonica. Compile it.
6. If you're on a Mac Core 2 Duo, run Applications/Utilities/Java/Java Preferences and move J2SE 5.0 32-bit to the top.
7. Compile the JLeptonica.java and Test.java files.
8. Run javah on JLeptonica.java to get the native header file.
9. Compile JLeptonicaC.c along with the above native header file.
10. Make it a dynamically loadable library.
11. You should now be able to run the program as follows:
- Code: Select all
java -classpath CLASSDIR -Djava.library.path=LIBDIR test.Test L|R IMGDIR
where CLASSDIR is the directory containing the class files,
LIBDIR is the directory containing your JLeptonicaC dynamic library
L|R is L for left-hand page images, or R for right-hand page images
IMGDIR is the directory containing the images from your camera, which must end in .JPG
The camera images must look something like this:
Try to get the page as evenly lit as possible: no hot spots.
The page may be rotated as much as ten degrees either way, and there may be some keystoning caused by having the camera not perfectly centered and not pointing exactly perpendicular to the page.