/** * Called by the detector to deliver detection results. * If your application called for it, this could be a place to check for * equivalent detections by tracking TextBlocks that are similar in location and content from * previous frames, or reduce noise by eliminating TextBlocks that have not persisted through * multiple detections. */ @Override public void receiveDetections(Detector.Detections<TextBlock> detections) { graphicOverlay.clear(); SparseArray<TextBlock> items = detections.getDetectedItems(); for (int i = 0; i < items.size(); ++i) { TextBlock item = items.valueAt(i); if (item != null && item.getValue() != null) { Log.d("OcrDetectorProcessor", "Text detected! " + item.getValue()); OcrGraphic graphic = new OcrGraphic(graphicOverlay, item); graphicOverlay.add(graphic); } } }
@Override public void receiveDetections(Detector.Detections<TextBlock> detections) { ocrGraphicOverlay.clear(); SparseArray<TextBlock> items = detections.getDetectedItems(); final StringBuilder sb = new StringBuilder(); for (int i = 0; i < items.size(); ++i) { TextBlock item = items.valueAt(i); if (item != null && item.getValue() != null) { Log.d("OcrDetectorProcessor", "Text detected! " + item.getValue()); sb.append(item.getValue()+"\n"); } OcrGraphic graphic = new OcrGraphic(ocrGraphicOverlay, item); ocrGraphicOverlay.add(graphic); } tvOcrResult.post(new Runnable() { @Override public void run() { tvOcrResult.setText(sb.toString()); } }); }
/** * Called by the detector to deliver detection results. * If your application called for it, this could be a place to check for * equivalent detections by tracking TextBlocks that are similar in location and content from * previous frames, or reduce noise by eliminating TextBlocks that have not persisted through * multiple detections. */ @Override public void receiveDetections(Detector.Detections<TextBlock> detections) { mGraphicOverlay.clear(); SparseArray<TextBlock> items = detections.getDetectedItems(); for (int i = 0; i < items.size(); ++i) { TextBlock item = items.valueAt(i); OcrGraphic graphic = new OcrGraphic(mGraphicOverlay, item); mGraphicOverlay.add(graphic); } }
/** * Called by the detector to deliver detection results. * If your application called for it, this could be a place to check for * equivalent detections by tracking TextBlocks that are similar in location and content from * previous frames, or reduce noise by eliminating TextBlocks that have not persisted through * multiple detections. */ @Override public void receiveDetections(Detector.Detections<TextBlock> detections) { mGraphicOverlay.clear(); SparseArray<TextBlock> items = detections.getDetectedItems(); for (int i = 0; i < items.size(); ++i) { TextBlock item = items.valueAt(i); OcrGraphic graphic = new OcrGraphic(mGraphicOverlay, item); mGraphicOverlay.add(graphic); } }