Tuesday, March 31, 2009

Image to BufferedImage conversion

For some reason, this seems to be a largely unsolved problem on the internet. Here's the short:

1) Image im = whatever...
2) BufferedImage bi = new BufferedImage(im.getWidth(null), im.getHeight(null), type);
3) Graphics g = bi.getGraphics();
4) g.drawImage(im, 0, 0, null);

There are plenty of optional details, of course, which check for transparent pixels, create a BufferedImage that is compliant with the target platform's graphics options, etc. These steps provide you with the critical path, and leave the details to exploratory choice.

Monday, March 30, 2009

webcam-server for linux

Building on my need to get webcam frames to OpenJCV in a faster than file IO manner, I apt-getted webcam-server. This program streams video from your webcam to http://localhost:8888 by default, with a few options for change.

There are some problems with initial startup:
1) webcam-server is not v4l2 compatible. So, type this into your terminal:
export LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so

2) The supplied applet (/usr/share/doc/webcam-server/applet/) works from outside your LAN only if you change the URL in webcam.html to relfect your ip address.

References:
https://bugs.launchpad.net/ubuntu/+source/webcam-server/+bug/179932
http://www.eroticpenguin.com/content/streamin-video-sure-why-not

Now, the idea is to have Java capture images from the stream on my localhost...

Sunday, March 29, 2009

Hough Lines

I implemented a version of Hough Lines outlined in Trucco & Verri's Introductory Techniques for 3-D Computer Vision. The implementation looks cleaner than all of the popular Google searches on the topic. I also commented it heavily so the algorithm appears extremely transparent. I have not compared it to other algorithms in terms of Big-O complexity or sheer speed.

Saturday, March 28, 2009

Video woes in a JVM world

To aid in the development of OpenJCV's streaming video display capability, I am using a few low-cost webcams. Initially, I planned to use Java's JMF library, but it turns out many webcams do nut work with the library. Next, I turned to a JMF third-party, open-source spin-off called FMJ (surpassed on Google only by Wikipedia's definition for "Full metal jacket"). Admittedly, I only spent a night trying the library with my two webcams, but it didn't work.

What's the solution? Here are the two with which I'm OK:
1) Require the user to add, as an argument, the command for capturing an image from the desired camera. This assumes the user has a program to grab individual frames, store them somewhere on their computer, and manage access between the frame grabber and OpenJCV.
2) Create my own C++ frame grabber to do all of the above. This takes the pressure off the user, but makes things a little less platform independent-- I'll have to find out which platform the user has and do different things for each...

For now, I'm going to implement option 1. Later (6 months to a year), I'll implement option 2.

Tuesday, March 24, 2009

OpenJCV blag

OpenJCV, short for Open Java Computer Vision, is the Java-variant of the popular computer vision library OpenCV. This is the project blog.

The project, as of today, is in an alpha-ish state. Many planned features have not been implemented, though a few base features have been completely implemented and tested. Of course, there may be a few bugs I missed. Here's a brief list of some currently implemented features:
-2D matrices
-ND matrices
-image IO
-window management and image display
-sobel, laplace and canny edge detection

OpenJCV will eventually contain all the functionality of OpenCV and more, but that may take another year or two. Here are a few things to come in the very near future:
-documentation
-a downloadable library (jar)
-video display
-hough transform (lines only)
-histograms
-links to my sourceforge stuff from this blog

Furthermore, I am in need of feedback. What do you want now? What do you want later? Please alpha test and play around with the display functions and computer vision algorithms on different platforms. Send any questions/comments/hate/love to openjcv at hotmail.