From 2cd08f46d33f0abd63db5f01e33a1fb113ff8d03 Mon Sep 17 00:00:00 2001 From: Thibaut ROMAIN Date: Thu, 16 Jun 2022 10:24:57 +0200 Subject: [PATCH 1/4] BUG: The shift in pleiades ortho was due to a wrong pixel correction --- .../Core/Metadata/src/otbPleiadesImageMetadataInterface.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Core/Metadata/src/otbPleiadesImageMetadataInterface.cxx b/Modules/Core/Metadata/src/otbPleiadesImageMetadataInterface.cxx index d03db7f6fc..4cbd84fc6f 100644 --- a/Modules/Core/Metadata/src/otbPleiadesImageMetadataInterface.cxx +++ b/Modules/Core/Metadata/src/otbPleiadesImageMetadataInterface.cxx @@ -594,7 +594,7 @@ void PleiadesImageMetadataInterface::Parse(ImageMetadata &imd) // fill RPC model if (imd[MDStr::GeometricLevel] == "SENSOR") { - FetchRPC(imd, -0.5, -0.5); + FetchRPC(imd, 0.5, 0.5); } } // Product read by the DIMAP GDAL driver @@ -613,7 +613,7 @@ void PleiadesImageMetadataInterface::Parse(ImageMetadata &imd) // fill RPC model if (imd[MDStr::GeometricLevel] == "SENSOR") { - FetchRPC(imd, -0.5, -0.5); + FetchRPC(imd, 0.5, 0.5); } } // Geom case -- GitLab From b7e593a63ee75a0dccef7fecbbaf338f5e0496ce Mon Sep 17 00:00:00 2001 From: Thibaut ROMAIN Date: Thu, 23 Jun 2022 15:55:40 +0200 Subject: [PATCH 2/4] BUG: The offset has been handled by GDAL >= 3.2 for pleiades products --- .../Core/Metadata/src/otbPleiadesImageMetadataInterface.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/Core/Metadata/src/otbPleiadesImageMetadataInterface.cxx b/Modules/Core/Metadata/src/otbPleiadesImageMetadataInterface.cxx index 4cbd84fc6f..36cda9a1f2 100644 --- a/Modules/Core/Metadata/src/otbPleiadesImageMetadataInterface.cxx +++ b/Modules/Core/Metadata/src/otbPleiadesImageMetadataInterface.cxx @@ -594,7 +594,7 @@ void PleiadesImageMetadataInterface::Parse(ImageMetadata &imd) // fill RPC model if (imd[MDStr::GeometricLevel] == "SENSOR") { - FetchRPC(imd, 0.5, 0.5); + FetchRPC(imd); } } // Product read by the DIMAP GDAL driver @@ -613,7 +613,7 @@ void PleiadesImageMetadataInterface::Parse(ImageMetadata &imd) // fill RPC model if (imd[MDStr::GeometricLevel] == "SENSOR") { - FetchRPC(imd, 0.5, 0.5); + FetchRPC(imd); } } // Geom case -- GitLab From f249b18244654a85788badc610af3c7f161adc56 Mon Sep 17 00:00:00 2001 From: Julien Osman Date: Mon, 18 Jul 2022 20:44:57 +0200 Subject: [PATCH 3/4] WIP: Fix reading RPC from GEOM for Pleiades --- ...OrthoRectification_pleiades-1_DEMGTIFF.tif | 4 +- ...vOrthoRectification_pleiades-1_DEMSRTM.tif | 4 +- ...rTvOrthoRectification_pleiades-1_noDEM.tif | 4 +- Data/Input/pleiades/pleiades-1.gcp2 | 73 +++++++++---------- .../include/otbGeomMetadataSupplier.h | 2 +- .../Metadata/src/otbGeomMetadataSupplier.cxx | 8 +- Modules/Core/Transform/test/CMakeLists.txt | 2 + .../Transform/test/otbRPCTransformTest.cxx | 11 ++- Modules/IO/IOGDAL/test/CMakeLists.txt | 2 + .../test/otbGDALRPCTransformerTest2.cxx | 12 ++- .../IO/ImageIO/include/otbImageFileReader.hxx | 5 +- 11 files changed, 75 insertions(+), 52 deletions(-) diff --git a/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_DEMGTIFF.tif b/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_DEMGTIFF.tif index 9ff1368571..82d2b2abfd 100644 --- a/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_DEMGTIFF.tif +++ b/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_DEMGTIFF.tif @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2200368da4dd12399e3df5c476891bf552d240d35be343c41c650d059b12ba00 -size 9589024 +oid sha256:06e9ec7f39f6289d72f7bd9d7ff258a5ee264f6695e21bedeac32da30396f920 +size 8014228 diff --git a/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_DEMSRTM.tif b/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_DEMSRTM.tif index e7e2a17eb6..23e5b75be2 100644 --- a/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_DEMSRTM.tif +++ b/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_DEMSRTM.tif @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:32cc257b2f2ea4bacba7b420cc6a3d8031f99831f6a9350fe5a51f5df449f5ca -size 9587130 +oid sha256:fefb90eed77369bd63d6de4922ed04ae5810d36a09bf322ff041e6a70340ae5a +size 8014228 diff --git a/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_noDEM.tif b/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_noDEM.tif index e8fdbf1b91..759fafcb3a 100644 --- a/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_noDEM.tif +++ b/Data/Baseline/OTB/Images/prTvOrthoRectification_pleiades-1_noDEM.tif @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b2b3e7d8702bca56b16ca6e5f89522451354a718588b0f65a09f9449fc5e7a8c -size 9586558 +oid sha256:d44b0600974780121bfe07db87863bc841266076f9e1b4b1e1f10c2acb19fe80 +size 8014228 diff --git a/Data/Input/pleiades/pleiades-1.gcp2 b/Data/Input/pleiades/pleiades-1.gcp2 index 8337a2d25b..edd595c82e 100644 --- a/Data/Input/pleiades/pleiades-1.gcp2 +++ b/Data/Input/pleiades/pleiades-1.gcp2 @@ -1,37 +1,36 @@ -# column row longitude latitude elevation -10 10 1.3619678304742049 43.685679307528154 255.0 -60 10 1.362269915752421 43.68568138233786 255.0 -110 10 1.3625720040752514 43.68568345638775 255.0 -160 10 1.3628740954430656 43.68568552967785 255.0 -210 10 1.3631761898562327 43.685687602208176 255.0 -260 10 1.3634782873151208 43.68568967397878 255.0 -10 60 1.3619690059603062 43.68545371966921 255.0 -60 60 1.362271090845755 43.685455793356994 255.0 -110 60 1.3625731787760083 43.68545786628494 255.0 -160 60 1.3628752697514357 43.685459938453086 255.0 -210 60 1.3631773637724058 43.68546200986146 255.0 -260 60 1.3634794608392868 43.685464080510094 255.0 -10 110 1.3619701802586466 43.68522813138672 255.0 -60 110 1.362272264751236 43.685230203952486 255.0 -110 110 1.3625743522888205 43.68523227575841 255.0 -160 110 1.36287644287177 43.68523434680452 255.0 -210 110 1.363178536500452 43.68523641709085 255.0 -260 110 1.3634806331752352 43.685238486617436 255.0 -10 160 1.3619713533675186 43.685002542681254 255.0 -60 160 1.3622734374671568 43.68500461412492 255.0 -110 160 1.3625755246119815 43.685006684808734 255.0 -160 160 1.3628776148023616 43.68500875473273 255.0 -210 160 1.3631797080386652 43.68501082389693 255.0 -260 160 1.3634818043212602 43.68501289230138 255.0 -10 210 1.3619725252852164 43.68477695355337 255.0 -60 210 1.362274608991812 43.68477902387485 255.0 -110 210 1.3625766957437855 43.68478109343648 255.0 -160 210 1.3628787855415057 43.684783162238276 255.0 -210 210 1.3631808783853407 43.684785230280276 255.0 -260 210 1.3634829742756576 43.68478729756251 255.0 -10 260 1.361973696010035 43.684551364003646 255.0 -60 260 1.3622757793234972 43.68455343320287 255.0 -110 260 1.362577865682529 43.68455550164222 255.0 -160 260 1.362879955087499 43.68455756932174 255.0 -210 260 1.363182047538775 43.684559636241445 255.0 -260 260 1.3634841430367244 43.68456170240138 255.0 +10 10 1.361964797875297 43.68568154265233 255 +10 60 1.3619659733772 43.68545595480884 255 +10 110 1.361967147691359 43.68523036654181 255 +10 160 1.361968320816069 43.68500477785178 255 +10 210 1.361969492749621 43.68477918873934 255 +10 260 1.361970663490313 43.68455359920505 255 +60 10 1.362266883126997 43.68568361748085 255 +60 60 1.362268058236132 43.68545802851544 255 +60 110 1.362269232157431 43.68523243912639 255 +60 160 1.362270404889188 43.68500684931427 255 +60 210 1.362271576429697 43.68478125907965 255 +60 260 1.362272746777254 43.6845556684231 255 +110 10 1.362568971423306 43.68568569154957 255 +110 60 1.362570146139862 43.68546010146221 255 +110 110 1.362571319668492 43.68523451095113 255 +110 160 1.362572492007488 43.68500892001691 255 +110 210 1.362573663155145 43.6847833286601 255 +110 260 1.362574833109759 43.68455773688128 255 +160 10 1.362871062764593 43.68568776485848 255 +160 60 1.362872237088761 43.68546217364918 255 +160 110 1.362873410224912 43.68523658201607 255 +160 160 1.362874582171338 43.68501098995972 255 +160 210 1.362875752926334 43.68478539748072 255 +160 260 1.362876922488197 43.68455980457963 255 +210 10 1.363173157151227 43.68568983740764 255 +210 60 1.363174331083198 43.68546424507637 255 +210 110 1.363175503827059 43.68523865232122 255 +210 160 1.363176675381105 43.68501305914275 255 +210 210 1.363177845743632 43.68478746554155 255 +210 260 1.363179014912935 43.68456187151816 255 +260 10 1.363475254583577 43.68569190919705 255 +260 60 1.363476428123539 43.68546631574382 255 +260 110 1.363477600475302 43.68524072186663 255 +260 160 1.363478771637159 43.68501512756603 255 +260 210 1.363479941607406 43.6847895328426 255 +260 260 1.363481110384341 43.68456393769691 255 diff --git a/Modules/Core/Metadata/include/otbGeomMetadataSupplier.h b/Modules/Core/Metadata/include/otbGeomMetadataSupplier.h index 8b8e1223b5..3168f36ceb 100644 --- a/Modules/Core/Metadata/include/otbGeomMetadataSupplier.h +++ b/Modules/Core/Metadata/include/otbGeomMetadataSupplier.h @@ -70,7 +70,7 @@ public: * * @param imd The ImageMetadata to fill */ - bool FetchRPC(ImageMetadata & imd); + bool FetchRPC(ImageMetadata & imd, const double lineOffset=0, const double sampleOffset=0); /** * @brief Fill the ImageMetadata with the GCP from the geom file diff --git a/Modules/Core/Metadata/src/otbGeomMetadataSupplier.cxx b/Modules/Core/Metadata/src/otbGeomMetadataSupplier.cxx index 670c4caefb..796d3d4793 100644 --- a/Modules/Core/Metadata/src/otbGeomMetadataSupplier.cxx +++ b/Modules/Core/Metadata/src/otbGeomMetadataSupplier.cxx @@ -93,7 +93,9 @@ int GeomMetadataSupplier::GetNbBands() const return 1; } -bool GeomMetadataSupplier::FetchRPC(ImageMetadata & imd) +bool GeomMetadataSupplier::FetchRPC(ImageMetadata & imd, + const double lineOffset, + const double sampleOffset) { bool hasValue; GetMetadataValue("polynomial_format", hasValue); @@ -101,8 +103,8 @@ bool GeomMetadataSupplier::FetchRPC(ImageMetadata & imd) return false; Projection::RPCParam rpcStruct; - rpcStruct.LineOffset = this->GetAs("line_off"); - rpcStruct.SampleOffset = this->GetAs("samp_off"); + rpcStruct.LineOffset = this->GetAs("line_off") + lineOffset; + rpcStruct.SampleOffset = this->GetAs("samp_off") + sampleOffset; rpcStruct.LatOffset = this->GetAs("lat_off"); rpcStruct.LonOffset = this->GetAs("long_off"); rpcStruct.HeightOffset = this->GetAs("height_off"); diff --git a/Modules/Core/Transform/test/CMakeLists.txt b/Modules/Core/Transform/test/CMakeLists.txt index 307be335e6..47d66986ab 100644 --- a/Modules/Core/Transform/test/CMakeLists.txt +++ b/Modules/Core/Transform/test/CMakeLists.txt @@ -106,6 +106,8 @@ otb_add_test(NAME trTvRPCTransformTest_pl_hnord_geom COMMAND otbTransformTestDri ${INPUTDATA}/pleiades/pleiades-1.gcp2 # GCP 0.02 # GeoTol 0.1 # ImgTol + 0.5 # lineOffset + 0.5 # sampleOffset ) otb_add_test(NAME trTvRPCTransformTest_pl_hnord_product COMMAND otbTransformTestDriver diff --git a/Modules/Core/Transform/test/otbRPCTransformTest.cxx b/Modules/Core/Transform/test/otbRPCTransformTest.cxx index f259fa1bab..97634445f7 100644 --- a/Modules/Core/Transform/test/otbRPCTransformTest.cxx +++ b/Modules/Core/Transform/test/otbRPCTransformTest.cxx @@ -41,7 +41,7 @@ using GenericRSTransformType = otb::GenericRSTransform; using DistanceType = itk::Statistics::EuclideanDistanceMetric; using GeographicalDistanceType = otb::GeographicalDistance; -int otbRPCTransformTest(int itkNotUsed(argc), char* argv[]) +int otbRPCTransformTest(int argc, char* argv[]) { bool success = true; PointType imagePoint; @@ -52,6 +52,13 @@ int otbRPCTransformTest(int itkNotUsed(argc), char* argv[]) std::string gcpFileName(argv[2]); double geoTol(atof(argv[3])); double imgTol(atof(argv[4])); + double lineOffset(0); + double sampleOffset(0); + if(argc == 7) + { + lineOffset = atof(argv[5]); + sampleOffset = atof(argv[6]); + } // Tools auto imgDistance = DistanceType::New(); @@ -69,7 +76,7 @@ int otbRPCTransformTest(int itkNotUsed(argc), char* argv[]) for (int loop = 0 ; loop < geomSupplier.GetNbBands() ; ++loop) imd.Bands.emplace_back(); otb::ImageMetadataInterfaceFactory::CreateIMI(imd, geomSupplier); - geomSupplier.FetchRPC(imd); + geomSupplier.FetchRPC(imd, lineOffset, sampleOffset); } else { diff --git a/Modules/IO/IOGDAL/test/CMakeLists.txt b/Modules/IO/IOGDAL/test/CMakeLists.txt index a9e1763c74..083346ca67 100644 --- a/Modules/IO/IOGDAL/test/CMakeLists.txt +++ b/Modules/IO/IOGDAL/test/CMakeLists.txt @@ -611,6 +611,8 @@ otb_add_test(NAME ioTvGDALRPCTransformerTest_pl_hnord_geom ${INPUTDATA}/pleiades/pleiades-1.gcp2 # GCP 0.02 # GeoTol 0.1 # ImgTol + 0.5 # lineOffset + 0.5 # sampleOffset ) otb_add_test(NAME ioTvGDALRPCTransformerTest_pl_hnord_product diff --git a/Modules/IO/IOGDAL/test/otbGDALRPCTransformerTest2.cxx b/Modules/IO/IOGDAL/test/otbGDALRPCTransformerTest2.cxx index d8e0d32043..ef4c4a89f5 100644 --- a/Modules/IO/IOGDAL/test/otbGDALRPCTransformerTest2.cxx +++ b/Modules/IO/IOGDAL/test/otbGDALRPCTransformerTest2.cxx @@ -36,7 +36,7 @@ typedef std::vector> pointsContainerType; typedef itk::Statistics::EuclideanDistanceMetric DistanceType; typedef otb::GeographicalDistance GeographicalDistanceType; -int otbGDALRPCTransformerTest2(int itkNotUsed(argc), char* argv[]) +int otbGDALRPCTransformerTest2(int argc, char* argv[]) { bool success = true; otb::GDALRPCTransformer::PointType imagePoint; @@ -47,6 +47,14 @@ int otbGDALRPCTransformerTest2(int itkNotUsed(argc), char* argv[]) std::string gcpFileName(argv[2]); double geoTol(atof(argv[3])); double imgTol(atof(argv[4])); + double lineOffset(0); + double sampleOffset(0); + + if(argc == 7) + { + lineOffset = atof(argv[5]); + sampleOffset = atof(argv[6]); + } // Tools auto distance = DistanceType::New(); @@ -60,7 +68,7 @@ int otbGDALRPCTransformerTest2(int itkNotUsed(argc), char* argv[]) for (int loop = 0 ; loop < geomSupplier.GetNbBands() ; ++loop) imd.Bands.emplace_back(); otb::ImageMetadataInterfaceFactory::CreateIMI(imd, geomSupplier); - geomSupplier.FetchRPC(imd); + geomSupplier.FetchRPC(imd, lineOffset, sampleOffset); } else { diff --git a/Modules/IO/ImageIO/include/otbImageFileReader.hxx b/Modules/IO/ImageIO/include/otbImageFileReader.hxx index 75f880c30d..378f8ad7da 100644 --- a/Modules/IO/ImageIO/include/otbImageFileReader.hxx +++ b/Modules/IO/ImageIO/include/otbImageFileReader.hxx @@ -403,7 +403,10 @@ void ImageFileReader::GenerateOutputInformatio { GeomMetadataSupplier geomSupplier(m_FilenameHelper->GetExtGEOMFileName(), m_FileName); ImageMetadataInterfaceFactory::CreateIMI(imd, geomSupplier); - geomSupplier.FetchRPC(imd); + if(imd.Has(MDStr::Mission) && (imd[MDStr::Mission] == "Pléiades")) + geomSupplier.FetchRPC(imd, 0.5, 0.5); + else + geomSupplier.FetchRPC(imd); geomSupplier.FetchGCP(imd); otbLogMacro(Info, << "Loading metadata from external geom file " << m_FilenameHelper->GetExtGEOMFileName()); } -- GitLab From db748502a00bd2aad178861d3ad9ba9c7109d3cd Mon Sep 17 00:00:00 2001 From: Thibaut ROMAIN Date: Wed, 20 Jul 2022 15:27:52 +0200 Subject: [PATCH 4/4] DOC: Add explanation on the modifications of some baselines --- Modules/Core/Transform/test/CMakeLists.txt | 5 +++++ Modules/IO/IOGDAL/test/CMakeLists.txt | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/Modules/Core/Transform/test/CMakeLists.txt b/Modules/Core/Transform/test/CMakeLists.txt index 47d66986ab..0df4ed292f 100644 --- a/Modules/Core/Transform/test/CMakeLists.txt +++ b/Modules/Core/Transform/test/CMakeLists.txt @@ -100,6 +100,8 @@ otb_add_test(NAME trTvRPCTransformTest_worldview2 COMMAND otbTransformTestDriver 0.1 # ImgTol ) +#For issue 2293, the baseline pleaides-1.geom had a shift of 0.5 pixels +#in the geom generated with OTB 7.4, the baseline was wrong. To keep the compatibility, we added this shift in the tests otb_add_test(NAME trTvRPCTransformTest_pl_hnord_geom COMMAND otbTransformTestDriver otbRPCTransformTest ${INPUTDATA}/pleiades/pleiades-1.geom # Geom @@ -110,6 +112,9 @@ otb_add_test(NAME trTvRPCTransformTest_pl_hnord_geom COMMAND otbTransformTestDri 0.5 # sampleOffset ) +#For issue 2293, we had to regenerate the baseline pleiades-1.gcp2 because there was a shift +#in the gcps that was fixed by the MR 918 +#To regenerate the gcps, see the wiki on the gitlab otb_add_test(NAME trTvRPCTransformTest_pl_hnord_product COMMAND otbTransformTestDriver otbRPCTransformTest LARGEINPUT{PLEIADES/TLSE_JP2_DIMAPv2_PRIMARY_PMS_lossless_12bits/IMGPHR_201222215194743808/IMG_PHR1A_PMS_201201151100183_SEN_IPU_20120222_0901-001_R1C1.JP2} # Product diff --git a/Modules/IO/IOGDAL/test/CMakeLists.txt b/Modules/IO/IOGDAL/test/CMakeLists.txt index 083346ca67..27014d0850 100644 --- a/Modules/IO/IOGDAL/test/CMakeLists.txt +++ b/Modules/IO/IOGDAL/test/CMakeLists.txt @@ -604,6 +604,8 @@ otb_add_test(NAME ioTvGDALRPCTransformerTest_worldview2 0.1 # ImgTol ) +#For issue 2293, we had to regenerate the baseline pleaides-1.geom because there was a shift +#in the geom generated with OTB 7.4, the baseline was wrong. To keep the compatibility, we added this shift in the tests otb_add_test(NAME ioTvGDALRPCTransformerTest_pl_hnord_geom COMMAND otbIOGDALTestDriver otbGDALRPCTransformerTest2 @@ -615,6 +617,9 @@ otb_add_test(NAME ioTvGDALRPCTransformerTest_pl_hnord_geom 0.5 # sampleOffset ) +#For issue 2293, we had to regenerate the baseline pleiades-1.gcp2 because there was a shift +#in the gcps that was fixed by the MR 918 +#To regenerate the gcps, see the wiki on the gitlab otb_add_test(NAME ioTvGDALRPCTransformerTest_pl_hnord_product COMMAND otbIOGDALTestDriver otbGDALRPCTransformerTest2 -- GitLab