习题上传:扫描识别url修改
This commit is contained in:
parent
436bdfe7c8
commit
c01a29bf3f
|
@ -1,6 +1,7 @@
|
||||||
import { ElMessageBox, ElMessage } from "element-plus";
|
import { ElMessageBox, ElMessage } from "element-plus";
|
||||||
import qs from "qs";
|
import qs from "qs";
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
import request from '@/utils/request'
|
||||||
import { pyOCRAPI } from "@/api/education/entpcoursework";
|
import { pyOCRAPI } from "@/api/education/entpcoursework";
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,6 +17,13 @@ const baidubceConfig = {
|
||||||
'client_secret': 'oWb0M0YWMmZPMQIhIUkJX99ddr7h61qf',
|
'client_secret': 'oWb0M0YWMmZPMQIhIUkJX99ddr7h61qf',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function getOcrContent(data) {
|
||||||
|
return request({
|
||||||
|
url: '/ocr/exam',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -226,30 +234,36 @@ const ocrImg2Json = async (urlBase64) => {
|
||||||
ElMessage.error("未检测到截图图片, 请截取图片后再识别");
|
ElMessage.error("未检测到截图图片, 请截取图片后再识别");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const resToken = await bdyAPI_getToken();
|
|
||||||
if (resToken.status !== 200) {
|
|
||||||
ElMessage.error("百度智能云用户标识有误");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const token = resToken.data?.access_token;
|
|
||||||
let base64Code = urlBase64.split(",")[1];
|
let base64Code = urlBase64.split(",")[1];
|
||||||
const query = {
|
const resOcr = await getOcrContent({ base64Code: base64Code });
|
||||||
image: base64Code, //图片地址(base64)
|
if (resOcr.code !== 200) {
|
||||||
line_probability: false, //是否返回每行识别结果的置信度。默认为false
|
ElMessage.error("图片识别错误");
|
||||||
disp_line_poly: false, //是否返回每行的四角点坐标。默认为false
|
|
||||||
words_type: 'handprint_mix', //文字类型。 默认:印刷文字识别 = handwring_only:手写文字识别 = handprint_mix: 手写印刷混排识别
|
|
||||||
layout_analysis: false, //是否分析文档版面:包括layout(图、表、标题、段落、目录);attribute(栏、页眉、页脚、页码、脚注)的分析输出
|
|
||||||
recg_long_division: false, //是否检测并识别手写竖式
|
|
||||||
recg_formula: true, //控制是否检测并识别公式,默认为false
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const resOcr = await bdyAPI_getOcrContent(token, base64Code, query);
|
|
||||||
if (resOcr.status !== 200) {
|
|
||||||
ElMessage.error("百度智能云图片识别错误");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
// const resToken = await bdyAPI_getToken();
|
||||||
|
// if (resToken.status !== 200) {
|
||||||
|
// ElMessage.error("百度智能云用户标识有误");
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// const token = resToken.data?.access_token;
|
||||||
|
// let base64Code = urlBase64.split(",")[1];
|
||||||
|
// const query = {
|
||||||
|
// image: base64Code, //图片地址(base64)
|
||||||
|
// line_probability: false, //是否返回每行识别结果的置信度。默认为false
|
||||||
|
// disp_line_poly: false, //是否返回每行的四角点坐标。默认为false
|
||||||
|
// words_type: 'handprint_mix', //文字类型。 默认:印刷文字识别 = handwring_only:手写文字识别 = handprint_mix: 手写印刷混排识别
|
||||||
|
// layout_analysis: false, //是否分析文档版面:包括layout(图、表、标题、段落、目录);attribute(栏、页眉、页脚、页码、脚注)的分析输出
|
||||||
|
// recg_long_division: false, //是否检测并识别手写竖式
|
||||||
|
// recg_formula: true, //控制是否检测并识别公式,默认为false
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// const resOcr = await bdyAPI_getOcrContent(token, base64Code, query);
|
||||||
|
// if (resOcr.status !== 200) {
|
||||||
|
// ElMessage.error("百度智能云图片识别错误");
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
|
||||||
return resOcr;
|
return resOcr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue