mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-26 17:30:35 +05:00
BUG: Shape recognition: Fixed some memory leaks
This commit is contained in:
parent
1d52aa3422
commit
50ac82e2be
@ -327,7 +327,7 @@ EntityGUI_FeatureDetectorDlg::EntityGUI_FeatureDetectorDlg( GeometryGUI* theGeom
|
||||
// mainFrame()->GroupBoxName->hide();
|
||||
|
||||
// Build an instance of detection used to perform image processing operations
|
||||
aDetector = new ShapeRec_FeatureDetector();
|
||||
myDetector = new ShapeRec_FeatureDetector();
|
||||
|
||||
setHelpFileName( "shape_recognition_page.html" );
|
||||
|
||||
@ -341,7 +341,7 @@ EntityGUI_FeatureDetectorDlg::EntityGUI_FeatureDetectorDlg( GeometryGUI* theGeom
|
||||
//=================================================================================
|
||||
EntityGUI_FeatureDetectorDlg::~EntityGUI_FeatureDetectorDlg()
|
||||
{
|
||||
|
||||
delete myDetector;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
@ -447,9 +447,9 @@ void EntityGUI_FeatureDetectorDlg::SelectionIntoArgument()
|
||||
return ;
|
||||
|
||||
// Setting the image caracteristics
|
||||
aDetector->SetPath( theImgFileName );
|
||||
height = aDetector->GetImgHeight();
|
||||
width = aDetector->GetImgWidth();
|
||||
myDetector->SetPath( theImgFileName );
|
||||
height = myDetector->GetImgHeight();
|
||||
width = myDetector->GetImgWidth();
|
||||
pictureLeft = -0.5 * width; // X coordinate of the top left corner of the background image in the view
|
||||
pictureTop = 0.5 * height; // Y coordinate of both top corners
|
||||
|
||||
@ -674,7 +674,7 @@ void EntityGUI_FeatureDetectorDlg::setEndPnt(const gp_Pnt& theEndPnt)
|
||||
{
|
||||
myEndPnt = theEndPnt;
|
||||
MESSAGE("myEndPnt = ("<<theEndPnt.X()<<", "<<theEndPnt.Y()<<")")
|
||||
if (setSelectionRect() && aDetector->GetImgHeight() > 0)
|
||||
if (setSelectionRect() && myDetector->GetImgHeight() > 0)
|
||||
showImageSample();
|
||||
}
|
||||
|
||||
@ -705,8 +705,8 @@ bool EntityGUI_FeatureDetectorDlg::setSelectionRect()
|
||||
void EntityGUI_FeatureDetectorDlg::showImageSample()
|
||||
{
|
||||
// Cropp the image to the selection rectangle given by the user
|
||||
aDetector->SetROI( myRect );
|
||||
std::string samplePicturePath = aDetector->CroppImage();
|
||||
myDetector->SetROI( myRect );
|
||||
std::string samplePicturePath = myDetector->CroppImage();
|
||||
|
||||
// Display the result
|
||||
QPixmap pixmap(QString(samplePicturePath.c_str()));
|
||||
@ -753,9 +753,9 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects )
|
||||
subPictureLeft = pictureLeft;
|
||||
subPictureTop = pictureTop;
|
||||
}
|
||||
aDetector->ComputeCorners( useROI, parameters );
|
||||
CvPoint2D32f* corners = aDetector->GetCorners();
|
||||
int cornerCount = aDetector->GetCornerCount();
|
||||
myDetector->ComputeCorners( useROI, parameters );
|
||||
CvPoint2D32f* corners = myDetector->GetCorners();
|
||||
int cornerCount = myDetector->GetCornerCount();
|
||||
int i;
|
||||
|
||||
// Build the geom objects associated to the detected corners and returned by execute
|
||||
@ -794,9 +794,9 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects )
|
||||
{
|
||||
GEOM::GEOM_ICurvesOperations_var aCurveOperations = myGeomGUI->GetGeomGen()->GetICurvesOperations( getStudyId() );
|
||||
|
||||
aDetector->ComputeContours( useROI, parameters );
|
||||
std::vector< std::vector<cv::Point> > contours = aDetector->GetContours();
|
||||
std::vector<cv::Vec4i> hierarchy = aDetector->GetContoursHierarchy();
|
||||
myDetector->ComputeContours( useROI, parameters );
|
||||
std::vector< std::vector<cv::Point> > contours = myDetector->GetContours();
|
||||
std::vector<cv::Vec4i> hierarchy = myDetector->GetContoursHierarchy();
|
||||
|
||||
std::vector< cv::Point > contour;
|
||||
int idx = 0;
|
||||
@ -914,8 +914,8 @@ bool EntityGUI_FeatureDetectorDlg::execute( ObjectList& objects )
|
||||
|
||||
// else if(myConstructorId ==LINES)
|
||||
// {
|
||||
// aDetector->ComputeLines();
|
||||
// std::vector<cv::Vec4i> lines = aDetector->GetLines();
|
||||
// myDetector->ComputeLines();
|
||||
// std::vector<cv::Vec4i> lines = myDetector->GetLines();
|
||||
// GEOM::GEOM_Object_var Pnt1;
|
||||
// GEOM::GEOM_Object_var Pnt2;
|
||||
// GEOM::GEOM_Object_var aLine;
|
||||
|
@ -84,7 +84,7 @@ private slots:
|
||||
|
||||
|
||||
private:
|
||||
ShapeRec_FeatureDetector* aDetector;
|
||||
ShapeRec_FeatureDetector* myDetector;
|
||||
|
||||
gp_Ax3 myWPlane;
|
||||
gp_Ax3 aGlobalCS;
|
||||
|
@ -60,6 +60,7 @@ void ShapeRec_FeatureDetector::SetPath( const std::string& thePath )
|
||||
IplImage* src = cvLoadImage(imagePath.c_str(),CV_LOAD_IMAGE_COLOR);
|
||||
imgHeight = src->height;
|
||||
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";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user