#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
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.