Commit 530dfb79 authored by Maximilien Cuony's avatar Maximilien Cuony Committed by Maximilien Cuony

Fix memory leaks in GraphSegmentation

parent bd971fd7
...@@ -243,6 +243,8 @@ namespace cv { ...@@ -243,6 +243,8 @@ namespace cv {
} }
} }
} }
free(thresholds);
} }
void GraphSegmentationImpl::filterSmallAreas(Edge *edges, const int &nb_edges, PointSet *es) { void GraphSegmentationImpl::filterSmallAreas(Edge *edges, const int &nb_edges, PointSet *es) {
...@@ -297,6 +299,8 @@ namespace cv { ...@@ -297,6 +299,8 @@ namespace cv {
p[j] = mapped_id[point]; p[j] = mapped_id[point];
} }
} }
free(mapped_id);
} }
void GraphSegmentationImpl::processImage(InputArray src, OutputArray dst) { void GraphSegmentationImpl::processImage(InputArray src, OutputArray dst) {
...@@ -328,6 +332,9 @@ namespace cv { ...@@ -328,6 +332,9 @@ namespace cv {
// Map to final output // Map to final output
finalMapping(es, output); finalMapping(es, output);
free(edges);
delete es;
} }
Ptr<GraphSegmentation> createGraphSegmentation(double sigma, float k, int min_size) { Ptr<GraphSegmentation> createGraphSegmentation(double sigma, float k, int min_size) {
...@@ -351,6 +358,10 @@ namespace cv { ...@@ -351,6 +358,10 @@ namespace cv {
} }
} }
PointSet::~PointSet() {
free(mapping);
}
int PointSet::getBasePoint( int p) { int PointSet::getBasePoint( int p) {
int base_p = p; int base_p = p;
...@@ -376,6 +387,7 @@ namespace cv { ...@@ -376,6 +387,7 @@ namespace cv {
nb_elements--; nb_elements--;
} }
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment