Category Archives: Testing

Java and time with Processing

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. import […]

Posted in Testing | Tagged , , | Comments closed

Screen capture in Processing

This sketch demonstrates the use of the Robot class in Java to perform screen capture in Processing. It will create Jodi like effect with feedback in computer screen. Have fun with it. Here are the codes. It makes use of the Robot class.   import java.awt.Robot; import java.awt.image.BufferedImage; import java.awt.Rectangle;   Robot robot;   void […]

Also posted in Software | Tagged , , | Comments closed

Save video in Processing with JCodec

As a side product of current research, I manage to save a Processing screen in an MP4 video file with the use of the JCodec library. Download the former¬†jcodec-0.1.5.jar into the code folder of your Processing sketch. The simplest way is to use the SequenceEncoder class to add a BufferedImage to the MP4 video. Remember […]

Also posted in Research, Software | Tagged , , , | Comments closed

Artificial Neural Network in OpenCV with Processing

This is the first trial of the Machine Learning module, artificial neural network in OpenCV with Processing. I used the same OpenCV 3.1.0 Java built files. The program took the live stream video (PImage) from webcam and down-sampled to a grid of just 8 x 6 pixels of greyscale. It started by default in the […]

Also posted in Research, Software | Tagged , , | Comments closed

Enumerate all files in the data folder of Processing

There are lots of ways to enumerate all the files inside the data folder of Processing sketch. Here are 2 of them. The first one uses the Java DirectoryStream class. The second one uses the static function walkFileTree from the Files class.   Example with DirectoryStream try { DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get(dataPath(""))); for (Path file […]

Also posted in Software | Tagged | Comments closed

Looping through a List in Processing

Here is a piece of demonstration code to use various ways to loop through a List or ArrayList in Processing, i.e. Java. The first two examples use for loop and the third one uses the while loop.   We initialize the ArrayList with random integers. ArrayList<Integer> iList = new ArrayList<Integer>(); iList.add(floor(random(10))); iList.add(floor(random(10))); iList.add(floor(random(10)));ArrayList<Integer> iList = […]

Also posted in Software | Tagged , | Comments closed

Processing with OCR

This is a short Processing sketch to demonstrate the use optical character recognition (OCR) with the Tesseract OCR engine. I used the Mac OSX platform for testing. Here are the steps.

Also posted in Software | Tagged , | Comments closed

Processing 3.0 Beta 1

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. Here is a sketch with 2D graphics, I try to list out those internal hidden variables and functions, especially […]

Also posted in Software | Tagged , | Comments closed

Load external class in Processing

It is a short side project away from the OpenCV and Processing thread. In this example, I would like to see if I can load an external class within a Processing sketch. The structure of the program is:

Posted in Testing | Tagged | Comments closed

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 […]

Posted in Testing | Tagged , | Comments closed