18 #ifndef __otbObjectDetectionClassifier_txx
19 #define __otbObjectDetectionClassifier_txx
28 template <
class TInputImage,
class TOutputVectorData,
class TLabel,
class TFunctionType>
31 : m_NeighborhoodRadius(0),
37 this->SetNumberOfRequiredInputs(2);
40 this->SetNumberOfRequiredOutputs(3);
45 template <
class TInputImage,
class TOutputVectorData,
class TLabel,
class TFunctionType>
51 template <
class TInputImage,
class TOutputVectorData,
class TLabel,
class TFunctionType>
63 template <
class TInputImage,
class TOutputVectorData,
class TLabel,
class TFunctionType>
68 Superclass::GenerateOutputInformation();
71 this->GetOutput()->CopyInformation(this->GetInput());
72 this->GetOutput()->SetLargestPossibleRegion(this->GetInput()->GetLargestPossibleRegion());
74 if (this->GetOutput()->GetRequestedRegion().GetNumberOfPixels() == 0)
76 this->GetOutput()->SetRequestedRegion(this->GetOutput()->GetLargestPossibleRegion());
81 template <
class TInputImage,
class TOutputVectorData,
class TLabel,
class TFunctionType>
86 this->SetNthInput(1, model);
89 template <
class TInputImage,
class TOutputVectorData,
class TLabel,
class TFunctionType>
97 template <
class TInputImage,
class TOutputVectorData,
class TLabel,
class TFunctionType>
106 output =
static_cast<itk::DataObject*
>(InputImageType::New().GetPointer());
110 output =
static_cast<itk::DataObject*
>(VectorDataType::New().GetPointer());
114 output =
static_cast<itk::DataObject*
>(InputImageType::New().GetPointer());
120 template <
class TInputImage,
class TOutputVectorData,
class TLabel,
class TFunctionType>
129 template <
class TInputImage,
class TOutputVectorData,
class TLabel,
class TFunctionType>
148 vdata->GetDataTree()->Add(document, root);
149 vdata->GetDataTree()->Add(folder, document);
151 for (
unsigned int threadId = 0; threadId < m_ThreadPointArray.size(); ++threadId)
153 PointArray& pointArray = m_ThreadPointArray[threadId];
154 typename PointArray::const_iterator it = pointArray.begin();
155 typename PointArray::const_iterator end = pointArray.end();
157 for (; it != end; ++it)
160 currentGeometry->SetNodeId(
"FEATURE_POINT");
165 currentGeometry->SetPoint(p);
166 currentGeometry->SetFieldAsInt(m_ClassKey, it->second);
167 vdata->GetDataTree()->Add(currentGeometry, folder);
172 template <
class TInputImage,
class TOutputVectorData,
class TLabel,
class TFunctionType>
177 Superclass::PrintSelf(os, indent);
180 template <
class TInputImage,
class TOutputVectorData,
class TLabel,
class TFunctionType>
185 Superclass::GenerateInputRequestedRegion();
189 const_cast< TInputImage *
>( this->GetInput() );
192 if ( !inputPtr || !outputPtr )
199 typename TInputImage::RegionType inputRequestedRegion;
200 inputRequestedRegion = inputPtr->GetRequestedRegion();
203 inputRequestedRegion.PadByRadius( m_NeighborhoodRadius + 1 );
206 if ( inputRequestedRegion.Crop(inputPtr->GetLargestPossibleRegion()) )
208 inputPtr->SetRequestedRegion( inputRequestedRegion );
217 inputPtr->SetRequestedRegion( inputRequestedRegion );
221 template <
class TInputImage,
class TOutputVectorData,
class TLabel,
class TFunctionType>
227 m_InvertedScales = m_Scales;
228 for(
unsigned int idx = 0; idx < m_Scales.Size(); ++idx)
230 if(m_Scales[idx]-1e-10 < 0.)
231 m_InvertedScales[idx] = 0.;
233 m_InvertedScales[idx] = 1 / m_Scales[idx];
238 template <
class TInputImage,
class TOutputVectorData,
class TLabel,
class TFunctionType>
247 typedef typename RegionType::IndexType
IndexType;
248 typedef typename RegionType::IndexValueType IndexValueType;
250 IndexType begin = outputRegionForThread.GetIndex();
251 IndexType end = begin;
252 end[0] += outputRegionForThread.GetSize(0);
253 end[1] += outputRegionForThread.GetSize(1);
255 IndexType current = begin;
256 for (; current[1] != end[1]; current[1]++)
258 if (current[1] % m_GridStep == 0)
260 for(current[0] = begin[0]; current[0] != end[0]; current[0]++)
262 if (current[0] % m_GridStep == 0)
265 input->TransformIndexToPhysicalPoint(current, point);
268 currentContinuous[0] += 0.5;
269 currentContinuous[1] += 0.5;
271 input->TransformContinuousIndexToPhysicalPoint(currentContinuous, pointOGR);
273 DescriptorType descriptor = m_DescriptorsFunction->Evaluate(point);
275 for (
unsigned int i = 0; i < descriptor.GetSize(); ++i)
277 modelMeasurement[i] = (descriptor[i] - m_Shifts[i]) * m_InvertedScales[i];
281 if (label != m_NoClassLabel)
283 m_ThreadPointArray[threadId].push_back(std::make_pair(pointOGR, label));
292 template <
class TInputImage,
class TOutputVectorData,
class TLabel,
class TFunctionPrecision,
class TCoordRep>
299 template <
class TInputImage,
class TOutputVectorData,
class TLabel,
class TFunctionPrecision,
class TCoordRep>