Skip to content

Commit

Permalink
Object detection OOM crash (PhotonVision#1451)
Browse files Browse the repository at this point in the history
Don't return before we release the object.
  • Loading branch information
Juniormunk authored Oct 9, 2024
1 parent c4b273e commit 142e22f
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,18 @@ public List<NeuralNetworkPipeResult> detect(Mat in, double nmsThresh, double box
Letterbox scale =
Letterbox.letterbox(in, letterboxed, this.inputSize, ColorHelper.colorToScalar(Color.GRAY));
if (!letterboxed.size().equals(this.inputSize)) {
letterboxed.release();
throw new RuntimeException("Letterboxed frame is not the right size!");
}

// Detect objects in the letterboxed frame
var results = RknnJNI.detect(objPointer, letterboxed.getNativeObjAddr(), nmsThresh, boxThresh);

letterboxed.release();

if (results == null) {
return List.of();
}
letterboxed.release();

return scale.resizeDetections(
List.of(results).stream()
Expand Down

0 comments on commit 142e22f

Please sign in to comment.