Pinta Application Programming Interface

Overview
Pinta API enables you to integrate analyzers created in Pinta Trainer to your applications with speed and elegance. Written in C, the API gives you effortless access to analyzers from applications written in practically any programming language. With its built-in parallelization, Pinta API can utilize many processing cores at once and queue asynchronous analysis calls for maximum performance. Blocking calls are also provided for less demanding applications.

Usage
Pinta is composed of two parts: a user interface tool for training and testing a classifier and a programming interface (API). This documentation describes the Pinta API in detail. The documentation is divided into three parts:

As a very short introduction to using the API please consider the following example.

#include <pinta.h>
#include <stdio.h>

int main(int argc, char* argv[])
{
  pinta_engine* engine;
  pinta_classification_result* result;
  int i;
  const char* fileName = argc > 1 ? argv[1] : "image.jpg";

  /* Load classification engine from file */
  engine = pinta_initialize("classifier.cft");
  /* Check that the engine was successfully created and that its type
     is what we expect. */
  if (engine->error != pinta_no_error ||
      engine->type != pinta_classification_type)
    return 1;
  /* Start execution */
  if (pinta_start(engine) != pinta_no_error)
    return 1;
  /* Fetch a measurement synchronously */
  result = (pinta_classification_result*)pinta_analyze_file_wait(engine, fileName);
  if (result != 0)
    {
      for (i=0; i<pinta_get_measurement_count(engine); ++i)
        printf("Measurement %i: %lf\n", i, result->measurements[i]);
    }
  else
    {
      printf("An error occured in analysis. Error code: %d\n", engine->error);
    }
  /* Free memory */
  pinta_free(result);
  pinta_free(engine);
  return 0;
}

To compile the application, pinta.h must be found in the include path. To link, the lib subfolder in the Pinta installation folder must be in the library search path. The application must be linked against pinta.lib on Windows, and against libpinta.so on Unix systems. The Pinta distribution comes with example projects that have the correct settings. Please take a look at the examples folder in the installation.

To run the application, the bin subfolder in the Pinta installation folder must be in PATH on Windows. On Unix, the lib subfolder must be in LD_LIBRARY_PATH.

 REM Windows batch file example
 set PATH="C:\Program Files\Intopii\Pinta\bin";%PATH%

 # Unix shell script example
 export LD_LIBRARY_PATH=~/pinta/lib:$LD_LIBRARY_PATH

Parallel vs. Sequential Operation
In most single-threaded applications, the typical usage sequence is just as shown above: initialize an analysis engine, send an image for analysis, and wait for the results. This technique however poorly utilizes the built-in parallelism in Pinta.

All functions in the Pinta API are thread-safe. That is, you can create an analysis engine in one thread and feed it with asynchronous analysis requests from other threads. Pinta will call a user-supplied call-back function each time an analysis request is finished.


Generated on Fri Dec 4 14:33:03 2009