Skip to Content
avatar image
Former Member

Regarding usage of Optical Character Recognition (OCR) API

Hi Team,

We were testing this new API (Optical Character Recognition (OCR) API) based on OCR technology and have 2 queries based on functionality/usage.

1.) Its "Try It Out" functionality works for .PDF files and correctly list out the contents as response. But it doesnt behave the same way for .jpeg or png files. The overview details state that it should be behaving the same way for .jpg or .pdf files, but it is not happening correctly.

2.) We are trying to test its functionality from the web full stack ide using the ui5 generated code but are facing some api connectivity issues. We tried to check the connection from the destination created but that too doesnt happen successfully. Is there any specific mapping required to be done so that api could be used.



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Dec 14, 2017 at 07:04 AM

    Hi S.K.

    you can use this code for getting ocr work
    getOCR: function(oEvent) {
    			var sHeaders = {
    				"Accept": "application/json",
    				"APIKey": "Your api key"
    			var url  = "";
    			var data = new FormData();
                           // this is file object
    			data.append('file', this.getView().byId("fileUploader").getFocusDomRef().files[0]);
    			data.append('lang', "en");
    			data.append('output_type', 'txt');
    		onOCRDetectedSuccess: function(data) {
    		onOCRDetectedFailed: function() {
    			var ajaxRequest = {};
    			ajaxRequest.url = /SAP_Leonardo_ML/ocr/ocr;
    			ajaxRequest.method = "POST";
    			ajaxRequest.headers = header; = data;
    			ajaxRequest.processData = false;
    			ajaxRequest.contentType = false;
    			ajaxRequest.cache = false;
    			ajaxRequest.success  = successcallback.bind(this);
    			ajaxRequest.error = failcallback.bind(this);
    Add comment
    10|10000 characters needed characters exceeded

  • Dec 14, 2017 at 04:13 AM

    Hi SK,

    I took screen shot and used the ".png" picture like this text.png and it worked fine.

    I guess the accuracy would depend on the noises in the picture and could you try with the simple pictures with black characters and white background first?

    About the destination, what kind of error did you face?




    Add comment
    10|10000 characters needed characters exceeded