Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
Usgscsm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aflab
astrogeology
Usgscsm
Commits
a99be168
Unverified
Commit
a99be168
authored
6 years ago
by
K. Williams
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #95 from AstroKEW78/testCameraModel
Test camera model
parents
dd99b900
28b2ee69
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/FrameCameraTests.cpp
+108
-3
108 additions, 3 deletions
tests/FrameCameraTests.cpp
with
108 additions
and
3 deletions
tests/FrameCameraTests.cpp
+
108
−
3
View file @
a99be168
...
@@ -10,6 +10,29 @@
...
@@ -10,6 +10,29 @@
using
json
=
nlohmann
::
json
;
using
json
=
nlohmann
::
json
;
class
FrameIsdTest
:
public
::
testing
::
Test
{
protected:
csm
::
Isd
isd
;
virtual
void
SetUp
()
{
std
::
ifstream
isdFile
(
"data/simpleFramerISD.json"
);
json
jsonIsd
=
json
::
parse
(
isdFile
);
for
(
json
::
iterator
it
=
jsonIsd
.
begin
();
it
!=
jsonIsd
.
end
();
++
it
)
{
json
jsonValue
=
it
.
value
();
if
(
jsonValue
.
size
()
>
1
)
{
for
(
int
i
=
0
;
i
<
jsonValue
.
size
();
i
++
)
{
isd
.
addParam
(
it
.
key
(),
jsonValue
[
i
].
dump
());
}
}
else
{
isd
.
addParam
(
it
.
key
(),
jsonValue
.
dump
());
}
}
isdFile
.
close
();
}
};
class
FrameSensorModel
:
public
::
testing
::
Test
{
class
FrameSensorModel
:
public
::
testing
::
Test
{
protected:
protected:
...
@@ -52,8 +75,7 @@ class FrameSensorModel : public ::testing::Test {
...
@@ -52,8 +75,7 @@ class FrameSensorModel : public ::testing::Test {
}
}
};
};
//NOTE: The imagePt layour is (Lines,Samples)
//NOTE: The imagePt format is (Lines,Samples)
// Also subtract 0.5 from the lines/samples. Hence Samples=0 and Lines=15 -> 14.5,-0.5
//centered and slightly off-center:
//centered and slightly off-center:
TEST_F
(
FrameSensorModel
,
Center
)
{
TEST_F
(
FrameSensorModel
,
Center
)
{
...
@@ -101,3 +123,86 @@ TEST_F(FrameSensorModel, OffBody4) {
...
@@ -101,3 +123,86 @@ TEST_F(FrameSensorModel, OffBody4) {
EXPECT_NEAR
(
groundPt
.
z
,
-
14.99325304
,
1e-8
);
EXPECT_NEAR
(
groundPt
.
z
,
-
14.99325304
,
1e-8
);
}
}
// Focal Length Tests:
TEST_F
(
FrameIsdTest
,
FL500_OffBody4
)
{
std
::
string
key
=
"focal_length"
;
std
::
string
newValue
=
"500.0"
;
isd
.
clearParams
(
key
);
isd
.
addParam
(
key
,
newValue
);
UsgsAstroFramePlugin
frameCameraPlugin
;
csm
::
Model
*
model
=
frameCameraPlugin
.
constructModelFromISD
(
isd
,
"USGS_ASTRO_FRAME_SENSOR_MODEL"
);
UsgsAstroFrameSensorModel
*
sensorModel
=
dynamic_cast
<
UsgsAstroFrameSensorModel
*>
(
model
);
ASSERT_NE
(
sensorModel
,
nullptr
);
csm
::
ImageCoord
imagePt
(
15.0
,
15.0
);
csm
::
EcefCoord
groundPt
=
sensorModel
->
imageToGround
(
imagePt
,
0.0
);
EXPECT_NEAR
(
groundPt
.
x
,
9.77688917
,
1e-8
);
EXPECT_NEAR
(
groundPt
.
y
,
-
1.48533467
,
1e-8
);
EXPECT_NEAR
(
groundPt
.
z
,
-
1.48533467
,
1e-8
);
}
TEST_F
(
FrameIsdTest
,
FL500_OffBody3
)
{
std
::
string
key
=
"focal_length"
;
std
::
string
newValue
=
"500.0"
;
isd
.
clearParams
(
key
);
isd
.
addParam
(
key
,
newValue
);
UsgsAstroFramePlugin
frameCameraPlugin
;
csm
::
Model
*
model
=
frameCameraPlugin
.
constructModelFromISD
(
isd
,
"USGS_ASTRO_FRAME_SENSOR_MODEL"
);
UsgsAstroFrameSensorModel
*
sensorModel
=
dynamic_cast
<
UsgsAstroFrameSensorModel
*>
(
model
);
ASSERT_NE
(
sensorModel
,
nullptr
);
csm
::
ImageCoord
imagePt
(
0.0
,
0.0
);
csm
::
EcefCoord
groundPt
=
sensorModel
->
imageToGround
(
imagePt
,
0.0
);
EXPECT_NEAR
(
groundPt
.
x
,
9.77688917
,
1e-8
);
EXPECT_NEAR
(
groundPt
.
y
,
1.48533467
,
1e-8
);
EXPECT_NEAR
(
groundPt
.
z
,
1.48533467
,
1e-8
);
}
TEST_F
(
FrameIsdTest
,
FL500_Center
)
{
std
::
string
key
=
"focal_length"
;
std
::
string
newValue
=
"500.0"
;
isd
.
clearParams
(
key
);
isd
.
addParam
(
key
,
newValue
);
UsgsAstroFramePlugin
frameCameraPlugin
;
csm
::
Model
*
model
=
frameCameraPlugin
.
constructModelFromISD
(
isd
,
"USGS_ASTRO_FRAME_SENSOR_MODEL"
);
UsgsAstroFrameSensorModel
*
sensorModel
=
dynamic_cast
<
UsgsAstroFrameSensorModel
*>
(
model
);
ASSERT_NE
(
sensorModel
,
nullptr
);
csm
::
ImageCoord
imagePt
(
7.5
,
7.5
);
csm
::
EcefCoord
groundPt
=
sensorModel
->
imageToGround
(
imagePt
,
0.0
);
EXPECT_NEAR
(
groundPt
.
x
,
10.0
,
1e-8
);
EXPECT_NEAR
(
groundPt
.
y
,
0.0
,
1e-8
);
EXPECT_NEAR
(
groundPt
.
z
,
0.0
,
1e-8
);
}
TEST_F
(
FrameIsdTest
,
FL500_SlightlyOffCenter
)
{
std
::
string
key
=
"focal_length"
;
std
::
string
newValue
=
"500.0"
;
isd
.
clearParams
(
key
);
isd
.
addParam
(
key
,
newValue
);
UsgsAstroFramePlugin
frameCameraPlugin
;
csm
::
Model
*
model
=
frameCameraPlugin
.
constructModelFromISD
(
isd
,
"USGS_ASTRO_FRAME_SENSOR_MODEL"
);
UsgsAstroFrameSensorModel
*
sensorModel
=
dynamic_cast
<
UsgsAstroFrameSensorModel
*>
(
model
);
ASSERT_NE
(
sensorModel
,
nullptr
);
csm
::
ImageCoord
imagePt
(
7.5
,
6.5
);
csm
::
EcefCoord
groundPt
=
sensorModel
->
imageToGround
(
imagePt
,
0.0
);
EXPECT_NEAR
(
groundPt
.
x
,
9.99803960
,
1e-8
);
EXPECT_NEAR
(
groundPt
.
y
,
0.0
,
1e-8
);
EXPECT_NEAR
(
groundPt
.
z
,
1.98000392e-01
,
1e-8
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment