Object detection OOM crash (#1451)

Don't return before we release the object.
This commit is contained in:
Cameron (3539)
2024-10-08 22:01:51 -04:00
committed by GitHub
parent c4b273e737
commit 142e22ff24

View File

@@ -112,15 +112,18 @@ public class RknnObjectDetector implements ObjectDetector {
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()