Skip to content

Commit 142e22f

Browse files
authored
Object detection OOM crash (#1451)
Don't return before we release the object.
1 parent c4b273e commit 142e22f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

photon-core/src/main/java/org/photonvision/jni/RknnObjectDetector.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,18 @@ public List<NeuralNetworkPipeResult> detect(Mat in, double nmsThresh, double box
112112
Letterbox scale =
113113
Letterbox.letterbox(in, letterboxed, this.inputSize, ColorHelper.colorToScalar(Color.GRAY));
114114
if (!letterboxed.size().equals(this.inputSize)) {
115+
letterboxed.release();
115116
throw new RuntimeException("Letterboxed frame is not the right size!");
116117
}
117118

118119
// Detect objects in the letterboxed frame
119120
var results = RknnJNI.detect(objPointer, letterboxed.getNativeObjAddr(), nmsThresh, boxThresh);
121+
122+
letterboxed.release();
123+
120124
if (results == null) {
121125
return List.of();
122126
}
123-
letterboxed.release();
124127

125128
return scale.resizeDetections(
126129
List.of(results).stream()

0 commit comments

Comments
 (0)