Skip to content

Compare image metadata in --compare-metadata

Cédric Traizet requested to merge compare-metadata into develop

Summary

Compare the otb::ImageMetadata object of baseline and test images in the --compare-metadata.

Rationale

Image metadata are now stored in a otb::ImageMetadata object (see !707 (merged)). But there are currently no systematic way of comparing the metadata of two images (there are unit test for metadata parsing in Modules/Core/Metadata thought). This MR is a refactoring of --compare-metadata to actually use otb::ImageMetadata to compare the metadata, instead of comparing only a part of metadata (it currently compares GCPs, geoTransform, projection and corners).

TileHint and Datatype metadatas are not tested, as they depend of the output format (the gdal driver used) and image type.

Two test have been added to test the functionality.

The first one uses the same file as test and baseline images:

otb_add_test(NAME tsTvCompareMetadata1 COMMAND otbTestKernelTestDriver
  --compare-metadata 0
  LARGEINPUT{SENTINEL1/S1A_S6_SLC__1SSV_20150619T195043}
  LARGEINPUT{SENTINEL1/S1A_S6_SLC__1SSV_20150619T195043}
  otbDummyTest
  )

The second one uses different files, with different metadata, and should fail:

otb_add_test(NAME tsTvCompareMetadata2 COMMAND otbTestKernelTestDriver
  --compare-metadata 0
  ${OTB_DATA_LARGEINPUT_ROOT}/PLEIADES-PRE/TLSE_JP2_ORTHO_DIMAPv2_PMS-N_lossy_12bits/IMG_PHR1Z_PMS_N_001/IMG_PHR1A_PMS-N_201006181052297_ORT_IPU_20111011_0619-001_R1C1.JP2
  ${OTB_DATA_LARGEINPUT_ROOT}/PLEIADES-PRE/TLSE_TIFF_ORTHO_DIMAPv2_MS_lossless_8bits/IMG_PHR1A_MS_002/IMG_PHR1A_MS_201006181052297_ORT_IPU_20111109_7807-004_R1C1.TIF
  otbDummyTest
  )
set_property(TEST tsTvCompareMetadata2 PROPERTY WILL_FAIL true)

Implementation Details

With the exception of MDGeom, all type of metadata (MDNum: double, MDStr: std::string, MDL1D: lut 1D, MDL2D: lut 2D, MDTime dates and ExtraKeys: std::string) are compared between baseline and test metadata. The comparison is done by comparing each element of the corresponding std::map in both metadata objects (associative container). The comparison is done using the == operator, with the exception of MDNum metadata which are compared relatively to a tolerance.

In the case of MDGeom metadatas the comparison needs to be done by hand, as the actual type of MDGeom is unknown. This is implemeted for RPC coefficients, GCPs and projection.

This MR also implements a few == operators for metadata types : otb::Time, otb::Projection::RPCParam and LUT<unsigned int dim>

Additional notes

A template<class T> std::string otb::Metadata::EnumToString(T t) function has been implemented to be able to get the name of a metadata in a generic way. This method is specialized for the different types of metadata and uses the boost::bimap of correspondance between enums and std::string. This function is used to generate the logs in --compare-metadata

for example otb::Metadata::EnumToString(MDNum::NoData) returns "NoData".

Copyright

The copyright owner is CNES and has signed the ORFEO ToolBox Contributor License Agreement.


Check before merging:

  • All discussions are resolved
  • At least 2 👍 votes from core developers, no 👎 vote.
  • The feature branch is (reasonably) up-to-date with the base branch
  • Dashboard is green
  • Copyright owner has signed the ORFEO ToolBox Contributor License Agreement
  • Optionally, run git diff develop... -U0 --no-color | clang-format-diff.py -p1 -i on latest changes and commit
Edited by Cédric Traizet

Merge request reports

Loading