Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import org.tensorflow.lite.Interpreter;
import org.tensorflow.lite.examples.detection.env.Logger;

import static java.lang.Math.min;

/**
* Wrapper for frozen detection models trained using the Tensorflow Object Detection API:
* github.com/tensorflow/models/tree/master/research/object_detection
Expand Down Expand Up @@ -196,7 +198,7 @@ public List<Recognition> recognizeImage(final Bitmap bitmap) {
// Show the best detections.
// after scaling them back to the input size.
final ArrayList<Recognition> recognitions = new ArrayList<>(NUM_DETECTIONS);
for (int i = 0; i < NUM_DETECTIONS; ++i) {
for (int i = 0; i < min(numDetections[0], NUM_DETECTIONS); ++i) {
final RectF detection =
new RectF(
outputLocations[0][i][1] * inputSize,
Expand Down