Page 1 of 1

I hate the Java Advanced Imaging API

Posted: 03 Jan 2011, 00:00
by rob
Or, an open JAI break-up letter.

If you have no idea what I'm talking about, you may as well skip this post :)

By all that is sacred and holy, I officially declare that I am finished -- finished -- with the JAI. Every time I decide to use the JAI to accomplish some image processing, because it's from Sun and because it has some filters and operations I'd like to use, it's a complete pain in the ass. Everything is opaque. You can't tell whether an operation is going to barf because it doesn't like the image you passed it, or not barf and just take hours to crunch through. The way the whole API is structured, it looks like it was written by a space alien from Mars. If you want to play nice and define a new operation for JAI, forget it. Eating glass is more fun.

Now, C has two very good and very high-quality image processing libraries: Leptonica, and OpenCV. I've used them, but only with very brief, tiny programs, because the day I move to C because Java doesn't have a good image processing library is the day I shoot myself right in the face, because that's what going to C from Java is like. Shooting yourself in the face. You C programmers, don't complain. Program in Java for ten years, then go back to C and tell me it doesn't make you feel exactly like popping a cap in your head, just to quiet that insane gibbering in the back of your skull that results from too many pointers, pointers to pointers, and templates. I'd rather learn a weird language like Erlang just to avoid having to use C for anything serious.

So fuck you, JAI, I'm through with you. Take your rendered ops and JAI registry files and go running back to your new daddy, Oracle, you filthy mutated whatever the hell you are.

Where the hell is the aspirin.

Re: I hate the Java Advanced Imaging API

Posted: 03 Jan 2011, 01:39
by steve1066d
Yep, the JAI is proof that you shouldn't code by committee.

Though its so promising.. when it works, its great (once you get past the weird syntax).

But yeah, when it doesn't work, you've got no clue why.

Re: I hate the Java Advanced Imaging API

Posted: 03 Jan 2011, 10:21
by Anonymous1
Soo, any alternatives?

Re: I hate the Java Advanced Imaging API

Posted: 03 Jan 2011, 10:29
by rob
Well, I wrote a partial port of Leptonica, bug-for-bug compatible. But I have no plans to complete the port. I haven't evaluated any of these (but I really need to):

ImageJ (but it's an app, not a library?)
im4java (Java interface to ImageMagick API)
Java OpenCV (partial Java port of OpenCV)
JavaCV (Java interface to OpenCV) <-- this may hold the most promise

Re: I hate the Java Advanced Imaging API

Posted: 03 Jan 2011, 12:31
by Anonymous1
I hope there are Python versions of these... I've used OpenCV for a page turn-detector (it's functional ;)) webcam, and it has tons of useful stuff.

I would suggest OpenCV. I was looking at the blob detection, as I am taking a stab at content-detection algorithms myself (just to crop out the useless junk in a page). Good luck, as OpenCV has tons of documentation for C++ and C#, but barely a complete script for Python (I'm not sure about Java either).

Re: I hate the Java Advanced Imaging API

Posted: 03 Jan 2011, 12:36
by rob
I'm pretty sure OpenCV has python bindings. I know that the MacPorts version of OpenCV has an option where you can select python bindings. Usually the bindings are straightforward ports of the native API, so lack of documentation shouldn't be a problem...

Re: I hate the Java Advanced Imaging API

Posted: 03 Jan 2011, 14:09
by Anonymous1
I actually used OpenCV's Python bindings for that application, and for a first-time CV user, it was like hell. There were tons of vague errors, strange new variable types that were unique to OpenCV, and other random things. In the end, though, it was worth it ;)

Re: I hate the Java Advanced Imaging API

Posted: 04 Jan 2011, 17:12
by rob
So I tried JavaCV and threw it out because it required OpenCV 2.1, and OpenCV is already on 2.2. Even with OpenCV 2.1, the program would run properly once, then crash a few times, then run again. So screw it -- I'll write a very small very carefully written C program.

Re: I hate the Java Advanced Imaging API

Posted: 05 Jan 2011, 10:55
by daniel_reetz
I hate to say it, Rob, but when you're angry, you write such funny copy that I *almost* wish you weren't such a calm, collected dude...

Re: I hate the Java Advanced Imaging API

Posted: 05 Jan 2011, 11:51
by rob
Ha ha, that's because it's a coping mechanism. When I'm hungry, I get loopy, and when I'm angry, I get (humorously) sarcastic. I've tried to tap into my inner violent criminal at other times, but he's elusive when he's in hiding.

Perhaps I'm a cat. Hungry cats are cute, while angry cats are sometimes funny (and sharp).