License Plate Recognition
API & SDK

Applications which offer License Plate Recognition functionalities utilise the license plate recognition capabilities and functions of a License Plate Recognition Engine.

The License Plate Recognition Engine (the core recognition module) has an Application Programming Interface (API), which is a series of functions that the application program can use to make the LPR Engine do the difficult work of recognition. It provides an interface between the processes of the application and the core image recognition tasks of license plate recognition.

Automatic License Plate Recognition
The Application and the License Plate Recognition Engine

In order to work with the API - to develop applications using the functions offered by the API - software developers need proper documentation, sample codes and program tools for the API. The collection of this documentation, set of programs and tools are called Software Development Kit (SDK).

The License Plate Recognition Software Development Kit includes everything developers need to write, build, test, and deploy license plate recognition enabled applications.

The basic and essential part of the SDK is the documentation of the API. The documentation contains the exact description of the definitions, functions and variables of the API.

For demonstration purposes we show here a part of the SDK of the CARMEN® License Plate Recognition Engine of Adaptive Recognition Hungary.

The native CARMEN® API provides interface using the C++ programming language to the recognition services of the CARMEN® Recognition Engine.

The API contains a C++ function named cm_findfirst which is responsible for finding and reading the first plate from an image (as there may be more than one).

Below is the documentation of this cm_findfirst function as it can be found in the CARMEN® SDK.

cm_findfirst By calling the cm_findfirst function the application can read a number plate from an image. The function returns the character tips of the number plate, and the text of the plate in ASCII and Unicode string format.
declaration int cm_findfirst(
    gxHANDLE  hanpr,
    const gxIMAGE*  pimage,
    cmNP**  panprresult
)
parameters
hanpr
The gxHANDLE value retrieved by the gx_openmodule function of the gxsd module.
pimage
Points to the gxIMAGE structure which contains the image to be scanned for license plates.
panprresult
Points to the cmNP* pointer which receives the data of the found license plate.The panprresult pointer is allowed to be 0 or the cmNP* pointer retrieved by a previous call of one of the cm_findfirst, cm_findnext or cm_format functions. In both cases the CMANPR module allocates enough memory space for the result if necessary.The application has to free this pointer.If the function returns NULL for the *panprresult pointer it means that no plate is found. (See later the detailed description of this structure.)
Copyright(C) 2007 by ARH Inc.


All functions, definitions and variables of the CARMEN API have the same style of description.

In order to help development work (reduce development time and costs) the SDK should provide well structured sample programs in source code.

The CARMEN SDK provides a very simple, still fully functional sample program in C++. The ready-to-compile sample program captures an image from the video source (this is done by calling the functions of a separate Video Capture Module),reads the license plate from the captured digital image and outputs the result(s) on the screen.

Below is the sample1.cpp C++ source code of the sample1.exe demo program of the CARMEN SDK.

/*
   cmanpr sample1.cpp
*/
 
#include <windows.h>
#include <stdio.h>
#include <conio.h>
#include "gxsd.h"
#include "gxerr.h"
#include "fxvd4.h"
#include "cmanpr.h"
 
//set the int property for the module specified by handle
int setintproperty(gxHANDLE handle,const char* propname,int value)
{
char   v[256];
   itoa(value,v,10);
   return gx_setmoduleproperty(handle,propname,v);
}
 
//get the int property from the module specified by handle
int getintproperty(gxHANDLE handle,const char* propname,int* value)
{
char   v[256];
   if (!gx_getmoduleproperty(handle,propname,v,256)) return 0;
   *value = atoi(v);
   return 1;
}
 
void main(int argc,char *argv[])
{
gxIMAGE   image;      //gxIMAGE object to recognize
   //initialise image
   gx_initimage(&image);
   //if command line parameter is provided, then it is assumed to be either
   // a) the name of the picture file, or
   // b) the channel number
   if (argc == 2)
   {
      argv++;
      if (isdigit(**argv))   // considered as channel number
      {
      gxHANDLE         hcap;      //handle for the fxvd4 module
         //open fxvd4 module
         if (!gx_openmodule(&hcap,"fxvd4","default")) goto error_ret;
         //set the capture settings
         if (!setintproperty(hcap,"channel",atoi(*argv))) goto error_ret;
         if (!setintproperty(hcap,"format",GX_GRAY)) goto error_ret;
         if (!setintproperty(hcap,"xres",50)) goto error_ret;
         if (!setintproperty(hcap,"yres",50)) goto error_ret;
         if (!setintproperty(hcap,"sline",0)) goto error_ret;
 
         //capture an image
         if (!gx_capture(hcap,&image,0))
         {
            gx_closehandle(&hcap);
            goto error_ret;
         }
         //close fxvd4 module
         gx_closehandle(&hcap);
      }
      else // possible the name of a file
      {
         if (!gx_loadimage(&image,*argv,0)) goto error_ret;
      }
      {
      gxHANDLE      hanpr;      //handle for the cmanpr module
      cmNP*         result;      //recognized number plate results
      char         anprname[256]="";   //the name of the engine
      int            nplate = 0;
         //open cmanpr module
         if (!gx_openmodule(&hanpr,"cmanpr","")) goto error_ret;
         if (!gx_getmoduleproperty(hanpr,"anprname",anprname,256)) goto error_ret;
         if (strcmp(anprname,"")) printf("Name of the anpr module: %s\n\n",anprname);
         else
         {
            printf("No engine installed.\n");
            gx_closehandle(&hanpr);
            goto end;
         }
         //read number plates from the image
         result = 0;
         nplate = 0;
         if (!cm_findfirst(hanpr,&image,&result)) goto error_ret;
         while(result)
         {
            printf("Found plate: %s\n",result->text?result->text:"No plate text");
            //write the position of the frame of the plate
            printf("Frame of the plate: (%3i,%3i) - (%3i,%3i)\n",
            result->frame.x1,result->frame.y1,result->frame.x2,result->frame.y2); printf(" | | \n"); printf(" (%3i,%3i) - (%3i,%3i)\n",
            result->frame.x4,result->frame.y4,result->frame.x3,result->frame.y3); //the application must free the result structure gx_globalfree(result); result = 0; nplate ++; if (!cm_findnext(hanpr,&result)) goto error_ret; } if (nplate == 0) printf("No plate found.\n"); //close cmanpr module gx_closehandle(&hanpr); } goto end; error_ret: { char errmsg[256]; //error message int error; //error code gx_geterror(&error,errmsg,256); //obtain error message printf("ErrorCode: 0x%08x - %s\n",error,errmsg); } } else { printf("usage: sample1.exe [channel] or sample1.exe [filename]\n"); } end: gx_freeimage(&image); printf("press any key to exit..."); getch(); printf("\n"); }
Copyright(C) 2007 by ARH Inc.


All functions, definitions and variables of the CARMEN® API have the same style of description.

In order to help development work (reduce development time and costs) the SDK should provide well structured sample programs in source code.

The CARMEN® SDK provides a very simple, still fully functional sample program in C++. The ready-to-compile sample program captures an image from the video source (this is done by calling the functions of a separate Video Capture Module), reads the license plate from the captured digital image and outputs the result(s) on the screen.

Below is the sample1.cpp C++ source code of the sample1.exe demo program of the CARMEN® SDK.