Skip to content

HOCR_SDK_runAsync

Included header

#include <HOCR_SDK_COMMON.h>

Description

Asynchronous engine module execution API; results are delivered via callback

HOCR_SDK_runAsync()

void HOCR_SDK_runAsync(void* obj, C_RESULT_CALLBACK callback, char* openApiName, char* requestId, int imgWidth, int imgHeight, int colorSpace, char* imgData, char* requestOptionJsonStr)
Parameters
NameTypeDescription
objvoid*

Pointer to 'ArgoEngineApi' object

callbackHOCR_SDK_RUN_RESULT_CALLBACK

Function pointer to receive engine module execution results via callback

openApiNamechar*

Name of the engine module to use

requestIdchar*

Request ID (value to identify the request)

imgWidthint

Image width

imgHeightint

Image height

colorSpaceint

Image color type

Note: RGB 0, RGBA 1, BGR 2, BGRA 3, YUV 4, GRAY 5

imgDatachar*

Image pixel data

Note: Raw pixel data (bitmap) array already decoded by an image processing library, etc.

requestOptionJsonStrchar*

JSON string to set options of the engine module obtained via HOCR_SDK_getOpenApiOption

Return value

None

Examples

  • Using the OpenCV library
cv::Mat mat = cv::imread("ocr1.png", cv::IMREAD_COLOR);

void resultCallbackFunc(char* resultJsonStr, int resultJsonLength) {
std::string callbackResultJson = std::string(resultJsonStr, resultJsonLength);
std::cout << callbackResultJson << std::endl;
}
std::string openApiName = "TEXT_RECOGNITION";
std::string requestId = "random-string";
char *dataMat = reinterpret_cast<char*>(temp.data);
std::string requestOptionJsonStr = "{}";

int resultSize = HOCR_SDK_runAsync(
obj,
&resultCallbackFunc,
openApiName.data(),
requestId.data(),
mat.cols,
mat.rows,
2, /* RGB 0, RGBA 1, BGR 2, BGRA 3, YUV 4, GRAY 5 */
dataMat,
requestOptionJsonStr.data()
);