otb issueshttps://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/issues2020-11-03T09:34:24Zhttps://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/issues/2106Reading the metadata from the geom files without OSSIM2020-11-03T09:34:24ZJulien OsmanReading the metadata from the geom files without OSSIMSub-issue of #1506 and #2024.
OSSIM is in charge of the interface with the geom files. As we remove OSSIM, we need a new interface. The new framework for the metadata will not need to write geom files, because it will use GDAL's ability...Sub-issue of #1506 and #2024.
OSSIM is in charge of the interface with the geom files. As we remove OSSIM, we need a new interface. The new framework for the metadata will not need to write geom files, because it will use GDAL's ability to deal with metadata. So we only need to implement a geom file reader.
# The new class `otb::GeomMetadataSupplier`
This class will be in charge of:
1. reading the geom file (formatted as `key: value` lines) to charge the metadata into a dictionary (`std::map<std::string, std::string>`)
1. extracting the common metadata from the dictionary to fill an ImageMetadata object with the method `Parse(Imagemetadata imi)`
1. allowing access to the dictionary so the ImageMetadataInterfaces can handle the sensor specific metadata, by inheriting from `otb::MetadataSupplierInterface` (and provide the method `GetAs<>`)
This class will be used by the `otb::ImageFileReader` if a geom file is present. In this case, the metadata won't be read by GDAL. The `otb::ImageFileReader` will use an instance of `otb::GeomMetadataSupplier` to parse the common metadata, then it will provide it to the `otb::ImageMetadataInterface` so it can parse the sensor specific metadata.
# Acceptance criterion
- [x] The class `otb::GeomMetadataSupplier` is implemented and tested
- [ ] The class `otb::GeomMetadataSupplier` is used by `otb::ImageFileReader` to parse the common metadata
The parsing of the sensor specific metadata by the IMIs using the `otb::GeomMetadataSupplier` is not in the scope of this issue, as it is covered by issue #2024.8.0.0Julien OsmanJulien Osmanhttps://gitlab.orfeo-toolbox.org/orfeotoolbox/otb/-/issues/2142Refactor SAR sensor models2021-11-08T09:56:32ZCédric TraizetRefactor SAR sensor modelsPart of the [sensor model refactoring](#2040).
The Sar functionalites should be refactored to become independent of Ossim.
### SAR model
##### Metadata parsing
SARImageMetadataInterface : use of `ossimSarSensorModel` to parse metadat...Part of the [sensor model refactoring](#2040).
The Sar functionalites should be refactored to become independent of Ossim.
### SAR model
##### Metadata parsing
SARImageMetadataInterface : use of `ossimSarSensorModel` to parse metadata, it has already been refactored to rely on GDAL instead of Ossim for metadata parsing, metadata parsing from geom file is still to be implemented.
While other sensors models are implemented in QGIS plugin, OTB currently uses 4 SAR sensor models:
* Sentinel 1
* RadarSat 2
* TerraSar-X
* CosmoSkyMed
The metadata parsing has been implemented in !761
Support for geom files should still be added. TODO: can this be done for all sensors at once ? Or do we need to implement geom sensor by sensor ? (this was required for Optical Sensor Models, because each sensor had specific keys and needed post-processing)
##### ossimSARSensorModel
SAR processing in OTB is based on Ossim. Most SAR classes are implemented in the OssimPlugins module. The `ossimSarSensorModel`, deriving from `ossimSensorModel` from Ossim is the main virtual class used for SAR functionalities and SAR metadata reading.
SARSensorModelAdapters : Adapter class for ossimSarSensorModel processing functions, it defines the following methods :
``` cpp
bool LoadState(const ImageKeywordlist& image_kwl);
bool SaveState(ImageKeywordlist& image_kwl);
bool IsValidSensorModel() const;
bool Deburst(std::vector<std::pair<unsigned long, unsigned long>>& lines, std::pair<unsigned long, unsigned long>& samples, bool onlyValidSample = false);
bool BurstExtraction(const unsigned int burst_index, std::pair<unsigned long, unsigned long>& lines, std::pair<unsigned long, unsigned long>& samples, bool allPixels = false);
bool DeburstAndConcatenate(std::vector<std::pair<unsigned long, unsigned long>>& linesBursts, std::vector<std::pair<unsigned long, unsigned long>>& samplesBursts, unsigned int& linesOffset, unsigned int first_burstInd, bool inputWithInvalidPixels = false);
bool Overlap(std::pair<unsigned long, unsigned long>& linesUp, std::pair<unsigned long, unsigned long>& linesLow,
std::pair<unsigned long, unsigned long>& samplesUp, std::pair<unsigned long, unsigned long>& samplesLow, unsigned int burstIndUp,bool inputWithInvalidPixels = false);
bool WorldToLineSampleYZ(const Point3DType& inGeoPoint, Point2DType& cr, Point2DType& yz) const;
bool WorldToLineSample(const Point3DType& inGEoPOint, Point2DType& cr) const;
bool WorldToSatPositionAndVelocity(const Point3DType& inGeoPoint, Point3DType& satellitePosition, Point3DType& satelliteVelocity) const;
bool LineToSatPositionAndVelocity(const double line, Point3DType& satellitePosition, Point3DType& satelliteVelocity) const;
static bool WorldToCartesian(const Point3DType& inGeoPoint, Point3DType& outCartesianPoint);
static bool ImageLineToDeburstLine(const std::vector<std::pair<unsigned long, unsigned long>>& lines, unsigned long imageLine, unsigned long& deburstLine);
static void DeburstLineToImageLine(const std::vector<std::pair<unsigned long, unsigned long>>& lines, unsigned long deburstLine, unsigned long& imageLine);
```
ossimSARSensorModel is implemented by 3 sensor:
* ossimSentinel1Model
* ossimCosmoSkyMedModel
* ossimTerraSarXModel
##### ossimGeometricSARSensorModel
ossimGeometricSARSensorModel is another implementation of SAR models in OssimPlugins, it is used by older sensors (?), including:
* ossimRadarSatModel
* ossimRadarSat2Model
* ossimAlosPalsarModel
* ossimErsSarModel
* ossimEnvisatASarModel
while ossimGeometricSARSensorModel is not used by SARSensorModelAdapters, it is available through the ossimPlugins projection factory, which means OTB is able to transform sensor points to/from geo points for these sensors. As metadata parsing is not implemented (it has been removed at some point ?) for these models (excepting RadarSat2), it is only possible to use these sensor by providing a geom file containing the required metadata to instantiate the ossimSensorModel. These sensor are not tested in OTB.
Questions:
* are AlosPalsar, ErsSar, Envisat Asar and RadarSat deprecated ? Should we support them in OTB 8.0 ?
* There is a RPC model defined in RadarSat 2 metadata, can we use it ? There is a ossimRadarSat2RPCModel, but it is not used by the ossimProjection factory.
### Refactoring plan
- [ ] #2158 >> Bug in TerraSar-X calibration
- [x] #2154 >> Implement SAR metadata parsing from geom files.
- [x] #2159 >> Use ImageMetadata in SarCalibration filters
- [x] #2150 >> Implement a factory for SensorTransformBase (only RPCForwardTransform and RPCInverseTransform are defined at this point), and use it in `GenericRSTransform`.
- [x] #2160 >> Implement `otb::SarSensorModel`, this class provides the same algorithms as `SARSensorModelAdapters`. This is the main issue of the refactoring, and it requires refinement.
- [x] #2151 >> Implement `otb::SarForwardTransform` and `otb::SarInverseTransform` deriving from `SensorTransformBase`, using `otb::SarSensorModel` to map points
- [x] #2152 >> Refactor SAR filter and application to use `otb::SarSensorModel`, `otb::SarForwardTransform` and `otb::SarInverseTransform`.
- [X] ~~Implement `otb::SarGeometricSensorModel` ?~~ (out of scope of version 8.0)
- [x] #2153 >> Remove Ossim based SAR classes (including OssimPlugins)
While most of the code is in QGISPlugins and can be reused easily (some Ossim data structure should be refactored, and ITK or the standard library should be used), some functionalities might require more work, in particular, SAR model uses a lot of point projections utilities from Ossim, maybe Proj can be used as a replacement for these functionalities.
The impact of the refactoring on DiapOTB should also be investigated.
### Tests
Test should be added for all methods implemented in `SarSensorModel` test should also be added for `otb::SarForwardTransform` and `otb::SarInverseTransform` with different sensors. The baseline for these tests will be generated with Ossim and OTB 7.2.0.
Some test have been deactivated while implementing the geom file reading (!759), because they rely heavily on the new SAR model. We need to reactivate them while implementing this model.
- saTvSarDeburstImageFilterTest
- saTvSarDeburstImageFilterTest2
- saTvSarDeburstImageFilterTest3
- saTvSarBurstExtractionImageFilterTest1
- saTvSarBurstExtractionImageFilterTest2
- prTvSensorModel_ers2-1
- prTvSensorModel_sentinel1-1
- prTvOrthoRectification_sentinel1_DEMGTIFF
- prTvOrthoRectification_sentinel1_DEMSRTM
- prTvOrthoRectification_sentinel1_noDEM
- otbSARAmplitudeEstimationImageFilterTest (DiapOTB)
- otbSARAmplitudeEstimationTest (DiapOTB)
- otbSARCartesianMeanEstimationTest (DiapOTB)8.0.0