Difference between revisions of "Tutorial Processing"

From BoofCV
Jump to navigationJump to search
m
m
Line 18: Line 18:
Gradle will ignore this package unless 'core.jar' exists in this directory.  That jar can be found in your Processing installation at process-XXX/core/library/core.jar, where XXX is installed version of processing.  Unfortunately there is no officially supported version of Processing on Maven central so it cannot be automatically installed.  Which is why you have to do this manual hackery.
Gradle will ignore this package unless 'core.jar' exists in this directory.  That jar can be found in your Processing installation at process-XXX/core/library/core.jar, where XXX is installed version of processing.  Unfortunately there is no officially supported version of Processing on Maven central so it cannot be automatically installed.  Which is why you have to do this manual hackery.


Testing has been done using Processing 2.X
Testing has been done using Processing 3.X and no longer works on 2.X


-------
-------
Line 28: Line 28:
== API and Usage Examples ==
== API and Usage Examples ==
Click below for a complete set of usage examples on GitHub:
Click below for a complete set of usage examples on GitHub:
  * [https://github.com/lessthanoptimal/BoofCV/tree/master/integration/processing/examples boofcv/integration/processing/examples]  
  * [https://github.com/lessthanoptimal/BoofProcessing/tree/master/examples BoofProcessing/examples]  


Browsing through those examples is the best way to learn how to use BoofCV in processing.  The interface provided is more object oriented than general BoofCV API and allows for commands to be chained in a sequence.  Consider the example below, contours are found by chaining several commands together; threshold, erode, and contour.  Operations which don't have a nice easy to use interface can also be used.  Just code them up as usual.
Browsing through those examples is the best way to learn how to use BoofCV in processing.  The interface provided is more object oriented than general BoofCV API and allows for commands to be chained in a sequence.  Consider the example below, contours are found by chaining several commands together; threshold, erode, and contour.  Operations which don't have a nice easy to use interface can also be used.  Just code them up as usual.


Consult the [https://github.com/lessthanoptimal/BoofCV/blob/master/integration/processing/README.TXT README.TXT] for instructions on how to build Processing support using Gradle.
Consult the [https://github.com/lessthanoptimal/BoofProcessing/blob/master/README.MD README.MD] for instructions on how to build Processing support using Gradle.


<syntaxhighlight lang="java">
<syntaxhighlight lang="java">
Line 58: Line 58:
   imgBlobs = results.getLabeledImage().visualize();
   imgBlobs = results.getLabeledImage().visualize();


   size(input.width, input.height);
   surface.setSize(input.width, input.height);
}
}



Revision as of 09:04, 9 March 2016

BoofCV provides an easy to use interface tailored for Processing. Don't know what Processing is? Here is a summary taken from its website:

Processing is a programming language, development environment, and online community. Since 2001, Processing has promoted software literacy within the visual arts and visual literacy within technology. Initially created to serve as a software sketchbook and to teach computer programming fundamentals within a visual context, Processing evolved into a development tool for professionals. Today, there are tens of thousands of students, artists, designers, researchers, and hobbyists who use Processing for learning, prototyping, and production.

Installing

The latest stable version of BoofCV can be easily installed into your Processing build environment. No compilation is required.

  • Sketch -> Import Library -> Add Library ...
  • Type "boofcv" into filter
  • Select and click Install button
  • Wait for it to download and you're ready to go!

If you want the bleeding edge code from GitHub then you'll need to compile it yourself. By default Gradle will build the jar for Processing, provided you have set your system up correctly. Instructions are in boofcv/integration/processing/readme.txt, for your convenience it's pasted below:

Gradle will ignore this package unless 'core.jar' exists in this directory. That jar can be found in your Processing installation at process-XXX/core/library/core.jar, where XXX is installed version of processing. Unfortunately there is no officially supported version of Processing on Maven central so it cannot be automatically installed. Which is why you have to do this manual hackery.

Testing has been done using Processing 3.X and no longer works on 2.X


To create the zip package for Processing type 'gradle processingZip' and after a little bit boofcv_processing.zip should appear in integration/processing directory.


API and Usage Examples

Click below for a complete set of usage examples on GitHub:

* BoofProcessing/examples 

Browsing through those examples is the best way to learn how to use BoofCV in processing. The interface provided is more object oriented than general BoofCV API and allows for commands to be chained in a sequence. Consider the example below, contours are found by chaining several commands together; threshold, erode, and contour. Operations which don't have a nice easy to use interface can also be used. Just code them up as usual.

Consult the README.MD for instructions on how to build Processing support using Gradle.

import boofcv.processing.*;
import boofcv.struct.image.*;

PImage imgContour;
PImage imgBlobs;

void setup() {

  PImage input = loadImage("particles01.jpg");

  // Convert the image into a simplified BoofCV data type
  SimpleGray gray = Boof.gray(input,ImageDataType.F32);

  // Threshold the image using its mean value
  double threshold = gray.mean();

  // find blobs and contour of the particles
  ResultsBlob results = gray.threshold(threshold,true).erode8(1).contour();

  // Visualize the results
  imgContour = results.getContours().visualize();
  imgBlobs = results.getLabeledImage().visualize();

  surface.setSize(input.width, input.height);
}

void draw() {
  background(0);
  if( mousePressed ) {
    image(imgBlobs, 0, 0);
  } else {
    image(imgContour, 0, 0);
  }
}