Isis 3 Programmer Reference
ApolloPanoramicDetectorMap.cpp
2 #include "Application.h"
3 #include "PvlGroup.h"
4 #include "SerialNumber.h"
5 #include "Table.h"
6 #include "iTime.h"
7 
8 #include <iostream>
9 using namespace std;
10 
11 using namespace std;
12 namespace Isis {
21  bool ApolloPanoramicDetectorMap::SetDetector(const double sample, const double line) {
22  //given a detector coordinate and a time (read from the 'parent' camera class)
23  // set the image coordinates
24  //save the detector coordinates
25  //negative signs are counterintuitive and I cannot fully explain them, I believe they are
26  // because of the negative z direction in the distortion map....
27  p_detectorLine = -line;
28  p_detectorSample = -sample;
29 
30  //convert from detector to fiducial coordinants
31  double fidL = (p_camera->time().Et() - m_etMiddle)/m_lineRate;
32  //double fidS = sample; //conversion is identity so it is skiped
33 
34  //convert from fiducial coordinates to parent image coordinates
35  p_intOri.image2Machine(p_detectorSample, fidL, &p_parentSample, &p_parentLine);
36 
37  //cout << "fiducial values sent to IO: " << p_detectorSample << " " << fidL << endl; //debug
38  //cout << "cube coordinates returned from IO: " << p_parentSample << " " << p_parentLine << endl;
39  return true;
40  }
41 
50  bool ApolloPanoramicDetectorMap::SetParent(const double sample, const double line) {
51  //Given an image (aka 'Parent', aka encoder, aka machine) coordinate set the detector
52  //coordiante and the time (time is set in the 'parent' camera class)
53  //save the parent data
54  p_parentLine = line;
55  p_parentSample = sample;
56  //convert from machine to fiducial coordinates
57  //cout << "cube coordinates sent to IO: " << sample << " " << line << endl; //debug
58 
59  p_intOri.machine2Image(sample,line,&p_detectorSample, &p_detectorLine);
60 
61  //cout << "fiducial coordinate return from IO: " << p_detectorSample << " " << p_detectorLine << endl;
62  //convert from fiducial coordinates to detector/time coordinates
63  iTime isisTime(m_etMiddle + p_detectorLine*m_lineRate);
64  p_camera->setTime(isisTime);
65  //This declaration may cause some debate. Regardless it seems to that
66  // since we model the motion of the camera as continuous smooth motion
67  // (not some discretely defined series of 1 pixel or 1 mm wide 'push-frames'),
68  // and we calculate the positions, pointings, etc at the specific time implied
69  // by the sub-pixel/mm line then the line in the dector will always be the same
70  // (in this case zero)
71  p_detectorLine = 0.0;
72 
73  return true;
74  }
75 
88  int ApolloPanoramicDetectorMap::initializeInteriorOrientation() {
89  int i,nrec;
90  //read the fidicial measurements from the attached table in the camera labels to define a
91  // series of affine transformation between image (aka encoder aka machine) coordinates
92  // and fiducial coordinates
93  Table tableFid("Fiducial Measurement", m_lab->fileName());
94 
95  nrec = tableFid.Records(); //get the number of records found in the cube blobs
96 
97  if( nrec <= 0) {
98  throw IException(IException::User,"No FID_MEASURES table found in cube blobs.\n",
99  _FILEINFO_);
100  return -1;
101  }
102  if( tableFid.Records() < 4) {
103  throw IException(IException::User,"Less than four FID_MEASURES found in cube blobs.\n",
104  _FILEINFO_);
105  return -1;
106  }
107  p_intOri.initialize();
108 
109  for(i=0;i<nrec;i++) //input all the observations to the the Interior Orientation Class
110  p_intOri.fiducialObservation(tableFid[i][0], tableFid[i][1], tableFid[i][2]);
111 
112  i = p_intOri.computeInteriorOrienation();
113 
114  if( i != 1) { //unsuccessful computation of the interior orienation
115  throw IException(IException::User,"Insufficient Fiducial Observations for computation of "
116  "the interior orientation.\nAt least one vertical pair "
117  "must be measured, many more is recomented.\n",
118  _FILEINFO_);
119  return -1;
120  }
121 
122  return 1;
123  }
124 } //end namespace Isis
int Records() const
Returns the number of records.
Definition: Table.cpp:224
Parse and return pieces of a time string.
Definition: iTime.h:78
Namespace for the standard library.
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
Class for storing Table blobs information.
Definition: Table.h:77
Isis exception class.
Definition: IException.h:107
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31