I’m trying to create a Nativescript mobile app that gets id information from a Photo of a license,
var data = {“language”: “eng”, “isOverlayRequired”: false, “url” : ‘http://dl.a9t9.com/ocrbenchmark/eng.png’, “iscreatesearchablepdf”: false, “issearchablepdfhidetextlayer” : false, “filetype”: “jpg” };
var settings = {
// “async”: true,
// “crossDomain”: true,
“url”: “https://api.ocr.space/parse/image”,
“method”: “POST”,
“headers”: {
“apikey”: ocrAPI
},
“mimeType”: “application/json”,
“body”: data
}
return httpModule.request(settings)
.then(function (ocrParsedResult) {
console.dir(ocrParsedResult);
console.log(ocrParsedResult.content);
console.log('statusCode: ’ + ocrParsedResult.statusCode);
console.dir(JSON.stringify(ocrParsedResult.headers));
//Get the parsed results, exit code and error message and details
var parsedResults = ocrParsedResult["ParsedResults"];
//var ocrExitCode = ocrParsedResult["OCRExitCode"];
//var isErroredOnProcessing = ocrParsedResult["IsErroredOnProcessing"];
var errorMessage = ocrParsedResult["ErrorMessage"];
//var errorDetails = ocrParsedResult["ErrorDetails"];
//var processingTimeInMilliseconds = ocrParsedResult["ProcessingTimeInMilliseconds"];
console.log(parsedResults);
if (parsedResults) {
var pageText = '';
parsedResults.forEach(function(value) {
var exitCode = value["FileParseExitCode"];
var parsedText = value["ParsedText"];
//var errorMessage = responseBody["ParsedTextFileName"];
//var errorDetails = responseBody["ErrorDetails"];
//var textOverlay = responseBody["TextOverlay"];
switch (+exitCode) {
case 1:
pageText = parsedText;
break;
case 0:
case -10:
case -20:
case -30:
case -99:
default:
pageText += "Error: " + errorMessage;
break;
}
}, this);
// Monta o objeto com os resultados
const result = {
parsedText: pageText,
ocrParsedResult: ocrParsedResult
}
console.log(JSON.stringify(result));
return result;
} else {
// reject(ocrParsedResult);
}
}, function (e) {
console.log("Error: " +e);
});
This is returning the following
{“OCRExitCode”:99,“IsErroredOnProcessing”:true,“ErrorMessage”:[“No file uploaded or URL or base64 provided”],“ErrorDetails”:“”,“ProcessingTimeInMilliseconds”:“99”}
Can anyone help me with this? is the URL to the image in the correct place?