I'm modifying a custom object detector based off this sample provided by google: vision-quickstart I'd like to prevent displaying a detected object altogether if that object doesn't meet a specified confidence level.
Then I modified the code to delete the label text with the following:
// ObjectGraphic.java
private static final float CONFIDENCE_THRESHOLD = 0.50f;
...
for (Label label : object.getLabels()) {
if (label.getConfidence() < CONFIDENCE_THRESHOLD) {continue;}
canvas.drawText...
Label Text Removed but not the bounding/label boxes
Obviously, this is one step in the right direction but not the final objective.
Here's what I found so far:
// ObjectDetectorProcessor.java
@Override
protected void onSuccess(
@NonNull List<DetectedObject> results, @NonNull GraphicOverlay graphicOverlay) {
for (DetectedObject object : results) {
graphicOverlay.add(new ObjectGraphic(graphicOverlay, object));
// commenting this preventing object overlays from being drawn
// possibly add graphicOverlay.remove() based on label.confidence, but how do I do that?
}
}
// GraphicOverlay.java
/** Adds a graphic to the overlay. */
public void add(Graphic graphic) {
synchronized (lock) {
graphics.add(graphic);
}
}
/** Removes a graphic from the overlay. */
public void remove(Graphic graphic) {
synchronized (lock) {
graphics.remove(graphic);
}
postInvalidate();
}
Please let me know if I'm not mentioning anything. I'd be more than willing to provide additional information for your questions.

