InsightSoftwareConsortium / ITK

Insight Toolkit (ITK) -- Official Repository. ITK builds on a proven, spatially-oriented architecture for processing, segmentation, and registration of scientific images in two, three, or more dimensions.
https://itk.org
Apache License 2.0
1.41k stars 663 forks source link

HoughTransform2DCirclesImageFilter cause memory leak in python #4384

Open yhlujz opened 8 months ago

yhlujz commented 8 months ago

My code like this:

import itk

image2D = itk.imread('image2D.nii.gz')
hough_filter = itk.HoughTransform2DCirclesImageFilter.New()
hough_filter.SetInput(image2D)
hough_filter.SetNumberOfCircles(1)
hough_filter.SetMinimumRadius(1)
hough_filter.SetMaximumRadius(int(11.4 / 2 / 0.85 + 2))
hough_filter.SetUseImageSpacing(True)

hough_filter.SetSweepAngle(0)
hough_filter.SetSigmaGradient(1)
hough_filter.SetVariance(10)

hough_filter.Update()
circles = hough_filter.GetCircles()
for circle in circles:
    print(circle)

then I get this:

<Swig Object of type 'std::list< itkEllipseSpatialObject2_Pointer >::value_type *' at 0x7fba0c9c8030>
swig/python detected a memory leak of type 'std::list< itkEllipseSpatialObject2_Pointer >::value_type *', no destructor found.
github-actions[bot] commented 8 months ago

Thank you for contributing an issue! 🙏

Welcome to the ITK community! 🤗👋☀️

We are glad you are here and appreciate your contribution. Please keep in mind our community participation guidelines. 📜 Also, please check existing open issues and consider discussion on the ITK Discourse. 📖

This is an automatic message. Allow for time for the ITK community to be able to read the issue and comment on it.

thewtex commented 8 months ago

<Swig Object of type 'std::list< itkEllipseSpatialObject2_Pointer >::value_type *' at 0x7fba0c9c8030>

We may need to wrap this type, std::list< itkEllipseSpatialObject2_Pointer >.

thewtex commented 5 months ago

<Swig Object of type 'std::list< itkEllipseSpatialObject2_Pointer >::value_type *' at 0x7fba0c9c8030>

We may need to wrap this type, std::list< itkEllipseSpatialObject2_Pointer >.

Likely the same typemap for std::list as was done for std::vector here: https://github.com/InsightSoftwareConsortium/ITK/commit/d6354b9d06457b740d8497595572c908461b5c1c