ROC SDK  2.4.0
Scalable Face Recognition Software
roc_example_lpr.c

Source code for examples/roc_example_lpr.c.

/*
* This example application takes a command line input of an image path
* and outputs the license plate recognition (LPR) results.
*
* To compile this example on OS X / Linux (bash):
*
* $ gcc -o roc-example-lpr roc_example_lpr.c -I ../include/ -L ../lib/ -Wl,-rpath,'$ORIGIN/../lib:../lib' -lroc
*
* To compile this example on Windows (Visual Studio Command Prompt):
*
* $ cl roc-example-lpr.c /TP /I ../include/ ../lib/roc.lib /Feroc-example-lpr.exe
*
* To run this application using an example image:
*
* Linux
* $ ./roc-example-lpr ../lib ../data/car.jpg
*
* Windows
* $ .\roc-example-lpr.exe . ..\data\car.jpg
*/
#include <stdio.h>
#include <stdlib.h>
#include "roc.h"
int main(int argc, char *argv[])
{
roc_image image;
roc_template templates[10];
size_t adaptive_minimum_size;
int i;
if (argc != 3)
roc_ensure("Expected two arguments:\n"
#ifdef _WIN32
" > roc-example-lpr.exe path\\to\\rocsdk\bin path\\to\\image.jpg"
#else // !_WIN32
" $ roc-example-lpr path/to/rocsdk/lib path/to/image.jpg"
#endif // _WIN32
);
// Initialize SDK
roc_ensure(roc_initialize(NULL, NULL));
// Detect up to ten words in the image
roc_ensure(roc_read_image(argv[2], ROC_BGR24, &image));
for (i=0; i<10; i++) {
if (!templates[i].algorithm_id) {
if (i == 0)
puts("Failed to detect text in image!");
break;
}
roc_string text, state;
roc_ensure(roc_get_metadata(templates[i], "Text", &text));
roc_ensure(roc_get_metadata(templates[i], "LicensePlateState", &state));
printf("%s State = %s Confidence = %f Center = (%d, %d) Size = (%d, %d)\n", text, state, templates[i].detection.confidence, (int)templates[i].detection.x, (int)templates[i].detection.y, (int)templates[i].detection.width, (int)templates[i].detection.height);
roc_ensure(roc_free_template(&templates[i]));
}
// Cleanup
return EXIT_SUCCESS;
}