【发布时间】:2018-11-29 09:18:49
【问题描述】:
我正在使用 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 Kit 的代码:
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 套件。可以在应用程序中更集成的东西(不需要为每张照片采取 3 个动作的东西)可以连接到 ML 套件的在线模式吗?像这样的代码,坚果使用云方法而不是实时:
<MLKitTextRecognition
class="my-class"
width="260"
height="380"
processEveryNthFrame="10"
preferFrontCamera="false"
[pause]="pause"
[torchOn]="torchOn"
(scanResult)="onTextRecognitionResult($event)">
</MLKitTextRecognition>
【问题讨论】:
标签: javascript camera nativescript imagesource firebase-mlkit