Skip to main content

runAsync

Description

Asynchronous engine module execution API, results are delivered via callback

runAsync()

void runAsync(void* obj, C_RESULT_CALLBACK callback, char* openApiName, char* requestId, int imgWidth, int imgHeight, int colorSpace, char* imgData, char* requestOptionJsonStr)
Parameters
Name Type Description
objvoid*

'ArgoEngineApi' object pointer

callbackC_RESULT_CALLBACK

Callback function pointer to receive engine module execution results

openApiNamechar*

Set name of engine module to use

requestIdchar*

Request ID (value for request identification)

imgWidthint

Image width

imgHeightint

Image height

colorSpaceint

Image color type (RGB 0, RGBA 1, BGR 2, BGRA 3, YUV 4, GRAY 5)

imgDatachar*

Image pixel data

requestOptionJsonStrchar*

Json format string for setting options of engine module queried by getOpenApiOption

Return Value

None

Example

  • Use OpenCV library
  • Use sample 'ocr1.png'
  • For runAsyncBase64 API, encode 'dataMat' to base64 and input for use
std::string callbackResultJson = "";
void resultCallbackFunc(char* resultJsonStr, int resultJsonLength) {
callbackResultJson = std::string(resultJsonStr, resultJsonLength);
}
cv::Mat temp = cv::imread("ocr1.png", cv::IMREAD_COLOR);
std::string requestOptionJsonStr ={}";
char *dataMat = (char *)temp.data;
char *resultJsonStr = nullptr;
int resultSize = run(obj,
&resultCallbackFunc,
(char *)openApiName.c_str(),
(char *)requestId.c_str(),
temp.cols,
temp.rows,
2,
dataMat,
(char *)requestOptionJsonStr.c_str());