OTB  10.0.0
Orfeo Toolbox
otbDisparityMapTo3DFilter.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbDisparityMapTo3DFilter_h
22 #define otbDisparityMapTo3DFilter_h
23 
24 #include "itkImageToImageFilter.h"
25 #include "otbGenericRSTransform.h"
27 #include "otbVectorImage.h"
28 #include "otbImage.h"
29 
30 namespace otb
31 {
32 
51 template <class TDisparityImage, class TOutputImage = otb::VectorImage<float, 2>, class TEpipolarGridImage = otb::VectorImage<float, 2>,
52  class TMaskImage = otb::Image<unsigned char>>
53 class ITK_EXPORT DisparityMapTo3DFilter : public itk::ImageToImageFilter<TDisparityImage, TOutputImage>
54 {
55 public:
58  typedef itk::ImageToImageFilter<TDisparityImage, TOutputImage> Superclass;
59  typedef itk::SmartPointer<Self> Pointer;
60  typedef itk::SmartPointer<const Self> ConstPointer;
61 
63  itkNewMacro(Self);
64 
66  itkTypeMacro(DisparityMapTo3DFilter, ImageToImageFilter);
67 
69  typedef TDisparityImage DisparityMapType;
70  typedef TOutputImage OutputImageType;
71  typedef TEpipolarGridImage GridImageType;
72  typedef TMaskImage MaskImageType;
73 
74  typedef typename OutputImageType::RegionType RegionType;
75  typedef typename OutputImageType::PixelType DEMPixelType;
76 
77  // 3D RS transform
78  // TODO: Allow tuning precision (i.e. double or float)
79  typedef double PrecisionType;
81 
82  // 3D points
84 
87  typedef typename PointSetType::PointsContainer PointsContainer;
88  typedef typename PointSetType::PointDataContainer LabelContainer;
89 
91  void SetHorizontalDisparityMapInput(const TDisparityImage* hmap);
92 
94  void SetVerticalDisparityMapInput(const TDisparityImage* vmap);
95 
97  void SetLeftEpipolarGridInput(const TEpipolarGridImage* grid);
98 
100  void SetRightEpipolarGridInput(const TEpipolarGridImage* grid);
101 
103  void SetDisparityMaskInput(const TMaskImage* mask);
104 
106  const TDisparityImage* GetHorizontalDisparityMapInput() const;
107  const TDisparityImage* GetVerticalDisparityMapInput() const;
108  const TEpipolarGridImage* GetLeftEpipolarGridInput() const;
109  const TEpipolarGridImage* GetRightEpipolarGridInput() const;
110  const TMaskImage* GetDisparityMaskInput() const;
112 
115  {
116  this->m_LeftImageMetadata = imd;
117  this->Modified();
118  }
120 
123  {
124  return this->m_LeftImageMetadata;
125  }
126 
129  {
130  this->m_RightImageMetadata = imd;
131  this->Modified();
132  }
134 
137  {
138  return this->m_RightImageMetadata;
139  }
140 
141 protected:
144 
146  ~DisparityMapTo3DFilter() override = default;
147 
149  void GenerateOutputInformation() override;
150 
152  void GenerateInputRequestedRegion() override;
153 
155  void BeforeThreadedGenerateData() override;
156 
158  void DynamicThreadedGenerateData(const RegionType& outputRegionForThread) override;
159 
165  void VerifyInputInformation() const override
166  {
167  }
168 
169 
170 private:
171  DisparityMapTo3DFilter(const Self&) = delete;
172  void operator=(const Self&) = delete;
173 
175  const ImageMetadata* m_LeftImageMetadata = nullptr;
176 
178  const ImageMetadata* m_RightImageMetadata = nullptr;
179 
182 
185 };
186 } // end namespace otb
187 
188 #ifndef OTB_MANUAL_INSTANTIATION
190 #endif
191 
192 #endif
Project an input disparity map into a 3D points.
RSTransformType::InputPointType TDPointType
void VerifyInputInformation() const override
PointSetType::PointDataContainer LabelContainer
void operator=(const Self &)=delete
OutputImageType::RegionType RegionType
OptimizerType::PointSetType PointSetType
otb::GenericRSTransform< PrecisionType, 3, 3 > RSTransformType
~DisparityMapTo3DFilter() override=default
RSTransformType::Pointer m_RightToGroundTransform
void SetLeftImageMetadata(const ImageMetadata *imd)
PointSetType::PointsContainer PointsContainer
otb::LineOfSightOptimizer< PrecisionType > OptimizerType
itk::SmartPointer< const Self > ConstPointer
const ImageMetadata * GetRightImageMetadata() const
DisparityMapTo3DFilter(const Self &)=delete
RSTransformType::Pointer m_LeftToGroundTransform
itk::ImageToImageFilter< TDisparityImage, TOutputImage > Superclass
void SetRightImageMetadata(const ImageMetadata *imd)
const ImageMetadata * GetLeftImageMetadata() const
itk::SmartPointer< Self > Pointer
OutputImageType::PixelType DEMPixelType
This is the class to handle generic remote sensing transform.
itk::SmartPointer< Self > Pointer
itk::Point< ScalarType, NInputDimensions > InputPointType
Generic class containing image metadata used in OTB.
Compute the position of a 3D point from a set of N lines of sight.
itk::PointSet< TLabel, 3, MeshType > PointSetType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.