Author Archives: bryan

TensorFlow in Processing

The Java binding for the Google Deep Learning library, TensorFlow is now available. The binary library files for version 1.1.0-rc1 ¬†are also available for download here. Below is the code for the Hello World program included in the distribution that I modified for Processing.   import org.tensorflow.Graph; import org.tensorflow.Session; import org.tensorflow.Tensor; import org.tensorflow.TensorFlow;   Graph [...]

Posted in Research, Software | Tagged , | Leave a comment

OpenCV 3.2 Java Build

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

Posted in Books, Research, Software | 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 [...]

Posted in Software, Testing | Tagged , , | Comments closed

Save Processing screen as video with jCodec – new

It may not be easy for readers to get the old jcodec-0.1.5.jar for what I have done in the last post. I tried to work out for a newer solution but found that the latest version did change quite a lot. The latest jcodec source is 0.2.0. I built the latest two files for the [...]

Posted in Research, 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 [...]

Posted in Research, Software, Testing | Tagged , , , | Comments closed

Searching in Weka with Processing

Further to the last Weka example, I used the same CSV data file for neighbourhood search. By pressing the mouse button, it generated a random sequence of numbers between 1 to 4. The program used the sequence as an instance to match against the database from the CSV data file. The closet match will be [...]

Posted in Research, Software | Tagged , , | Comments closed

First trial of Weka in Processing

Instead of using the machine learning module (ML) of OpenCV, I also investigated another popular machine learning library for Java, Weka, from the University of Waikato. The first trial was to load an external CSV file into the proper data structure of the Weka library. The content of the CSV file is as follows. The [...]

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

Posted in Research, Software, Testing | 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 [...]

Posted in Software, Testing | 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))); The first [...]

Posted in Software, Testing | Tagged , | Comments closed