Loading src/UsgsAstroFramePlugin.cpp +29 −23 Original line number Diff line number Diff line Loading @@ -400,27 +400,18 @@ csm::Model *UsgsAstroFramePlugin::constructModelFromISD(const csm::Isd &imageSup missingKeywords.push_back("sensor_orientation"); } sensorModel->m_odtX[0] = atof(imageSupportData.param("optical_distortion_x", 0).c_str()); sensorModel->m_odtX[1] = atof(imageSupportData.param("optical_distortion_x", 1).c_str()); sensorModel->m_odtX[2] = atof(imageSupportData.param("optical_distortion_x", 2).c_str()); sensorModel->m_odtX[3] = atof(imageSupportData.param("optical_distortion_x", 3).c_str()); sensorModel->m_odtX[4] = atof(imageSupportData.param("optical_distortion_x", 4).c_str()); sensorModel->m_odtX[5] = atof(imageSupportData.param("optical_distortion_x", 5).c_str()); sensorModel->m_odtX[6] = atof(imageSupportData.param("optical_distortion_x", 6).c_str()); sensorModel->m_odtX[7] = atof(imageSupportData.param("optical_distortion_x", 7).c_str()); sensorModel->m_odtX[8] = atof(imageSupportData.param("optical_distortion_x", 8).c_str()); sensorModel->m_odtX[9] = atof(imageSupportData.param("optical_distortion_x", 9).c_str()); sensorModel->m_odtY[0] = atof(imageSupportData.param("optical_distortion_y", 0).c_str()); sensorModel->m_odtY[1] = atof(imageSupportData.param("optical_distortion_y", 1).c_str()); sensorModel->m_odtY[2] = atof(imageSupportData.param("optical_distortion_y", 2).c_str()); sensorModel->m_odtY[3] = atof(imageSupportData.param("optical_distortion_y", 3).c_str()); sensorModel->m_odtY[4] = atof(imageSupportData.param("optical_distortion_y", 4).c_str()); sensorModel->m_odtY[5] = atof(imageSupportData.param("optical_distortion_y", 5).c_str()); sensorModel->m_odtY[6] = atof(imageSupportData.param("optical_distortion_y", 6).c_str()); sensorModel->m_odtY[7] = atof(imageSupportData.param("optical_distortion_y", 7).c_str()); sensorModel->m_odtY[8] = atof(imageSupportData.param("optical_distortion_y", 8).c_str()); sensorModel->m_odtY[9] = atof(imageSupportData.param("optical_distortion_y", 9).c_str()); if (imageSupportData.param("optical_distortion") == "") { missingKeywords.push_back("optical_distortion"); } else { json jayson = json::parse(imageSupportData.param("optical_distortion")); std::vector<double> xDistortion = jayson["x"]; std::vector<double> yDistortion = jayson["y"]; xDistortion.resize(10, 0.0); yDistortion.resize(10, 0.0); sensorModel->m_odtX = xDistortion; sensorModel->m_odtY = yDistortion; } sensorModel->m_ephemerisTime = atof(imageSupportData.param("center_ephemeris_time").c_str()); if (imageSupportData.param("center_ephemeris_time") == "") { Loading @@ -444,8 +435,8 @@ csm::Model *UsgsAstroFramePlugin::constructModelFromISD(const csm::Isd &imageSup json sample = jayson.value("sample", json("")); json line = jayson.value("line", json("")); sensorModel->m_ccdCenter[0] = atof(sample.dump().c_str()); sensorModel->m_ccdCenter[1] = atof(line.dump().c_str()); sensorModel->m_ccdCenter[0] = atof(line.dump().c_str()); sensorModel->m_ccdCenter[1] = atof(sample.dump().c_str()); if (sample == json("")) { missingKeywords.push_back("detector_center x"); Loading Loading @@ -483,6 +474,21 @@ csm::Model *UsgsAstroFramePlugin::constructModelFromISD(const csm::Isd &imageSup missingKeywords.push_back("focal2pixel_samples 2"); } // We don't pass the pixel to focal plane transformation so invert the // focal plane to pixel transformation double determinant = sensorModel->m_iTransL[1] * sensorModel->m_iTransS[2] - sensorModel->m_iTransL[2] * sensorModel->m_iTransS[1]; sensorModel->m_transX[1] = sensorModel->m_iTransL[1] / determinant; sensorModel->m_transX[2] = - sensorModel->m_iTransS[1] / determinant; sensorModel->m_transX[0] = - (sensorModel->m_transX[1] * sensorModel->m_iTransL[0] + sensorModel->m_transX[2] * sensorModel->m_iTransS[0]); sensorModel->m_transY[1] = - sensorModel->m_iTransL[2] / determinant; sensorModel->m_transY[2] = sensorModel->m_iTransS[2] / determinant; sensorModel->m_transY[0] = - (sensorModel->m_transY[1] * sensorModel->m_iTransL[0] + sensorModel->m_transY[2] * sensorModel->m_iTransS[0]); if (imageSupportData.param("radii") == "") { missingKeywords.push_back("radii"); } Loading src/UsgsAstroFrameSensorModel.cpp +11 −11 Original line number Diff line number Diff line Loading @@ -198,8 +198,8 @@ csm::ImageCoord UsgsAstroFrameSensorModel::groundToImage( //Convert distorted mm into line/sample double sample, line; sample = m_iTransS[0] + m_iTransS[1] * distortedx + m_iTransS[2] * distortedx + m_ccdCenter[0] - 0.5; line = m_iTransL[0] + m_iTransL[1] * distortedy + m_iTransL[2] * distortedy + m_ccdCenter[0] - 0.5; sample = m_iTransS[0] + m_iTransS[1] * distortedx + m_iTransS[2] * distortedy + m_ccdCenter[1]; line = m_iTransL[0] + m_iTransL[1] * distortedx + m_iTransL[2] * distortedy + m_ccdCenter[0]; return csm::ImageCoord(line, sample); } Loading Loading @@ -235,11 +235,11 @@ csm::EcefCoord UsgsAstroFrameSensorModel::imageToGround(const csm::ImageCoord &i so = sample - m_sample_pp; //Convert from the pixel space into the metric space double optical_center_x, optical_center_y, x_camera, y_camera; optical_center_x = m_ccdCenter[0] - 0.5; optical_center_y = m_ccdCenter[1] - 0.5; y_camera = m_transY[0] + m_transY[1] * (lo - optical_center_y) + m_transY[2] * (lo - optical_center_y); x_camera = m_transX[0] + m_transX[1] * (so - optical_center_x) + m_transX[2] * (so - optical_center_x); double line_center, sample_center, x_camera, y_camera; line_center = m_ccdCenter[0]; sample_center = m_ccdCenter[1]; y_camera = m_transY[0] + m_transY[1] * (lo - line_center) + m_transY[2] * (so - sample_center); x_camera = m_transX[0] + m_transX[1] * (lo - line_center) + m_transX[2] * (so - sample_center); // Apply the distortion model (remove distortion) double undistorted_cameraX, undistorted_cameraY = 0.0; Loading Loading @@ -293,10 +293,10 @@ csm::EcefLocus UsgsAstroFrameSensorModel::imageToRemoteImagingLocus(const csm::I csm::WarningList *warnings) const { // Find the line,sample on the focal plane (mm) // CSM center = 0.5, MDIS IK center = 1.0 double col = imagePt.samp - (m_ccdCenter[0] - 0.5); double row = imagePt.line - (m_ccdCenter[1] - 0.5); double focalPlaneX = m_transX[0] + m_transX[1] * col + m_transX[2] * col; double focalPlaneY = m_transY[0] + m_transY[1] * row + m_transY[2] * row; double row = imagePt.line - m_ccdCenter[0]; double col = imagePt.samp - m_ccdCenter[1]; double focalPlaneX = m_transX[0] + m_transX[1] * row + m_transX[2] * col; double focalPlaneY = m_transY[0] + m_transY[1] * row + m_transY[2] * col; // Distort double undistortedFocalPlaneX = focalPlaneX; Loading tests/FrameCameraTests.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ //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); Loading @@ -21,7 +21,7 @@ TEST_F(FrameSensorModel, Center) { } 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); Loading @@ -30,28 +30,28 @@ 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); Loading tests/data/simpleFramerISD.json +4 −4 Original line number Diff line number Diff line { "center_ephemeris_time": 50, "dt_ephemeris": 100, "focal2pixel_lines": [-7.5, 0.0, 0.1], "focal2pixel_samples": [-7.5, 0.1, 0.0], "focal2pixel_lines": [0.0, 0.0, 10.0], "focal2pixel_samples": [0.0, 10.0, 0.0], "focal_length_model": { "focal_length": 50, "epsilon": 1.0 Loading @@ -16,8 +16,8 @@ "interpolation_method": "lagrange", "number_of_ephemerides": 1, "optical_distortion": { "x": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] "x": [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "y": [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] }, "radii": { "semimajor": 0.01, Loading Loading
src/UsgsAstroFramePlugin.cpp +29 −23 Original line number Diff line number Diff line Loading @@ -400,27 +400,18 @@ csm::Model *UsgsAstroFramePlugin::constructModelFromISD(const csm::Isd &imageSup missingKeywords.push_back("sensor_orientation"); } sensorModel->m_odtX[0] = atof(imageSupportData.param("optical_distortion_x", 0).c_str()); sensorModel->m_odtX[1] = atof(imageSupportData.param("optical_distortion_x", 1).c_str()); sensorModel->m_odtX[2] = atof(imageSupportData.param("optical_distortion_x", 2).c_str()); sensorModel->m_odtX[3] = atof(imageSupportData.param("optical_distortion_x", 3).c_str()); sensorModel->m_odtX[4] = atof(imageSupportData.param("optical_distortion_x", 4).c_str()); sensorModel->m_odtX[5] = atof(imageSupportData.param("optical_distortion_x", 5).c_str()); sensorModel->m_odtX[6] = atof(imageSupportData.param("optical_distortion_x", 6).c_str()); sensorModel->m_odtX[7] = atof(imageSupportData.param("optical_distortion_x", 7).c_str()); sensorModel->m_odtX[8] = atof(imageSupportData.param("optical_distortion_x", 8).c_str()); sensorModel->m_odtX[9] = atof(imageSupportData.param("optical_distortion_x", 9).c_str()); sensorModel->m_odtY[0] = atof(imageSupportData.param("optical_distortion_y", 0).c_str()); sensorModel->m_odtY[1] = atof(imageSupportData.param("optical_distortion_y", 1).c_str()); sensorModel->m_odtY[2] = atof(imageSupportData.param("optical_distortion_y", 2).c_str()); sensorModel->m_odtY[3] = atof(imageSupportData.param("optical_distortion_y", 3).c_str()); sensorModel->m_odtY[4] = atof(imageSupportData.param("optical_distortion_y", 4).c_str()); sensorModel->m_odtY[5] = atof(imageSupportData.param("optical_distortion_y", 5).c_str()); sensorModel->m_odtY[6] = atof(imageSupportData.param("optical_distortion_y", 6).c_str()); sensorModel->m_odtY[7] = atof(imageSupportData.param("optical_distortion_y", 7).c_str()); sensorModel->m_odtY[8] = atof(imageSupportData.param("optical_distortion_y", 8).c_str()); sensorModel->m_odtY[9] = atof(imageSupportData.param("optical_distortion_y", 9).c_str()); if (imageSupportData.param("optical_distortion") == "") { missingKeywords.push_back("optical_distortion"); } else { json jayson = json::parse(imageSupportData.param("optical_distortion")); std::vector<double> xDistortion = jayson["x"]; std::vector<double> yDistortion = jayson["y"]; xDistortion.resize(10, 0.0); yDistortion.resize(10, 0.0); sensorModel->m_odtX = xDistortion; sensorModel->m_odtY = yDistortion; } sensorModel->m_ephemerisTime = atof(imageSupportData.param("center_ephemeris_time").c_str()); if (imageSupportData.param("center_ephemeris_time") == "") { Loading @@ -444,8 +435,8 @@ csm::Model *UsgsAstroFramePlugin::constructModelFromISD(const csm::Isd &imageSup json sample = jayson.value("sample", json("")); json line = jayson.value("line", json("")); sensorModel->m_ccdCenter[0] = atof(sample.dump().c_str()); sensorModel->m_ccdCenter[1] = atof(line.dump().c_str()); sensorModel->m_ccdCenter[0] = atof(line.dump().c_str()); sensorModel->m_ccdCenter[1] = atof(sample.dump().c_str()); if (sample == json("")) { missingKeywords.push_back("detector_center x"); Loading Loading @@ -483,6 +474,21 @@ csm::Model *UsgsAstroFramePlugin::constructModelFromISD(const csm::Isd &imageSup missingKeywords.push_back("focal2pixel_samples 2"); } // We don't pass the pixel to focal plane transformation so invert the // focal plane to pixel transformation double determinant = sensorModel->m_iTransL[1] * sensorModel->m_iTransS[2] - sensorModel->m_iTransL[2] * sensorModel->m_iTransS[1]; sensorModel->m_transX[1] = sensorModel->m_iTransL[1] / determinant; sensorModel->m_transX[2] = - sensorModel->m_iTransS[1] / determinant; sensorModel->m_transX[0] = - (sensorModel->m_transX[1] * sensorModel->m_iTransL[0] + sensorModel->m_transX[2] * sensorModel->m_iTransS[0]); sensorModel->m_transY[1] = - sensorModel->m_iTransL[2] / determinant; sensorModel->m_transY[2] = sensorModel->m_iTransS[2] / determinant; sensorModel->m_transY[0] = - (sensorModel->m_transY[1] * sensorModel->m_iTransL[0] + sensorModel->m_transY[2] * sensorModel->m_iTransS[0]); if (imageSupportData.param("radii") == "") { missingKeywords.push_back("radii"); } Loading
src/UsgsAstroFrameSensorModel.cpp +11 −11 Original line number Diff line number Diff line Loading @@ -198,8 +198,8 @@ csm::ImageCoord UsgsAstroFrameSensorModel::groundToImage( //Convert distorted mm into line/sample double sample, line; sample = m_iTransS[0] + m_iTransS[1] * distortedx + m_iTransS[2] * distortedx + m_ccdCenter[0] - 0.5; line = m_iTransL[0] + m_iTransL[1] * distortedy + m_iTransL[2] * distortedy + m_ccdCenter[0] - 0.5; sample = m_iTransS[0] + m_iTransS[1] * distortedx + m_iTransS[2] * distortedy + m_ccdCenter[1]; line = m_iTransL[0] + m_iTransL[1] * distortedx + m_iTransL[2] * distortedy + m_ccdCenter[0]; return csm::ImageCoord(line, sample); } Loading Loading @@ -235,11 +235,11 @@ csm::EcefCoord UsgsAstroFrameSensorModel::imageToGround(const csm::ImageCoord &i so = sample - m_sample_pp; //Convert from the pixel space into the metric space double optical_center_x, optical_center_y, x_camera, y_camera; optical_center_x = m_ccdCenter[0] - 0.5; optical_center_y = m_ccdCenter[1] - 0.5; y_camera = m_transY[0] + m_transY[1] * (lo - optical_center_y) + m_transY[2] * (lo - optical_center_y); x_camera = m_transX[0] + m_transX[1] * (so - optical_center_x) + m_transX[2] * (so - optical_center_x); double line_center, sample_center, x_camera, y_camera; line_center = m_ccdCenter[0]; sample_center = m_ccdCenter[1]; y_camera = m_transY[0] + m_transY[1] * (lo - line_center) + m_transY[2] * (so - sample_center); x_camera = m_transX[0] + m_transX[1] * (lo - line_center) + m_transX[2] * (so - sample_center); // Apply the distortion model (remove distortion) double undistorted_cameraX, undistorted_cameraY = 0.0; Loading Loading @@ -293,10 +293,10 @@ csm::EcefLocus UsgsAstroFrameSensorModel::imageToRemoteImagingLocus(const csm::I csm::WarningList *warnings) const { // Find the line,sample on the focal plane (mm) // CSM center = 0.5, MDIS IK center = 1.0 double col = imagePt.samp - (m_ccdCenter[0] - 0.5); double row = imagePt.line - (m_ccdCenter[1] - 0.5); double focalPlaneX = m_transX[0] + m_transX[1] * col + m_transX[2] * col; double focalPlaneY = m_transY[0] + m_transY[1] * row + m_transY[2] * row; double row = imagePt.line - m_ccdCenter[0]; double col = imagePt.samp - m_ccdCenter[1]; double focalPlaneX = m_transX[0] + m_transX[1] * row + m_transX[2] * col; double focalPlaneY = m_transY[0] + m_transY[1] * row + m_transY[2] * col; // Distort double undistortedFocalPlaneX = focalPlaneX; Loading
tests/FrameCameraTests.cpp +6 −6 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ //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); Loading @@ -21,7 +21,7 @@ TEST_F(FrameSensorModel, Center) { } 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); Loading @@ -30,28 +30,28 @@ 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); Loading
tests/data/simpleFramerISD.json +4 −4 Original line number Diff line number Diff line { "center_ephemeris_time": 50, "dt_ephemeris": 100, "focal2pixel_lines": [-7.5, 0.0, 0.1], "focal2pixel_samples": [-7.5, 0.1, 0.0], "focal2pixel_lines": [0.0, 0.0, 10.0], "focal2pixel_samples": [0.0, 10.0, 0.0], "focal_length_model": { "focal_length": 50, "epsilon": 1.0 Loading @@ -16,8 +16,8 @@ "interpolation_method": "lagrange", "number_of_ephemerides": 1, "optical_distortion": { "x": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "y": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] "x": [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], "y": [0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] }, "radii": { "semimajor": 0.01, Loading