After the release of OpenCV 3.4.2, I have prepared the pre-built version of the Java libraries for OSX, Ubuntu, and Windows 8.1 platforms (64 bits). In this release, there is more extensive support for the Java binding. I also packaged the library as the Processing library – CVImage. Please refer to latest book for details. In addition to the optflow contributed library, it also includes additional contributed libraries, such as bgsegm, face, and tracking.
Instead of using the Processing millis() function or the Java Timer class, we can also make use of the relatively new Instant and Duration classes in Java 8. Here is one simple example for demonstration.
The program uses 2 Instant variables: start, end. It computes the time duration between them using the Duration.between() function.
In preparing for the forthcoming book in Processing and OpenCV, I have tried to build the Java binding in OpenCV 3.2. It worked easily for the basic components. Nevertheless, when I included the contribution module – optflow, it failed. After a number of attempts in various platforms, I found it was due to the gen_java.py script in folder opencv-3.2.0/modules/java/generator. I tried to add back the import details for the class DenseOpticalFlow. It worked again. Here is what I patch in the gen_java.py script.
For those who do not want to build it yourselves, you can download a pre-built version of the OpenCV 3.2 Java library. You can use it with Processing immediately. I have tested it with the current Processing at 3.3. It contains the following files for various platforms in 64 bit:
The new Processing 3.0 beta is available in the Processing website for download. There are some changes in the internal operations that we may need to pay attention to in case our programs depend on them.