ocr - Nativescript : 带有 nativescript-ocr 的相机照片资源
问题描述
我正在尝试使用 nativescript 相机模块拍照并在其上运行 nativescript-ocr 模块(https://github.com/EddyVerbruggen/nativescript-ocr)。
这是我的代码:
public saveToGallery: boolean = true;
public keepAspectRatio: boolean = true;
public width: number = 300;
public height: number = 300;
private ocr: OCR;
constructor() {
this.ocr = new OCR();
}
ngOnInit(): void {
}
onTakePhoto() {
let options = {
width: this.width,
height: this.height,
keepAspectRatio: this.keepAspectRatio,
saveToGallery: this.saveToGallery
};
takePicture(options).
then((imageAsset) => {
console.log("Result is an image asset instance");
let img: ImageSource = new ImageSource();
img.fromAsset(imageAsset).then((success) => {
if (success) {
this.ocr.retrieveText({
image: img,
whitelist: "ABCDEF",
blacklist: "0123456789",
onProgress: (percentage: number) => {
console.log(`Decoding progress: ${percentage}%`);
}
}).then(
(result: RetrieveTextResult) => {
console.log(`Result: ${result.text}`);
}, (error: string) => {
console.log(`Error: ${error}`);
})
}
});
}).catch((err) => {
console.log("Error -> " + err.message);
});
}
onRequestPermissions() {
requestPermissions();
}
}
相机插件工作正常,拍摄并保存照片,但是当我运行 onTakePhoto 时,我收到以下错误消息:
“ocr.retrieveText 中的错误:错误:java.lang.IllegalArgumentException:数据路径不存在!”
我不确定以正确的方式使用 .fromAsset,但我尝试了很多方法来解决这个问题
我做错了什么?
解决:我没有正确创建我的 tesseract/tessdata 文件夹
解决方案
推荐阅读
- r - 在 R 的 Hunspell 词典中手动添加自定义单词
- c# - 如何注册
- maven - mvn clean install -U 和 eclipse 项目之间的区别 => Maven => 更新项目
- php - Wordpress 永久链接和 Apache 未找到或无法统计,引用者
- angular - 如何在 Highcharts 中显示 csv 数据?
- android - Android pjsip:第一个传入视频呼叫提供 CallmediaInfo 状态 PJSUA_CALL_MEDIA_NONE
- stripe-payments - 测试手动确认 Stripe 的 PaymentIntent
- javascript - JavaScript:为什么“1”-“1”会返回 0?
- javascript - 网站未读取正确的本地 json
- javascript - 将 JSZip 对象转换为 ArrayBuffer 的最佳方法是什么?