Salome HOME
Fix memory leaks
[modules/geom.git] / src / ShapeRecognition / ShapeRec_FeatureDetector.cxx
index b61f4bc905df5426ecab7c578b9b7840a99ca210..4d3adaa3b0034b3c2997c5a4bb9cb116216c8664 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -59,7 +59,8 @@ void ShapeRec_FeatureDetector::SetPath( const std::string& thePath )
   {
     IplImage* src = cvLoadImage(imagePath.c_str(),CV_LOAD_IMAGE_COLOR);
     imgHeight = src->height;
-    imgWidth = src->width; 
+    imgWidth = src->width;
+    cvReleaseImage(&src);
   }
 }
 
@@ -227,7 +228,6 @@ bool ShapeRec_FeatureDetector::ComputeContours( bool useROI, ShapeRec_Parameters
     cvReleaseImage(&sample_h_plane);
     cvReleaseImage(&sample_s_plane);
     cvReleaseImage(&input_image);
-    cvReleaseImage(&input_image);
     cvReleaseImage(&input_hsv);
     cvReleaseImage(&input_hplane);
     cvReleaseImage(&input_splane);
@@ -294,6 +294,9 @@ std::string ShapeRec_FeatureDetector::CroppImage()
   
   cvSaveImage ("/tmp/cropped_image.bmp", cropped_image);
   
+  cvReleaseImage(&src);
+  cvReleaseImage(&cropped_image);
+  
   return "/tmp/cropped_image.bmp";
 }