我必须创建一个数独解算器,所以我使用谷歌视觉创建了一个数字识别,用于从grid.This数字识别中检索数字修剪网格以分析每个单元格,但识别不起作用。我认为问题来自于TextRecognizer,他在识别单个字符方面有困难。
你能帮帮我吗?
谢谢。
btnProcess.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
new Thread(new Runnable() {
public void run() {
final StringBuilder stringBuilder = new StringBuilder();
TextRecognizer textRecognizer=new TextRecognizer.Builder(getApplicationContext()).build();
if(!textRecognizer.isOperational()){
Log.e("Error","Detector not available");
}
else {
int largeur = (bitmap.getWidth()) / 9;
int hauteur = (bitmap.getHeight()) / 9;
Bitmap cellule = null;
for (int y = 0; y< 9; y++) {
for (int x = 0; x < 9; x++) {
cellule = Bitmap.createBitmap(bitmap,x*largeur,y*hauteur,largeur,hauteur);
Frame frame = new Frame.Builder().setBitmap(cellule).build();
cellule.recycle();
SparseArray<TextBlock> items = textRecognizer.detect(frame);
if (items.size()==0){
stringBuilder.append("0" + " ");
}
else{
TextBlock item=items.valueAt(0);
stringBuilder.append(item.getValue() + " ");
}
}
stringBuilder.append("\n");
}
}
runOnUiThread(new Runnable() {
public void run() {
txtResult.setText(stringBuilder.toString());
}
});
}
}).start();
};
});发布于 2020-11-09 17:47:09
你说你用的是谷歌视觉的OCR?您可以在以下位置测试google vision api:
在:
试用接口
只需导入您的图像,并查看API是否识别这些数字。只是为了排除使用Google Vision检测这些数字的能力或无能为力。
https://stackoverflow.com/questions/49915680
复制相似问题