我想在我的应用程序中同时使用图像标记和文本识别。我有以下内容:
fun initAnalyzer(cameraExecutor: Executor) {
imageAnalyzer = ImageAnalysis.Builder().build().also { imageAnalysis ->
imageAnalysis.setAnalyzer(
cameraExecutor,
ImageMLAnalyzer { image, imageProxy, machineLearningUtils ->
textClassifier?.processImageWithText(image,
onSuccess = { result ->
val resultString = processLineText(result)
if (TextRecognitionClassifier.NORESULT !=
resultString &&
!isProcessingImage) {
processAnalyzedResult(resultString)
} else {
imageClassifier?.processImage(image,
onSuccess = { labelProbList ->
val labelResult = processResult(labelProbList)
if (ImageClassifier.NORESULT != labelResult &&
!isProcessingImage) {
openWebView(labelResult)
}
machineLearningUtils.analyzing(false)
imageProxy.close()
}, onFailure = {
machineLearningUtils.analyzing(false)
imageProxy.close()
})
}
machineLearningUtils.analyzing(false)
imageProxy.close()
}, onFailure = {
machineLearningUtils.analyzing(false)
imageProxy.close()
})
})
}
}
我遇到的问题是,首先,这样我并没有真正同时使用它们,其次,当我输入图像检测器时出现错误:
com.google.firebase.ml.common.FirebaseMLException: No image data found.