|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#5
|
|||
|
|||
|
Re: Standalone image analysis.
We are trying to use the WPIBinaryImage class as well for finding contour lines. It seems to work well. However, we are struggling to use it continuously.
To us it appears that there is a huge native memory leak (something inside the native code) when the findContours() method actually finds contour lines. Could you tell me whether or not your code includes a line like the following (where findBin is instance of a WPIBinaryImage)? Code:
WPIContour[] contours = finalBin.findContours(); We've found that we can process a few images without issues, but if we try to run continuously (processing hundreds of frames), our process hits 1 GB of RAM usage and quickly continues to grow until memory is exhausted. We don't seem to hit the memory issue if we don't use the findContours() method, or if the findContours() method doesn't locate anything (memory usage only appears to explode when contours are found). In any case, I'd be curious to know if you've run across this issue as well and if so how you worked around it. Here's our "do nothing" minimal vision processing code which demonstrates the memory leak using only the WPI classes and methods: Code:
package com.techhounds.camera;
import edu.wpi.first.smartdashboard.camera.WPICameraExtension;
import edu.wpi.first.wpijavacv.WPIBinaryImage;
import edu.wpi.first.wpijavacv.WPIColorImage;
import edu.wpi.first.wpijavacv.WPIContour;
import edu.wpi.first.wpijavacv.WPIGrayscaleImage;
import edu.wpi.first.wpijavacv.WPIImage;
/**
* A "trivial" SmartDashboard camera extension demonstrating the memory
* leak issue in the
*
* @author pkb
*/
public class MemoryLeakExtension extends WPICameraExtension {
@Override
public WPIImage processImage(WPIColorImage colorImg) {
// Pull out one color
WPIGrayscaleImage grayImg = colorImg.getBlueChannel();
// Reduce to black and white for contour tracing
WPIBinaryImage binImg = grayImg.getThreshold(200);
// Find the contours within the image (unfortunately memory
// is leaked big time as soon as it starts finding contours)
WPIContour[] contours = binImg.findContours();
// Let the dash board display the gray image
return grayImg;
}
}
Paul |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|