HOCR_SDK_run
Included header
#include <HOCR_SDK_COMMON.h>
Description
Engine module execution API
HOCR_SDK_run()
|
- Parameters
-
Name Type Description obj void* Pointer to 'ArgoEngineApi' object
resultJson char** Engine module execution result string (JSON)
openApiName char* Name of the engine module to use
requestId char* Request ID (value to identify the request)
imgWidth int Image width
imgHeight int Image height
colorSpace int Image color type
Note: RGB 0, RGBA 1, BGR 2, BGRA 3, YUV 4, GRAY 5
imgData char* Image pixel data
Note: Raw pixel data (bitmap) array already decoded by an image processing library, etc.
requestOptionJsonStr char* JSON string to set options of the engine module obtained via HOCR_SDK_getOpenApiOption
- Return value
int: Length of the ‘resultJson’ string
Examples
- Using the OpenCV library
cv::Mat mat = cv::imread("ocr1.png", cv::IMREAD_COLOR);
char *resultJsonStr = nullptr;
std::string openApiName = "TEXT_RECOGNITION";
std::string requestId = "random-string";
char *dataMat = reinterpret_cast<char*>(temp.data);
std::string requestOptionJsonStr = "{}";
int resultSize = HOCR_SDK_run(
obj,
&resultJsonStr,
openApiName.data(),
requestId.data(),
mat.cols,
mat.rows,
2, /* RGB 0, RGBA 1, BGR 2, BGRA 3, YUV 4, GRAY 5 */
dataMat,
requestOptionJsonStr.data()
);
std::string resultJson(resultJsonStr, resultSize);
Example result JSON
{
"RESULT": [
{
"IS_SUCCESS": true,
"MSG": "",
"REQUEST_INDEX": 0,
"RESULT": {
"page_number": 0,
"image_width": 469,
"image_height": 247,
"image_rotation": 0.0,
"words": [
{
"word_id": 0,
"bbox": [
30,
59,
449,
59,
449,
200,
30,
200
],
"text": "ABC",
"score": "0.998727"
}
],
"lines": [
{
"line_id": 0,
"words_id": [
0
],
"bbox": [
30,
59,
449,
59,
449,
200,
30,
200
],
"text": "ABC"
}
],
"page_text": "ABC"
}
}
],
"REQUEST_TIME": "2025-12-01 17:08:55.769",
"RESPONSE_TIME": "2025-12-01 17:08:56.496"
}