13#include "NaifStatus.h"
14#include "OsirisRexDistortionMap.h"
15#include "CameraFocalPlaneMap.h"
40 QString mess =
"FocalPlaneMap must be set in the Camera object prior to"
41 " initiating this distortion model!";
42 throw IException(IException::Programmer, mess, _FILEINFO_);
89 if (filter.toUpper().compare(
"UNKNOWN") == 0) {
90 odkkey =
"INS" +
toString(naifIkCode) +
"_OD_K";
93 odkkey =
"INS" +
toString(naifIkCode) +
"_OD_K_" + filter.trimmed().toUpper();
97 for (
int i = 0; i < 5; ++i) {
101 catch (IException &e) {
106 if (
m_debug ) std::cout <<
"Bad Distortion Model - set to -1\n";
112 if (filter.toUpper().compare(
"UNKNOWN") == 0) {
113 odcenterkey =
"INS" +
toString(naifIkCode) +
"_OD_CENTER";
116 odcenterkey =
"INS" +
toString(naifIkCode) +
"_OD_CENTER_" + filter.trimmed().toUpper();
122 QString dbKey =
"INS" +
toString(naifIkCode) +
"_DEBUG_MODEL";
124 }
catch (IException &ie) {
130 std::cout <<
"\nModel Initialized! - IKCode = " << naifIkCode
131 <<
", Filter = " << filter <<
"\n";
159 m_focalMap->SetFocalPlane(dx, dy);
160 std::cout <<
"\nCompute Undistorted at dx = " << dx
161 <<
", dy = " << dy <<
"\n";
162 std::cout <<
"DLine = " << m_focalMap->DetectorLine()
163 <<
", DSamp = " << m_focalMap->DetectorSample() <<
"\n";
167 if (
p_odk.size() < 2) {
180 std::cout <<
"x0 = " << x0 <<
", y0 = " << y0 <<
"\n";
186 double xx, yy, r, rr, rrr, rrrr;
187 double xdistortion, ydistortion;
188 double xdistorted, ydistorted;
189 double xprevious, yprevious;
192 xprevious = 1000000.0;
193 yprevious = 1000000.0;
195 double tolerance = 0.000001;
197 bool bConverged =
false;
203 for(
int i = 0; i < 50; i++) {
204 xx = (xt-x0) * (xt-x0);
205 yy = (yt-y0) * (yt-y0);
214 xdistortion = drOverR * (xt-x0);
215 ydistortion = drOverR * (yt-y0);
218 xt = dx - xdistortion;
219 yt = dy - ydistortion;
225 if((fabs(xt - xprevious) <= tolerance) && (fabs(yt - yprevious) <= tolerance)) {
232 std::cout <<
"i=" << i <<
", xt=" << xt <<
", yt=" << yt
233 <<
", xdist=" << xdistortion
234 <<
", ydist=" << ydistortion
235 <<
", xtol=" << (xt - xprevious)
236 <<
", ytol=" << (yt - yprevious) <<
"\n";
246 std::cout <<
"Loop terminated after " << nrevs <<
" iterations! - converged? "
247 << ( ( bConverged ) ?
"Yes!" :
"No-(") <<
"\n";
259 std::cout <<
"ULine = " << m_focalMap->DetectorLine()
260 <<
", USamp = " << m_focalMap->DetectorSample() <<
"\n";
286 m_focalMap->SetFocalPlane(ux, uy);
287 std::cout <<
"\nCompute Distorted at ux = " << ux
288 <<
", uy = " << uy <<
"\n";
289 std::cout <<
"ULine = " << m_focalMap->DetectorLine()
290 <<
", USamp = " << m_focalMap->DetectorSample() <<
"\n";
294 if (
p_odk.size() < 2) {
307 std::cout <<
"x0 = " << x0 <<
", y0 = " << y0 <<
"\n";
314 double r = qSqrt(((x-x0) * (x-x0)) + ((y - y0) * (y-y0)));
329 std::cout <<
"DLine = " << m_focalMap->DetectorLine()
330 <<
", DSamp = " << m_focalMap->DetectorSample() <<
"\n";
CameraDistortionMap(Camera *parent, double zDirection=1.0)
Camera distortion map constructor.
double p_focalPlaneX
Distorted focal plane x.
double p_undistortedFocalPlaneX
Undistorted focal plane x.
std::vector< double > p_odk
Vector of distortion coefficients.
double p_undistortedFocalPlaneY
Undistorted focal plane y.
Camera * p_camera
The camera to distort/undistort.
double p_focalPlaneY
Distorted focal plane y.
Convert between distorted focal plane and detector coordinates.
double DetectorSampleOrigin() const
double DetectorLineOrigin() const
CameraFocalPlaneMap * FocalPlaneMap()
Returns a pointer to the CameraFocalPlaneMap object.
virtual bool SetFocalPlane(double dx, double dy)
Compute undistorted focal plane x/y.
virtual ~OsirisRexDistortionMap()
Default Destructor.
OsirisRexDistortionMap(Camera *parent, double zDirection=1.0)
OSIRIS REx Camera distortion map constructor.
double m_distortionOriginSample
The distortion's origin sample coordinate.
virtual bool SetDistortion(int naifIkCode, QString filter="UNKNOWN")
Load distortion coefficients and center-of-distortion for OCAMS.
double m_detectorOriginLine
The origin of the detector's line coordinate.
virtual bool SetUndistortedFocalPlane(double ux, double uy)
Compute distorted focal plane x/y.
double m_pixelPitch
The pixel pitch for OCAMS.
bool m_debug
Debug option.
double m_distortionOriginLine
The distortion's origin line coordinate.
double m_detectorOriginSample
The origin of the detector's sample coordinate.
This is free and unencumbered software released into the public domain.
QString toString(const LinearAlgebra::Vector &vector, int precision)
A global function to format LinearAlgebra::Vector as a QString with the given precision.