This project contains several tools for creating image and video processing applications in Java. It combines GStreamer, OpenCv, and TensorFlow into an interoparable Java system.
The documentation for this project is in its infancy.
Most dependencies will be picked up automatically from maven central but there are two to take note of.
- opencv-packaging which contains scripts for building an packaging OpenCV for use with these libraries. These projects read the native shared libraries out of packaged Jar files. opencv-packaging will build and package OpenCV itself into a jar file.
- dempsy-commons is normally deployed to maven central but will occasionally (like at the time of this writing) have changes required by the projects here. Currently, to build the
master
branch of this project you will also need to build themaster
branch of dempsy-commons.
lib-image
contains the main image processing routines and OpenCv functionality. It contains some decent general purpose classes but also some more esoteric implementations that might be hard to find in other places.
com.jiminger.image.CvRaster
is an alternative (actually, an extention) to the OpenCv JavaMat
. It allows for direct manipulation of the actual data contained in theMat
in a more convenient manner. See the Javadocs forCvRaster
for more information.com.jiminger.image.ImageFile
is a means of loading and writing images to disk. It's more robust than most implemetations since it usesOpenCv
and falls back toImageIO
when that doesn't work.com.jiminger.image.houghspace.Transform
is a generalized Hough Transform. It's written from scratch and doesn't useOpenCv
's who's implementation isn't "generalized" anyway.com.jiminger.image.mjpeg.MJPEGWriter
will take a series of images and write a "Motion JPEG" movie file.com.jiminger.image.TensorUtils
is a lightweight wrapper around TensorFlow. It will eventually grow to a "zero-copy" utility that makes TensorFlow much easier to use from Java. Currently it's not that extensive.
lib-gstreamer
contains a set of utilities to make using Gstreamer much easier from Java. You can construct GStreamer pipelines using a builder pattern, manage resources more easily, and it also contains a BreakoutFilter
that allows the easy processing of video frames from within Java.
gst-breakout
is a native "C" based GStreamer plugin that lib-gstreamer
depends on in order to process video frames from Java using the BreakoutFilter
, See the Javadocs for BreakoutFilter
in lib-gstreamer
.
lib-nr
is an implementation of Powell's method. As a simple example of how to use this library, you pass a function to be minimized to a Minimizer. Suppose I wanted to minimize the simple polynomial (x-2)^2 - 3
. In this case, it's obvious the minimum is at [2, -3]
but if we wanted to use the Minimizer
to determine that we would pass the function to the minimizer and kick it off with an initial value as follows:
final Minimizer m = new Minimizer(x -> ((x[0] - 2.0) * (x[0] - 2.0)) - 3.0);
final double minVal = m.minimize(new double[] { -45.0 });
final double minParam = m.getFinalPostion()[0];
assertEquals(-3.0, minVal, 0.0001);
assertEquals(2.0, minParam, 0.0001);
Powell's method is actually implemented using the algorithm from Numerical Recipes in C and called using JNA. It currently isn't threadsafe but from Java there's a global lock to prevent multiple simultaneous entries. Contributions welcome.
native
is a supporting native C/C++ code for the above projects. It contains:
- The navive code that supports
CvRaster
. - The Numerical Recipes in C implementation of Powell's method which is called from the
Minimizer
inlib-nr
. This implementation's been modified so it can be used recursively and from multuple threads. - C/C++ code for writing a JPEG images into an MJPEG
avi
file written fromMJPEGWriter
inlib-image
- C++ code for performing a Hough Transform used by the
com.jiminger.image.houghspace.Transform
fromlib-image
. - It will eventually contain native code that will support using TensorFlow from Java.
See the TestBedTensorFlow.java class for an example of GStreamer, OpenCv, and TensorFlow put together in a single Java application using the libraries here.
It grew out of an old project from 2004. Details of that old project can be found at S8 and the still working image processing code can be found in the separate github repository s8.
In brief the original project was my attempt to convert my parents library of legacy super-8 mm film to DVD. I have actually got this working and have scanned several 400 foot rolls of film. See the above link for details.