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