2. FOCR SDK Features
Init gateway
Contact us for get app_id
& secret_key
OCRManager.initGateway(appId, secretKey, new IInitGatewayCallback() {
@Override
public void onSuccess() {
}
@Override
public void onFail(@Nullable AppException error) {
}
});
Register OCR callback
After registration, the SDK will return the corresponding status in the callback
onStart
Called at start OCR
onSuccess
Called when return result
onFail
Called when an error occurs in process
OCRManager.registerOCRCallback(new IOCRCallback() {
@Override
public void onStart() {
}
@Override
public void onFail(@Nullable AppException error) {
}
@Override
public void onSuccess(@NonNull OCRData result) {
}
});
Get Config
Get list config used to ocr param
When sucess, result is
listConfig
, it will be called ononSuccess()
in callbackWhen fail, it will called on
onFail()
in callback
OCRManager.getConfig(new IOCRConfigCallback() {
@Override
public void onSuccess(@NonNull List<OCRConfigData> listConfig) {
}
@Override
public void onFail(@Nullable AppException error) {
}
});
Start OCR
Used to start OCR
When successful start, it will be called on
onStart()
in callbackWhen have result
result
will be return ononSuccess
in callback.When fails, it will be processed at callback
onFail()
in callback.
//use file
OCRManager.startOCR(documentType, responseFormat, toMathMl, file);
...
//use file path
OCRManager.startOCR(documentType, responseFormat, toMathMl, absoluteFilePath);
Export OCR data
Used to export data OCR to csv or excel file
exportType
isOCRExportType.CSV
orOCRExportType.EXCEL
When export success
data
will be return ononSuccess
in callback.When fails, it will be processed at callback
onFail()
in callback
OCRManager.export(requestId, exportType, new IExportCallback() {
@Override
public void onSuccess(@NonNull String data) {
}
@Override
public void onFail(@Nullable AppException error) {
}
});
UI Preview OCR data
<ai.ftech.focrsdk.sdk.FOCRView
android:id="@+id/ocrView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Then set OCRData from onSuccess to view
ocrView.setData(ocrData)
Last updated