C++ API

The APIs from all other languages are generated from the C++ code using SWIG. It’s straightforward to use the API from different languages based on this documentation as threre are only #3 useful functions.

Sample code for Android using Java could be found here.

The header file to include is defined at https://github.com/DoubangoTelecom/ultimateALPR-SDK/blob/master/c++/ultimateALPR-SDK-API-PUBLIC.h

enum ultimateAlprSdk::ULTALPR_SDK_IMAGE_TYPE

Defines the image types.

Values:

ULTALPR_SDK_IMAGE_TYPE_RGB24

Each pixel is stored on 3 bytes. Each channel (R, G, B) is stored with 8 bits of precision (256 possible values). Here is how the pixels are packed:

const int pixel = (B & 0xff) << 16 | (G & 0xff) << 8 | (R & 0xff);

ULTALPR_SDK_IMAGE_TYPE_NV12

YUV 4:2:0 image with a plane of 8 bit Y samples followed by an interleaved U/V plane containing 8 bit 2x2 subsampled colour difference samples. More information at https://www.fourcc.org/pixel-format/yuv-nv12/

ULTALPR_SDK_IMAGE_TYPE_NV21

YUV 4:2:0 image with a plane of 8 bit Y samples followed by an interleaved V/U plane containing 8 bit 2x2 subsampled chroma samples. The same as ULTALPR_SDK_IMAGE_TYPE_NV12 except the interleave order of U and V is reversed. More information at https://www.fourcc.org/pixel-format/yuv-nv21/

ULTALPR_SDK_IMAGE_TYPE_YUV420P

These formats are identical to YV12 except that the U and V plane order is reversed. They comprise an NxM Y plane followed by (N/2)x(M/2) U and V planes. This is the format of choice for many software MPEG codecs. More information at https://www.fourcc.org/pixel-format/yuv-i420/

ULTALPR_SDK_IMAGE_TYPE_YVU420P

Same as ULTALPR_SDK_IMAGE_TYPE_YUV420P except the order of U and V is reversed. More information at https://www.fourcc.org/pixel-format/yuv-yv12/

ULTALPR_SDK_IMAGE_TYPE_YUV422P

YUV 4:2:2 image with an NxM Y plane followed by (N/2)x(M) V and U planes.

ULTALPR_SDK_IMAGE_TYPE_YUV444P

YUV 4:4:4 image with an NxM Y plane followed by NxM V and U planes.

class UltAlprSdkResult

Result returned by the engine at initialization, deInitialization and processing stages.

Public Functions

int code() const

The result code. 0 if success, nonzero otherwise.

const std::string &phrase() const

Short description for the code.

const std::string &json() const

The license plates as JSON content string. May be null if no plate found.

const size_t numPlates() const

Number of license plates in json string. This is a helper function to quickly check whether the result contains license plates without parsing the json string.

bool isOK() const

Whether the result is success. true if success, false otherwise.

class UltAlprSdkEngine

The Automatic Number/License Plate Recognition (ANPR/ALPR) engine.

Public Static Functions

static UltAlprSdkResult init(const std::string &jsonConfig = "", const UltAlprSdkParallelDeliveryCallback *parallelDeliveryCallback = nullptr)

Initializes the engine. This function must be the first one to call.

Return

a result

Parameters

static UltAlprSdkResult deInit()

DeInitialize the engine. This function must be the last one to be call. Deallocate all the resources allocated using init function.

Return

a result

static UltAlprSdkResult process(const ULTALPR_SDK_IMAGE_TYPE imageType, const void *imageData, const size_t imageWidthInSamples, const size_t imageHeightInSamples, const size_t imageStrideInSamples = 0)

Performs ANPR detection and recognition operations.

Parameters
  • imageType: The image type.

  • imageData: Pointer to the image data.

  • imageWidthInSamples: Image width in samples.

  • imageHeightInSamples: Image height in samples.

  • imageStrideInSamples: Image stride in samples. Should be zero unless your the data is strided.

static UltAlprSdkResult process(const ULTALPR_SDK_IMAGE_TYPE imageType, const void *yPtr, const void *uPtr, const void *vPtr, const size_t widthInSamples, const size_t heightInSamples, const size_t yStrideInBytes, const size_t uStrideInBytes, const size_t vStrideInBytes, const size_t uvPixelStrideInBytes = 0)

Performs ANPR detection and recognition operations.

Parameters
  • imageType: The image type.

  • yPtr: Pointer to the start of the Y (luma) samples.

  • uPtr: Pointer to the start of the U (chroma) samples.

  • vPtr: Pointer to the start of the V (chroma) samples.

  • widthInSamples: Image width in samples.

  • heightInSamples: Image height in samples.

  • yStrideInBytes: Stride in bytes for the Y (luma) samples.

  • uStrideInBytes: Stride in bytes for the U (chroma) samples.

  • vStrideInBytes: Stride in bytes for the V (chroma) samples.

  • uvPixelStrideInBytes: Pixel stride in bytes for the UV (chroma) samples. Should be 1 for planar and 2 for semi-planar formats. Set to 0 for auto-detect.

Fork me on GitHub