我正在为我的应用(https://github.com/CalamityDeadshot/DNAsec)实现OCR,其主题非常具体。
我需要识别由字符“ A”,“ T”,“ G”,“ C”,“-”,“,”,“”组成的单词,但是TextRecognizer只能检测单词,而不能检测字符具有预定义的单词词汇,因此无法识别“ ATGCGC”之类的单词。
如何使用TextRecognizer做到这一点,或者应该使用哪些库呢?
谢谢。
当前,我正在覆盖画布中绘制可识别的文本:
public void draw(Canvas canvas) {
TextBlock text = mText;
if (text == null) {
return;
}
// Checking if the value is of my letters to draw a box around the word
if (text.getValue().equals("A") ||
text.getValue().equals("T") ||
text.getValue().equals("G") ||
text.getValue().equals("C")) {
RectF rect = new RectF(text.getBoundingBox());
rect.left = translateX(rect.left);
rect.top = translateY(rect.top);
rect.right = translateX(rect.right);
rect.bottom = translateY(rect.bottom);
canvas.drawRect(rect, sRectPaint);
}
// Checking if the value is of my letters to draw recognized text
List<? extends Text> textComponents = text.getComponents();
for(Text currentText : textComponents) {
if (currentText.getValue().equals("A") ||
currentText.getValue().equals("T") ||
currentText.getValue().equals("G") ||
currentText.getValue().equals("C")) {
float left = translateX(currentText.getBoundingBox().left);
float bottom = translateY(currentText.getBoundingBox().bottom);
canvas.drawText(currentText.getValue(), left, bottom, sTextPaint);
}
}
}