views:

121

answers:

1

I'm developing a simple (or at least thought so) desktop application in Java for real-time image processing. I've chosen to access video frames using the Java Media Framework (JMF). I have a PAL camera and use EasyCAP video converter for digitizing. The device is visible on my Windows machine as a VFW device, allowing for YUV and 24-Bit RGB format acquisitions (32-Bit not available).

I already figured out the basics of the framework. I'm using a javax.media.Processor for media-data controlling and, for the beginning, wanted to add a grayscale-codec (implementing javax.media.Codec) for further rendering. In the codec I can access individual frames as javax.media.Buffer objects.

What is the fastest way to do the grayscale conversion in Java? I'd like to stick to some standard like JAI or so, as I'd like to be able to easily do further conversions using the same framework / methods.

I've been considering the following until now:

Adding a codec on the beginning of the codec chain to convert 24-Bit RGB to 32-Bit RGB. Than using java.nio.ByteBuffer to cast byte[] to int[] pixel-array for further processing with javax.awt.image filters. I've already tried to use com.sun.media.codec.video.colorspace.RGBConverter to achieve that, without success, though.

I'd be really grateful for any help, hope anyone has already done that.

I'd be grateful for any suggestions regarding overall application architecture as well. My general goal is to implement an Optical Flow algorithm in Java to be able to estimate camera attitude in real-time using visual input only.

A: 

Have a look at this library at JH Labs ( http://www.jhlabs.com/ip/filters/index.html ). It is available with source code. You can check the implementation there... specifically GrayscaleFilter.. Also Check the license before use. If you like it then please give credit to the original author.. :)

Favonius
Thanks for your answer Favonius. I maybe can copy the color weighting used in this filter. But in my case, I need the output to be 8-bit and not 24 or 32. I know, I've forgotten to mention that in my original post - sorry for that.
mmm