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