6.7.0 - Alpha16 - 打包应用支持自带离线 Paddle OCR 引擎, 避免依赖插件安装
This commit is contained in:
26
app/src/main/assets-app/sample/OCR/PaddleOCR (内置 API).js
Normal file
26
app/src/main/assets-app/sample/OCR/PaddleOCR (内置 API).js
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @author TonyJiangWJ
|
||||
*/
|
||||
!function internalApiForPaddleOcr() {
|
||||
console.show();
|
||||
|
||||
// 指定是否用精简版模型, 速度较快, 默认为 true
|
||||
let useSlim = false;
|
||||
|
||||
// CPU 线程数量, 实际好像没啥作用
|
||||
let cpuThreadNum = 4;
|
||||
|
||||
let start = new Date();
|
||||
let img = images.read('test.png');
|
||||
let results = ocr.paddle.detect(img, { useSlim, cpuThreadNum });
|
||||
|
||||
toastLog(`识别结束, 耗时: ${new Date() - start}ms`);
|
||||
|
||||
log(`识别结果: ${JSON.stringify(
|
||||
Array.from(results).map((result) => {
|
||||
return { label: result.label, confidence: result.confidence, bounds: result.bounds };
|
||||
}))}`);
|
||||
|
||||
// 回收图片
|
||||
img.recycle();
|
||||
}();
|
||||
Reference in New Issue
Block a user