-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test camera model #95
Changes from 4 commits
8a2b780
4986276
f8238d0
08c48f8
cb074f3
28b2ee6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,11 +10,33 @@ | |
|
||
using json = nlohmann::json; | ||
|
||
class FrameIsdTest : public ::testing::Test { | ||
protected: | ||
|
||
|
||
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(); | ||
} | ||
}; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. code copy and paste will be removed once Fixtures.h files gets merged. |
||
class FrameSensorModel : public ::testing::Test { | ||
protected: | ||
|
||
UsgsAstroFrameSensorModel *sensorModel; | ||
|
||
csm::Isd isd; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be removed |
||
void SetUp() override { | ||
sensorModel = NULL; | ||
std::ifstream isdFile("data/simpleFramerISD.json"); | ||
|
@@ -57,14 +79,14 @@ class FrameSensorModel : public ::testing::Test { | |
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can yank this comment, since this is fixed. |
||
//centered and slightly off-center: | ||
TEST_F(FrameSensorModel, Center) { | ||
csm::ImageCoord imagePt(7.0, 7.0); | ||
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, 1e-8); | ||
EXPECT_NEAR(groundPt.z, 0, 1e-8); | ||
} | ||
TEST_F(FrameSensorModel, SlightlyOffCenter) { | ||
csm::ImageCoord imagePt(7.0, 6.0); | ||
csm::ImageCoord imagePt(7.5, 6.5); | ||
csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0); | ||
EXPECT_NEAR(groundPt.x, 9.80194018, 1e-8); | ||
EXPECT_NEAR(groundPt.y, 0, 1e-8); | ||
|
@@ -73,31 +95,106 @@ TEST_F(FrameSensorModel, SlightlyOffCenter) { | |
|
||
//Test all four corners: | ||
TEST_F(FrameSensorModel, OffBody1) { | ||
csm::ImageCoord imagePt(14.5, -0.5); | ||
csm::ImageCoord imagePt(15.0, 0.0); | ||
csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0); | ||
EXPECT_NEAR(groundPt.x, 0.44979759, 1e-8); | ||
EXPECT_NEAR(groundPt.y, -14.99325304, 1e-8); | ||
EXPECT_NEAR(groundPt.z, 14.99325304, 1e-8); | ||
} | ||
TEST_F(FrameSensorModel, OffBody2) { | ||
csm::ImageCoord imagePt(-0.5, 14.5); | ||
csm::ImageCoord imagePt(0.0, 15.0); | ||
csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0); | ||
EXPECT_NEAR(groundPt.x, 0.44979759, 1e-8); | ||
EXPECT_NEAR(groundPt.y, 14.99325304, 1e-8); | ||
EXPECT_NEAR(groundPt.z, -14.99325304, 1e-8); | ||
} | ||
TEST_F(FrameSensorModel, OffBody3) { | ||
csm::ImageCoord imagePt(-0.5, -0.5); | ||
csm::ImageCoord imagePt(0.0, 0.0); | ||
csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0); | ||
EXPECT_NEAR(groundPt.x, 0.44979759, 1e-8); | ||
EXPECT_NEAR(groundPt.y, 14.99325304, 1e-8); | ||
EXPECT_NEAR(groundPt.z, 14.99325304, 1e-8); | ||
} | ||
TEST_F(FrameSensorModel, OffBody4) { | ||
csm::ImageCoord imagePt(14.5, 14.5); | ||
csm::ImageCoord imagePt(15.0, 15.0); | ||
csm::EcefCoord groundPt = sensorModel->imageToGround(imagePt, 0.0); | ||
EXPECT_NEAR(groundPt.x, 0.44979759, 1e-8); | ||
EXPECT_NEAR(groundPt.y, -14.99325304, 1e-8); | ||
EXPECT_NEAR(groundPt.z, -14.99325304, 1e-8); | ||
} | ||
|
||
|
||
// Focal Length Tests: | ||
TEST_F(FrameIsdTest, FL500_OffBody4) { | ||
isd.clearParams("focal_length"); | ||
isd.addParam("focal_length","500.0"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This super nit picky. Can we use a single variable for the key? std::string key = "focal_length"? This will make refactoring later easier and is better form I think to help maintain these. |
||
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) { | ||
isd.clearParams("focal_length"); | ||
isd.addParam("focal_length","500.0"); | ||
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) { | ||
isd.clearParams("focal_length"); | ||
isd.addParam("focal_length","500.0"); | ||
UsgsAstroFramePlugin frameCameraPlugin; | ||
|
||
csm::Model *model = frameCameraPlugin.constructModelFromISD( | ||
isd, | ||
"USGS_ASTRO_FRAME_SENSOR_MODEL"); | ||
|
||
UsgsAstroFrameSensorModel* sensorModel = dynamic_cast<UsgsAstroFrameSensorModel *>(model); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All these repeated instantiations look good. We can refactor out once parameterized tests are working the way we want them to. |
||
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) { | ||
isd.clearParams("focal_length"); | ||
isd.addParam("focal_length","500.0"); | ||
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); | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could have sworn this was already merged by #91 weird
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I bet that upstream was not pulled and merged, so we are seeing both.