Java, Webcam & Linux

In my opinion, the interaction between real world and computers is one of the most exciting part of software development.

To see the world with an electronic eye and be able to add information to reality creating an augmented reality is really amazing.

One of the fields we are strongly focused at Calameda labs is Augmented Reality.

The first problem to overcome is how to retrieve an image from your webcam. I’m a java programmer and I’m a convinced linux user.

In java, to work with the webcam there is a package named Java Media Framework (JMF).

Java Media Framework has two problems:

  • Is outdated: I don’t know why but Sun has forgotten about this project and its last update dates back to 2007.
  • Use video4linux to interact with Linux

I want to spent same extra words to explain better the second point

Linux WebCam Support

Linux provides the webcam support with a kernel module named Video4Linux.

Video4Linux or V4L (for friends) is a hardware abstraction layer for the webcam’s world to applications.

Linux is alive, very alive, and over the years, a new version of the Video4Linux was developed: Video4Linux2 (V4L2 for friend :-)).

Although v4l2 is integrated into the standard kernel a number of drivers don’t support the new v4l2 API yet, so we’ll likely see v4l and v4l2 coexist for some time.

Obviously v4l and v4l2 is not fully compatible and, since JMF was developed at the time of v4l, you cannot use a webcam that supports v4l2 with JMF on Linux.

In other words if you have a recent webcam that the kernel recognized with v4l2 driver is impossible to use with java with JMF.

This is the situation.

The Solution

Fortunately there is a solution: Video4Linux4Java (now you’re exaggerating with the names:-))

As you can read from the site “Video4Linux4Java (v4l4j) is a GPL’d java package providing simple access to the capture interface of the Video4Linux (V4L) API from Java.”

This library supports both V4L and V4L2 devices and it’s easy to integrate in your java code.

I recommend it and maybe in some future article I will show you some piece of code that uses it.

That’s all Folks.

Daniele

Advertisements
Explore posts in the same categories: Augmented Reality, Calameda, Java Media Framework, JMF, Methodologies, V4L, V4L2, V4L4J, Video For Linux, Video For Linux 2

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: