I tried running my own vision code on our new Galaxy S5 phones but it was crashing after about 25 seconds, so I opened up the memory profiler and saw that the memory usage was rapidly climbing to 1GB, at which point the phones crashed.
I tried running both the example code and a blank OpenCVPipeline (processFrame() was just "return rgba;") and still ran into the issue.
In order to resolve this I made the following edits to OpenCVPipeline.java:
I turned rgba and gray in onCameraFrame() in OpenCVPipeline into member variables and added another member variable called res which is a Mat
Initialized all three to new Mat() at the beginning of the class
then in onCameraFrame() I do rgba.release(); gray.release(); res.release();
I reinitialize rgba and gray to new Mat()
Set res = processFrame(rgba, gray) in onCameraFrame() just above the return statement in order to maintain a reference to that Mat
Returned res
Based on a discussion with several other programmers on Discord, we believe this may be because the Java Garbage Collector collects the Java references to the Mats but does not trigger deletion of the Mats themselves in the native code.
I tried running my own vision code on our new Galaxy S5 phones but it was crashing after about 25 seconds, so I opened up the memory profiler and saw that the memory usage was rapidly climbing to 1GB, at which point the phones crashed.
I tried running both the example code and a blank OpenCVPipeline (processFrame() was just "return rgba;") and still ran into the issue.
In order to resolve this I made the following edits to OpenCVPipeline.java:
Based on a discussion with several other programmers on Discord, we believe this may be because the Java Garbage Collector collects the Java references to the Mats but does not trigger deletion of the Mats themselves in the native code.
Thanks, Derek Guo FTC Team 8375 Programmer