![](/img/trans.png)
[英]Nativescript core Firebase ML kit offline text recognition vertical
[英]Nativescript core convert imageAsset into Imagesource ML kit and camera interface
我正在使用Nativescript核心和帶nativescript-camera插件的firebase ML套件進行文本識別的在線版本(我不知道是否有更好的插件)
目前,我對此事件有一個看法:
exports.onCapture = function () {
if (camera.isAvailable()) {
var options = { width: 300, height: 300, keepAspectRatio: false, saveToGallery: false};
camera.takePicture(options)
.then(function (imageAsset) {
getTextFromPhotoCloud("HOW TO CONVERT imageAsset TO IMAGESOURCE");
}).catch(function (err) {
console.log("Error -> " + err.message);
});
}
}
以及ml套件的以下代碼:
function getTextFromPhotoCloud(imageSource) {
var firebase = require("nativescript-plugin-firebase");
firebase.mlkit.textrecognition.recognizeTextCloud({
image: imageSource
}).then(function (result) {
console.log(result.text ? result.text : "");
}).catch(function (errorMessage) {
return console.log("ML Kit error: " + errorMessage);
});
}
如何將相機響應轉換為圖像源格式(對於ML套件)而不保存在圖庫中?
是否有更好的相機插件或其他產品? 實際上,我必須啟動相機應用程序,拍照並接受預覽才能啟動ML工具包。 可以在應用程序中集成一些可以連接到ML工具包在線模式的東西(不需要為每張照片執行3個操作)嗎? 像這樣的代碼,有點不能使用雲方法,而不是實時:
<MLKitTextRecognition
class="my-class"
width="260"
height="380"
processEveryNthFrame="10"
preferFrontCamera="false"
[pause]="pause"
[torchOn]="torchOn"
(scanResult)="onTextRecognitionResult($event)">
</MLKitTextRecognition>
在圖像源中使用fromAsset
方法。
import { fromAsset } from "tns-core-modules/image-source"
fromAsset(imageAsset).
then((imageSource) => {
.....
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.