Difference between revisions of "Tutorial Videos and Webcams"

From BoofCV
Jump to navigationJump to search
m
m
Line 1: Line 1:
= Videos and Webcams in BoofCV =
BoofCV focuses on image processing and computer vision algorithms and for the most part relies on other libraries for input and output.  For example, BoofCV does not define GUI widgets but uses Swing instead.  The same philosophy applies to capturing images from videos and webcams.  Unfortunately the built in support that Java provides for reading videos and webcams is very limited.
BoofCV focuses on image processing and computer vision algorithms and for the most part relies on other libraries for input and output.  For example, BoofCV does not define GUI widgets but uses Swing instead.  The same philosophy applies to capturing images from videos and webcams.  Unfortunately the built in support that Java provides for reading videos and webcams is very limited.



Revision as of 19:10, 5 December 2012

BoofCV focuses on image processing and computer vision algorithms and for the most part relies on other libraries for input and output. For example, BoofCV does not define GUI widgets but uses Swing instead. The same philosophy applies to capturing images from videos and webcams. Unfortunately the built in support that Java provides for reading videos and webcams is very limited.

The only video format which BoofCV natively supports is MJPEG and image sequence. MJPEG is a very simple video format that is for the most part a series of JPEG images concatenated together. MJPEG's inclusion in BoofCV is primarily to provide video support in applets. Support is also provided for reading image sequences from directories.

Third party libraries are required for reading webcams or other video formats. Support for these third party libraries can be found in the 'boofcv/integration' directory. Currently wrappers are only provided for Xuggler. Libraries which are not 'supported' can still be used easily with BoofCV, you just need to convert the output image (typically a BufferedImage) into a BoofCV style image.

Converting to MJPEG

To read a video and not mess with third party libraries the easiest way to do so is convert the video to MJPEG. The easiest way in Linux to create an MJPEG from some other video format is using ffmpeg. Below is a command line example.

ffmpeg -i FILENAME -sameq example.mjpeg

Other flags can be added to resize the image or adjust image quality. There are a few videos where ffmpeg will produce an MJPEG which BoofCV cannot read, but this is not common.

Xuggler Integration

Xuggler support is still being worked on to make the API easier to deal with. To read a video using the SimpleImageSequence interface use XugglerSimplified. For example:

SimpleImageSequence<ImageFloat32> videoLeft =
   new XugglerSimplified<ImageFloat32>("FileName.avi", ImageFloat32.class);

Be sure to correctly setup all the classpaths for Xugger and to include the BoofCVXuggler.jar in your classpath. BoofCVXuggler.jar can be downloaded online or compiled yourself using ant scripts provided in 'boofcv/integration/xuggler'.

See also integration JavaDoc

Bumblebee2 Stereo Camera in Linux

I also wrote a Java wrapper for Bumblebee2 stereo cameras which does not rely on any code from PtGrey, which in the past has had poor support for Linux. You can checkout the source code from github using the link below:

https://github.com/lessthanoptimal/JBumblebee

Other Options

The easiest way to integrate a 3rd party library with BoofCV is to read in a frame as a BufferedImage, then convert it into a native BoofCV image format using ConvertBufferedImage. An alternative is to write a wrapper that implements SimpleImageSequence, which is used by several examples.

Video Libraries

Webcams

If you know of some other options please post a message to BoofCV's message board (see sidebar link) letting us know about it! Especially if you have suggestions for Windows and MacOS.