com.google.firebase.functions.FirebaseFunctionsException:不存在图像

问题描述 投票:0回答:2

当我从 kotlin 代码调用函数注释图像时,我得到了 firebase Exception 的响应。 异常消息是===>“com.google.firebase.functions.FirebaseFunctionsException:不存在图像。” 我添加了类似官方文档的代码==>https://firebase.google.com/docs/ml/android/recognize-text 我确保我将图像发送到 firebase 函数。 请问我该如何解决这个问题?

请问我该如何解决这个问题?

android google-cloud-functions text-extraction text-recognition
2个回答
0
投票

我也遇到了同样的问题。我刚刚将 annotateImage 函数更新为 safeSearchDetection

export const annotateImage = functions.https.onCall(async (data, context) => {
  if (!context.auth) {
    throw new functions.https.HttpsError(
      "unauthenticated",
      "annotateImage must be called while authenticated."
    );
  }
  try {
    return await client.safeSearchDetection(data);
  } catch (e) {
    // @ts-expect-error
    throw new functions.https.HttpsError("internal", e.message, e.details);
  }
});

0
投票

我也面临着同样的问题。我按照官方文档的描述做了同样的事情。部署到 Firebase 函数的 index.ts 文件的代码中存在错误。

需要将data对象转换为Json对象,然后将其传递给client.annotateImage(obj)

因为 data 对象以 String 的形式出现。

文件位置:- 视觉注释图像/functions/src/index.ts

export const annotateImage = functions.https.onCall(async (data, context) => {
  if (!context.auth) {
    throw new functions.https.HttpsError(
      "unauthenticated",
      "annotateImage must be called while authenticated."
    );
  }
  var obj = JSON.parse(data); // add this line
  try {
    return await client.annotateImage(obj); // update here
  } catch (e) {
    // @ts-expect-error
    throw new functions.https.HttpsError("internal", e.message, e.details);
  }
});
© www.soinside.com 2019 - 2024. All rights reserved.