Skip to content
Snippets Groups Projects
Unverified Commit a99be168 authored by K. Williams's avatar K. Williams Committed by GitHub
Browse files

Merge pull request #95 from AstroKEW78/testCameraModel

Test camera model
parents dd99b900 28b2ee69
Branches
Tags
No related merge requests found
...@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment