java - cover text inside an image with firebase
问题描述
I'm trying to make sure that all the writings are covered in a preloaded photo. for that im using firebase ml libraries(on-device, not cloud api).
I'm currently trying with the rect and giving it the coordinates that it reads from the block like that:
imageViewArray[i].setRight(blockFrame.right);
imageViewArray[i].setLeft(blockFrame.left);
imageViewArray[i].setTop(blockFrame.top);
imageViewArray[i].setBottom(blockFrame.bottom);
i didnt see any error but nothing change in my app.. where i wrong?
another thing: as i read here getCornerPoint() create a Point[] with the axis x and y about all 4 corners.. can these be useful to me to create an imageview that is placed in the same area?
this is my onStart() in MainActivity:
protected void onStart() {
super.onStart();
FirebaseVisionImage image = FirebaseVisionImage.fromBitmap(bitmap);
FirebaseVisionTextRecognizer textRecognizer = FirebaseVision.getInstance()
.getOnDeviceTextRecognizer();
final Task<FirebaseVisionText> result =
textRecognizer.processImage(image)
.addOnSuccessListener(new OnSuccessListener<FirebaseVisionText>() {
@Override
public void onSuccess(FirebaseVisionText firebaseVisionText) {
// Task completed successfully
Integer i = 0;
resultText = firebaseVisionText.getText();
output = resultText;
tvResult.setText(output);
for (FirebaseVisionText.TextBlock block: firebaseVisionText.getTextBlocks()) {
String blockText = block.getText(); //prende il testo e lo mette nella stringa
Float blockConfidence = block.getConfidence(); //bho
List<RecognizedLanguage> blockLanguages = block.getRecognizedLanguages(); //rileva la lingua
Point[] blockCornerPoints = block.getCornerPoints(); //prende le coordinate della box
Rect blockFrame = block.getBoundingBox();
ImageView[] imageViewArray = new ImageView[50];
imageViewArray[i] = new ImageView(context);
imageViewArray[i].setBackgroundColor(Color.rgb(255, 0, 0));
imageViewArray[i].setRight(blockFrame.right);
imageViewArray[i].setLeft(blockFrame.left);
imageViewArray[i].setTop(blockFrame.top);
imageViewArray[i].setBottom(blockFrame.bottom);
i++;
}
}
})
.addOnFailureListener(
new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
// Task failed with an exception
}
});
}
解决方案
推荐阅读
- python - 如何从 gremlin-python valueMap 访问 id 和 label 值
- jquery - 菜单扩展/收缩时如何将 fa-chevron-up 与 fa-chevron-down 交换并进行转换
- python - 在 AWS Lambda 上运行预先调用的 python 导入和编译函数
- architecture - 显示用于开发解决方案的技术的最佳图表是什么?
- php - PHP:替换数据库中的现有日期
- angular - RxJS - 告诉 observable 等待其他 observable 发出非空值
- javascript - 我怎样才能在 k6 中完成这个测试用例来调用 API 并检查长度
- python - 屏幕管理器 - 我在尝试创建一个管理器以从主窗口转到窗口并返回主窗口时遇到问题,
- javascript - 在 Array.from 中使用函数
- linux - 如何将多个 tar 文件合并为一个 tar 文件