OpenCV and Processing 1

This is the beginning of a series of posts related to using OpenCV and Processing in the Linux environment. I built the OpenCV 3.0.0 rc1 in Ubuntu. By putting the 2 files, libopencv_java300.so and opencv-300.jar in the code folder of a sketch, I can use the alpha version 3.0a7 of Processing and the official Java binding of OpenCV together to prepare for the examples of a newly proposed book in image processing and computer vision. I do not use the OpenCV for Processing library by Greg Borenstein, in order to reveal the underlying working mechanism of OpenCV for learning purpose.
 

The Processing codes should work in the OSX and Windows platforms. The latest javadoc I can find online is 2.4.11 that I believe there are significant changes from OpenCV 2 to OpenCV 3. To start with, I try to work on with the modules: core, highgui, imgproc and video first. They correspond to the Java packages

  • org.opencv.core
  • org.opencv.highgui
  • org.opencv.imgproc
  • org.opencv.video

Example 1

import org.opencv.core.Core;
 
void setup() {
  size(640, 480);
  println(Core.VERSION);
  println(Core.NATIVE_LIBRARY_NAME);
}
 
void draw() {
  background(0);
}

 
The console output will be

3.0.0-rc1
opencv_java300

Core.VERSION contains the version identifier of the OpenCV library. Core.NATIVE_LIBRARY_NAME is the native library name where we are going to load before using the OpenCV functions.