import request from '@/utils/request'
|
|
/**
|
* 上传图片进行OCR识别
|
* @param {FormData} data - 包含file、type和provider的表单数据
|
*/
|
export function recognizeImage(data) {
|
return request({
|
url: '/system/ocr/recognize',
|
method: 'post',
|
data: data,
|
headers: {
|
'Content-Type': 'multipart/form-data',
|
'repeatSubmit': false // 禁用防重复提交检查
|
}
|
})
|
}
|
|
/**
|
* 获取支持的OCR识别类型
|
*/
|
export function getOcrTypes() {
|
return request({
|
url: '/system/ocr/types',
|
method: 'get'
|
})
|
}
|
|
/**
|
* 获取支持的OCR服务提供商
|
*/
|
export function getOcrProviders() {
|
return request({
|
url: '/system/ocr/providers',
|
method: 'get'
|
})
|
}
|
|
/**
|
* 通过URL进行OCR识别
|
* @param {String} imageUrl - 图片URL地址
|
* @param {String} type - 识别类型
|
* @param {String} provider - OCR服务提供商
|
* @param {Array} itemNames - 需要提取的字段名称数组
|
*/
|
export function recognizeByUrl(imageUrl, type, provider, itemNames) {
|
return request({
|
url: '/system/ocr/recognizeByUrl',
|
method: 'get',
|
params: {
|
imageUrl: imageUrl,
|
type: type || 'General',
|
provider: provider || 'ali',
|
itemNames: itemNames
|
}
|
})
|
}
|
|
/**
|
* 提取OCR结果中的目标字段
|
* @param {Object} ocrResult - OCR原始结果
|
*/
|
export function extractFields(ocrResult) {
|
return request({
|
url: '/system/ocr/extractFields',
|
method: 'post',
|
data: ocrResult
|
})
|
}
|