代码拉取完成,页面将自动刷新
// 192.168.31.230
const axios = require('axios');
const fs = require('fs');
const url = 'http://192.168.31.230:1224/api/ocr';
const file = fs.readFileSync('2.png');
const b64 = file.toString('base64');
axios
.post(url, { base64: b64 })
.then((response) => {
let data = response.data;
if (data.code === 100) {
data.data.forEach((item) => {
let box = item.box;
console.log(
`识别到的文本:[ ${item.text} ] 左上角坐标${box[0][0]},${box[0][1]} 右下角坐标${box[2][0]},${box[2][1]}`,
);
});
} else if (data.code === 300) {
console.log('base64解码失败');
} else if (data.code === 101) {
console.log('没有识别到文字');
}
})
.catch((error) => {
console.error('识别失败:', error);
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。