cancel
Showing results for 
Search instead for 
Did you mean: 

Recognize text using OCR in RPA

0 Kudos

Hello everybody,

I want to use OCR to recognize text from a file or image in RPA.

In the added custom task, the Call for OCR Service API was created, but I cannot understand how I can upload the file for this request (ctx.ajax.call).

I want to add it to the "data" parameter.

1.
var model = {
lang: "en, de",
outputType: "txt",
pageSegMode: "1",
modelType: "lstmStandard",
files: "C: .... \ Screenshot_1.png"};


ctx.ajax.call({...
data: model,
...});  

But when I add it to json, I get an error and the OCR service cannot find the “files” parameter.

2.
var form = new FormData ();
  form.append ("files", "/C:....Screenshot_1.png");

ctx.ajax.call({...
data: form,
...});  

When I add it to “FormData” (as in the Doku API from api.sap.com), this is impossible (the error is “ErrorType FormData not defined”).

Kindly help or suggest.

Accepted Solutions (1)

Accepted Solutions (1)

Jerome
Advisor
Advisor
0 Kudos

Hi,

To upload a file, you can use the following example :

ctx.ajax.call({
  url: 'https://...',
  method: e.ajax.method.post,
  formData: {
     name: 'files', file: 'C:\\Temp\\Capture.png'
  },
  contentType: e.ajax.content.form,
  success: function(res, status, xhr) {
    sc.endStep(); // Custom
    return;
  },
  error: function(res, status, xhr) {
    ctx.log(' ctx.ajax.call  error: ' + res);
    rootData.MyData.content = res;
  }
});

You will need to adapt it to the service you want to use.

Regards,

J.

Answers (0)