From e368cd0b497d2df41c997811bee2b1f59bc4f9b3 Mon Sep 17 00:00:00 2001 From: Julien Michel <julien.michel@cnes.fr> Date: Mon, 16 Oct 2017 09:20:49 +0200 Subject: [PATCH] BUG: Fixing bug #1467. No Update() should happen on filters whatsoever, unless you know for sure that the Udpate() call will not load whole image in memory. No local pointers to filters are allowed (because the streaming pipeline disappears at the end of the method) --- .../AppImageUtils/app/otbConvert.cxx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Modules/Applications/AppImageUtils/app/otbConvert.cxx b/Modules/Applications/AppImageUtils/app/otbConvert.cxx index cae4ff2411..51ce7f3eeb 100644 --- a/Modules/Applications/AppImageUtils/app/otbConvert.cxx +++ b/Modules/Applications/AppImageUtils/app/otbConvert.cxx @@ -222,6 +222,10 @@ private: template<class TImageType> void GenericDoExecute() { + + // Clear previously registered filters + m_Filters.clear(); + std::string rescaleType = this->GetParameterString("type"); if( (rescaleType != "none") && (rescaleType != "linear") && (rescaleType != "log2") ) @@ -383,7 +387,7 @@ private: rescaler->SetGamma(GetParameterFloat("type.linear.gamma")); } - m_TmpFilter = rescaler; + m_Filters.push_back(rescaler.GetPointer()); SetParameterOutputImage<TImageType>("out", rescaler->GetOutput()); } @@ -440,19 +444,19 @@ private: { typedef MultiToMonoChannelExtractROI<FloatVectorImageType::InternalPixelType, typename TImageType::InternalPixelType> ExtractROIFilterType; - typedef ObjectList<ExtractROIFilterType> ExtractROIFilterListType; typedef otb::ImageList<otb::Image<typename TImageType::InternalPixelType> > ImageListType; typedef ImageListToVectorImageFilter<ImageListType, TImageType > ListConcatenerFilterType; typename ImageListType::Pointer imageList; typename ListConcatenerFilterType::Pointer concatener; - typename ExtractROIFilterListType::Pointer extractorList; imageList = ImageListType::New(); concatener = ListConcatenerFilterType::New(); - extractorList = ExtractROIFilterListType::New(); + //m_Filters.push_back(imageList.GetPointer()); + m_Filters.push_back(concatener.GetPointer()); + const bool monoChannel = IsParameterEnabled("channels.grayscale"); // get band order @@ -461,16 +465,15 @@ private: for (auto && channel : channels) { typename ExtractROIFilterType::Pointer extractROIFilter = ExtractROIFilterType::New(); + m_Filters.push_back(extractROIFilter.GetPointer()); extractROIFilter->SetInput(GetParameterImage("in")); if (!monoChannel) extractROIFilter->SetChannel(channel); extractROIFilter->UpdateOutputInformation(); - extractorList->PushBack(extractROIFilter); imageList->PushBack(extractROIFilter->GetOutput()); } concatener->SetInput(imageList); concatener->UpdateOutputInformation(); - concatener->Update(); return concatener->GetOutput(); } @@ -507,8 +510,8 @@ private: } } - itk::ProcessObject::Pointer m_TmpFilter; TransferLogType::Pointer m_TransferLog; + std::vector<itk::LightObject::Pointer> m_Filters; }; } -- GitLab