Now we proceed to first core part of the tutorials, representation of image in Processing and OpenCV. In Processing, the class is PImage. Digital video, Movie and live webcam feed, Capture are also PImage. When we import the external image file from the data folder through loadImage(), the format will usually be RGB. The internal representation is, however, ARGB.
Continue reading
OpenCV and Processing 4 more
This example will demonstrate the use of the Rect class in OpenCV and compare it with the Rectangle class in Java. The Rect class will be useful when we work on the face detection example later. The detected faces will be returned as rectangles.
Continue reading
OpenCV and Processing 4
The Java binding of OpenCV has a number of data classes in the form of MatOfxxx, where xxx is other datatype such as Int, Float, Point. This example will demonstrate the use of MatOfInt class. These classes will usually be used for parameters passing between different OpenCV functions. We can manipulate it similar to array and List.
Continue reading
OpenCV and Processing 3
This example will demonstrate the use of CvType, Size and Scalar.
CvType defines all the matrix types in OpenCV. It describes the number of channels, and depth information for each element (pixel) in the matrix. This example will use CV_8UC1 – 8 bits unsigned char, 1 channel. To communicate with Processing, we usually take CV_8UC4 for ARGB as the RGB format in PImage also uses 4 bytes for storage.
Continue reading
OpenCV and Processing 2
The second example loads the OpenCV library; creates an identity matrix; and print its content in the console window.
Continue reading
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.
Continue reading
Processing Test with the PGraphics
To simplify the use of a dynamic mask with image, I try to use the PGraphics class as an off screen buffer to store the image for a subsequent mask operation. The foreground image is the live video input from the webcam. The mouse drag operation will draw a dynamic mask to reveal the webcam image. It makes use of the fact that the PGraphics class is a subclass of PImage. The mask function can directly take the PGraphics instance as input. Here is a sample screen shot.
Continue reading
Processing Performance Test 2
The second performance test is to compare the performance among three ways to copy from one PImage to another with exactly the same size. The first method uses the PImage.copy function. The second method use the arrayCopy function to copy directly from one pixels array to another. The third method uses a linear loop to traverse the pixels array one by one.
Continue reading
Processing Performance Test 1
I try to compare various methods to handle mainly image-based computer graphics in the Processing environment and publish the results for developers’ reference. The first one is a very straightforward test by comparing two ways to modify all pixels in a single PImage object instance.
The first way is nested loops for x and y dimensions and the second way is to traverse the whole pixels array in one linear loop.
Continue reading