zl程序教程

您现在的位置是:首页 >  云平台

当前栏目

小程序ocr通过二进制上传识别出错openapi.ocr.vehicleLicense:fail media data missing

识别上传程序二进制 通过 Data 出错 missing
2023-09-11 14:19:38 时间

 

 

// item 为 chooseImage 返回的图片 path
let buffer = wx.getFileSystemManager().readFileSync(item)
 
wx.cloud.callFunction({
    name:'printedTextOCR',
    data: { buffer }
}).then(
    r => {
        console.log(r)
    }
)
 
// 云函数
const cloud = require('wx-server-sdk')
 
cloud.init()
 
exports.main = async (event, context) => {
 
  return await cloud.openapi.ocr.printedText({
    type:'photo',
    img: {
      contentType:'image/jpg',
      value: event.buffer
    }
  }).then(r => r).catch(e => e)
}

报如下错误:

errCode: 41005,
errMsg:"openapi.ocr.printedText:fail media data missing hint: [Jo03914741]"

更新:云函数图片的二进制数据如下:

value: Buffer.from(event.buffer)

 

 

 

转 : https://developers.weixin.qq.com/community/develop/doc/000e0a8ba305f067ac397176b56800