Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Cloud Vision API send response "com.google.firebase.functions.FirebaseFunctionsException: No image "

Hi,

I am newbie in Cloud Vision Api and using it for my android app development to translate urdu text from image but everytime I hit my firebase function i get exception as "com.google.firebase.functions.FirebaseFunctionsException: No image present."  However I've decoded my base64 encoded image and found correct image.

I am going crazy finding solution of what went wrong as i followed firebase documentation.

https://firebase.google.com/docs/ml/android/recognize-text?_gl=1*15xzslq*_up*MQ..*_ga*NDc3MTU1MjQ0Lj...

Anyone can please provide a solution of it.

Here is my firebase cloud function code in index.js:

 
const functions = require("firebase-functions");
const vision = require("@google-cloud/vision");
 
 
const client = new vision.ImageAnnotatorClient();
 
exports.annotateImage = functions.https.onCall(async (data, context) => {
if (!context.auth) {
throw new functions.https.HttpsError(
"unauthenticated",
"annotateImage must be called while authenticated."
);
 
}
console.log("data "+data)
logger.log("dataRequest"+data)
try {
logger.log("parseDataRequest"+JSON.parse(data))
return await client.annotateImage(JSON.parse(data)); // I've tried removing JSON.parse but same exception occurred.
} catch (e) {
throw new functions.https.HttpsError("internal", e.message, e.details);
}
});

And my android end request format : 

{
"image": {
"content": "/9j/4AAQ........(base64image)=="
},
"features": [
{
"type": "TEXT_DETECTION"
}
],
"imageContext": {
"languageHints": [
"ur"
]
}
}

Thank you in advance for providing the solution. Have a great day!!!.

 

1 0 391
0 REPLIES 0