Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Main Repositories
otb
Commits
e8cced54
Commit
e8cced54
authored
Jan 28, 2021
by
Julien Osman
Browse files
TEST: Add test for GenericRSTransform
parent
7755fbcc
Pipeline
#6660
failed with stages
in 87 minutes and 59 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Modules/Core/Transform/test/CMakeLists.txt
View file @
e8cced54
...
...
@@ -101,7 +101,7 @@ otb_add_test(NAME trTvRPCTransformTest_worldview2 COMMAND otbTransformTestDriver
0.1
# ImgTol
)
otb_add_test
(
NAME trTvRPCTransformTest_pl_hnord COMMAND otbTransformTestDriver
otb_add_test
(
NAME trTvRPCTransformTest_pl_hnord
_geom
COMMAND otbTransformTestDriver
otbRPCTransformTest
${
INPUTDATA
}
/pleiades/pleiades-1.geom
# Geom
${
INPUTDATA
}
/pleiades/pleiades-1.gcp2
# GCP
...
...
@@ -109,6 +109,14 @@ otb_add_test(NAME trTvRPCTransformTest_pl_hnord COMMAND otbTransformTestDriver
0.1
# ImgTol
)
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
${
INPUTDATA
}
/pleiades/pleiades-1.gcp2
# GCP
0.02
# GeoTol
0.1
# ImgTol
)
otb_add_test
(
NAME bfTvLogPolarTransformResample COMMAND otbTransformTestDriver
--compare-image
${
EPSILON_7
}
${
BASELINE
}
/bfLogPolarTransformResampleOutput.tif
${
TEMP
}
/bfLogPolarTransformResampleOutput.tif
...
...
Modules/Core/Transform/test/otbRPCTransformTest.cxx
View file @
e8cced54
...
...
@@ -31,11 +31,13 @@
#include
"otbImageFileReader.h"
#include
"otbRPCForwardTransform.h"
#include
"otbRPCInverseTransform.h"
#include
"otbGenericRSTransform.h"
using
PointType
=
itk
::
Point
<
double
,
3
>
;
using
PointsContainerType
=
std
::
vector
<
PointType
>
;
using
ForwardTransformType
=
otb
::
RPCForwardTransform
<
double
,
3
,
3
>
;
using
InverseTransformType
=
otb
::
RPCInverseTransform
<
double
,
3
,
3
>
;
using
GenericRSTransformType
=
otb
::
GenericRSTransform
<
double
,
3
,
3
>
;
using
DistanceType
=
itk
::
Statistics
::
EuclideanDistanceMetric
<
PointType
>
;
using
GeographicalDistanceType
=
otb
::
GeographicalDistance
<
PointType
>
;
...
...
@@ -52,8 +54,12 @@ int otbRPCTransformTest(int itkNotUsed(argc), char* argv[])
double
imgTol
(
atof
(
argv
[
4
]));
// Tools
auto
d
istance
=
DistanceType
::
New
();
auto
imgD
istance
=
DistanceType
::
New
();
auto
geoDistance
=
GeographicalDistanceType
::
New
();
OGRSpatialReference
oSRS
;
oSRS
.
SetWellKnownGeogCS
(
"WGS84"
);
char
*
wgsRef
=
nullptr
;
oSRS
.
exportToWkt
(
&
wgsRef
);
otb
::
ImageMetadata
imd
;
if
(
0
==
rpcFile
.
compare
(
rpcFile
.
length
()
-
4
,
4
,
"geom"
))
...
...
@@ -75,14 +81,28 @@ int otbRPCTransformTest(int itkNotUsed(argc), char* argv[])
reader
->
SetFileName
(
rpcFile
);
reader
->
UpdateOutputInformation
();
imd
=
reader
->
GetOutput
()
->
GetImageMetadata
();
imd
.
Remove
(
otb
::
MDGeom
::
ProjectionWKT
);
}
// Setting the
forward and inverse
transform
// Setting the transform
s
auto
ForwardTransform
=
ForwardTransformType
::
New
();
ForwardTransform
->
SetMetadata
(
imd
);
auto
InverseTransform
=
InverseTransformType
::
New
();
InverseTransform
->
SetMetadata
(
imd
);
auto
GenericRSTransform_img2wgs
=
GenericRSTransformType
::
New
();
GenericRSTransform_img2wgs
->
SetInputProjectionRef
(
""
);
GenericRSTransform_img2wgs
->
SetOutputProjectionRef
(
wgsRef
);
GenericRSTransform_img2wgs
->
SetInputImageMetadata
(
&
imd
);
GenericRSTransform_img2wgs
->
InstantiateTransform
();
auto
GenericRSTransform_wgs2img
=
GenericRSTransformType
::
New
();
GenericRSTransform_wgs2img
->
SetInputProjectionRef
(
wgsRef
);
GenericRSTransform_wgs2img
->
SetOutputProjectionRef
(
""
);
GenericRSTransform_wgs2img
->
SetOutputImageMetadata
(
&
imd
);
GenericRSTransform_wgs2img
->
InstantiateTransform
();
// Loading the GCP
PointsContainerType
pointsContainer
;
PointsContainerType
geo3dPointsContainer
;
...
...
@@ -107,32 +127,54 @@ int otbRPCTransformTest(int itkNotUsed(argc), char* argv[])
}
// For each CGP
double
distance
;
for
(
PointsContainerType
::
iterator
pointsIt
=
pointsContainer
.
begin
(),
geo3dPointsIt
=
geo3dPointsContainer
.
begin
()
;
(
pointsIt
!=
pointsContainer
.
end
())
&&
(
geo3dPointsIt
!=
geo3dPointsContainer
.
end
())
;
++
pointsIt
,
++
geo3dPointsIt
)
{
// std::cout << "Point: " << *pointsIt << " GeoPoint: " << *geo3dPointsIt << "\n";
// Testing forward transform
geo3dPoint
=
ForwardTransform
->
TransformPoint
(
*
pointsIt
);
auto
forwardPointDistance
=
geoDistance
->
Evaluate
(
geo3dPoint
,
*
geo3dPointsIt
);
if
(
forwardPointDistance
>
geoTol
)
// geo3dPoint = ForwardTransform->TransformPoint(*pointsIt);
// distance = geoDistance->Evaluate(geo3dPoint, *geo3dPointsIt);
// if (distance > geoTol)
// {
// std::cerr << "Geo distance between ForwardTransform->TransformPoint and GCP too high :\n"
// << "GCP: " << *geo3dPointsIt << " / computed: " << geo3dPoint << "\n"
// << "dist = " << distance << " (tol = " << geoTol << ")" << std::endl;
// success = false;
// }
// // Testing inverse transform
// imagePoint = InverseTransform->TransformPoint(*geo3dPointsIt);
// distance = imgDistance->Evaluate(imagePoint, *pointsIt);
// if (distance > imgTol)
// {
// std::cerr << "Distance between InverseTransform->TransformPoint and GCP too high :\n"
// << "GCP: " << *pointsIt << " / computed: " << imagePoint << "\n"
// << "dist = " << distance << " (tol = " << imgTol << ")" << std::endl;
// success = false;
// }
// Testing image to wgs transform
geo3dPoint
=
GenericRSTransform_img2wgs
->
TransformPoint
(
*
pointsIt
);
distance
=
geoDistance
->
Evaluate
(
geo3dPoint
,
*
geo3dPointsIt
);
if
(
distance
>
geoTol
)
{
std
::
cerr
<<
"Geo distance between
Forward
Transform->TransformPoint and GCP too high :
\n
"
std
::
cerr
<<
"Geo distance between
GenericRS
Transform
_img2wgs
->TransformPoint and GCP too high :
\n
"
<<
"GCP: "
<<
*
geo3dPointsIt
<<
" / computed: "
<<
geo3dPoint
<<
"
\n
"
<<
"dist = "
<<
forwardPointD
istance
<<
" (tol = "
<<
geoTol
<<
")"
<<
std
::
endl
;
<<
"dist = "
<<
d
istance
<<
" (tol = "
<<
geoTol
<<
")"
<<
std
::
endl
;
success
=
false
;
}
// Testing
invers
e transform
imagePoint
=
Inverse
Transform
->
TransformPoint
(
*
geo3dPointsIt
);
auto
inversePointD
istance
=
d
istance
->
Evaluate
(
imagePoint
,
*
pointsIt
);
if
(
inversePointD
istance
>
imgTol
)
{
std
::
cerr
<<
"Distance between
Inverse
Transform->TransformPoint and GCP too high :
\n
"
<<
"GCP: "
<<
*
pointsIt
<<
" / computed: "
<<
imagePoint
<<
"
\n
"
<<
"dist = "
<<
inversePointD
istance
<<
" (tol = "
<<
imgTol
<<
")"
<<
std
::
endl
;
success
=
false
;
}
// Testing
wgs to imag
e transform
//
imagePoint =
GenericRS
Transform
_wgs2img
->TransformPoint(*geo3dPointsIt);
// d
istance =
imgD
istance->Evaluate(imagePoint, *pointsIt);
//
if (
d
istance > imgTol)
//
{
//
std::cerr << "Distance between
GenericRS
Transform
_wgs2img
->TransformPoint and GCP too high :\n"
//
<< "GCP: " << *pointsIt << " / computed: " << imagePoint << "\n"
//
<< "dist = " <<
d
istance << " (tol = " << imgTol << ")" << std::endl;
//
success = false;
//
}
}
if
(
success
)
...
...
Modules/IO/IOGDAL/test/CMakeLists.txt
View file @
e8cced54
...
...
@@ -264,70 +264,71 @@ foreach(INPUTFILE_PIXELTYPE ${INPUTFILE_PIXELTYPES_LIST})
endforeach
()
otb_add_test
(
NAME TuGDALRPCTransformerTest
COMMAND otbIOGDALTestDriver
otbGDALRPCTransformerTest
${
INPUTDATA
}
/TuGDALRPCTransformerTest_DEM.tif
)
COMMAND otbIOGDALTestDriver
otbGDALRPCTransformerTest
${
INPUTDATA
}
/TuGDALRPCTransformerTest_DEM.tif
)
otb_add_test
(
NAME ioTvGDALRPCTransformerTest_ikonos_geom
COMMAND otbIOGDALTestDriver
otbGDALRPCTransformerTest2
${
INPUTDATA
}
/ikonos/ikonos-1.geom
# Geom
${
INPUTDATA
}
/ikonos/ikonos-1.gcp2
# GCP
0.04
# GeoTol
0.1
# ImgTol
)
COMMAND otbIOGDALTestDriver
otbGDALRPCTransformerTest2
${
INPUTDATA
}
/ikonos/ikonos-1.geom
# Geom
${
INPUTDATA
}
/ikonos/ikonos-1.gcp2
# GCP
0.04
# GeoTol
0.1
# ImgTol
)
otb_add_test
(
NAME ioTvGDALRPCTransformerTest_ikonos_product
COMMAND otbIOGDALTestDriver
otbGDALRPCTransformerTest2
LARGEINPUT{IKONOS/BLOSSEVILLE/po_2619900_blu_0000000.tif}
# Product
${
INPUTDATA
}
/ikonos/ikonos-1.gcp2
# GCP
0.04
# GeoTol
0.1
# ImgTol
)
COMMAND otbIOGDALTestDriver
otbGDALRPCTransformerTest2
LARGEINPUT{IKONOS/BLOSSEVILLE/po_2619900_blu_0000000.tif}
# Product
${
INPUTDATA
}
/ikonos/ikonos-1.gcp2
# GCP
0.04
# GeoTol
0.1
# ImgTol
)
otb_add_test
(
NAME ioTvGDALRPCTransformerTest_quickbird
COMMAND otbIOGDALTestDriver
otbGDALRPCTransformerTest2
${
INPUTDATA
}
/QB/qb-1.geom
# Geom
${
INPUTDATA
}
/QB/qb-1.gcp2
# GCP
0.024
# GeoTol
0.1
# ImgTol
)
COMMAND otbIOGDALTestDriver
otbGDALRPCTransformerTest2
${
INPUTDATA
}
/QB/qb-1.geom
# Geom
${
INPUTDATA
}
/QB/qb-1.gcp2
# GCP
0.024
# GeoTol
0.1
# ImgTol
)
otb_add_test
(
NAME ioTvGDALRPCTransformerTest_spot6
COMMAND otbIOGDALTestDriver
otbGDALRPCTransformerTest2
${
INPUTDATA
}
/spot6/spot6-1.geom
# Geom
${
INPUTDATA
}
/spot6/spot6-1.gcp2
# GCP
0.06
# GeoTol
0.1
# ImgTol
)
COMMAND otbIOGDALTestDriver
otbGDALRPCTransformerTest2
${
INPUTDATA
}
/spot6/spot6-1.geom
# Geom
${
INPUTDATA
}
/spot6/spot6-1.gcp2
# GCP
0.06
# GeoTol
0.1
# ImgTol
)
otb_add_test
(
NAME ioTvGDALRPCTransformerTest_worldview2
COMMAND otbIOGDALTestDriver
otbGDALRPCTransformerTest2
${
INPUTDATA
}
/wv2/wv2-1.geom
# Geom
${
INPUTDATA
}
/wv2/wv2-1.gcp2
# GCP
0.0185
# GeoTol
0.1
# ImgTol
)
COMMAND otbIOGDALTestDriver
otbGDALRPCTransformerTest2
${
INPUTDATA
}
/wv2/wv2-1.geom
# Geom
${
INPUTDATA
}
/wv2/wv2-1.gcp2
# GCP
0.0185
# GeoTol
0.1
# ImgTol
)
otb_add_test
(
NAME ioTvGDALRPCTransformerTest_pl_hnord_geom
COMMAND otbIOGDALTestDriver
otbGDALRPCTransformerTest2
${
INPUTDATA
}
/pleiades/pleiades-1.geom
# Geom
${
INPUTDATA
}
/pleiades/pleiades-1.gcp2
# GCP
0.02
# GeoTol
0.1
# ImgTol
)
COMMAND otbIOGDALTestDriver
otbGDALRPCTransformerTest2
${
INPUTDATA
}
/pleiades/pleiades-1.geom
# Geom
${
INPUTDATA
}
/pleiades/pleiades-1.gcp2
# GCP
0.02
# GeoTol
0.1
# ImgTol
)
otb_add_test
(
NAME ioTvGDALRPCTransformerTest_pl_hnord_product
COMMAND otbIOGDALTestDriver
otbGDALRPCTransformerTest2
LARGEINPUT{PLEIADES/TLSE_JP2_DIMAPv2_PRIMARY_PMS_lossless_12bits/IMGPHR_201222215194743808/IMG_PHR1A_PMS_201201151100183_SEN_IPU_20120222_0901-001_R1C1.JP2}
${
INPUTDATA
}
/pleiades/pleiades-1.gcp2
# GCP
0.02
# GeoTol
0.1
# ImgTol
)
COMMAND otbIOGDALTestDriver
otbGDALRPCTransformerTest2
LARGEINPUT{PLEIADES/TLSE_JP2_DIMAPv2_PRIMARY_PMS_lossless_12bits/IMGPHR_201222215194743808/IMG_PHR1A_PMS_201201151100183_SEN_IPU_20120222_0901-001_R1C1.JP2}
# Product
${
INPUTDATA
}
/pleiades/pleiades-1.gcp2
# GCP
0.02
# GeoTol
0.1
# ImgTol
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment