Skip to content

Commit

Permalink
XML: Check for non-zero poly coeffs for optical distortion
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-alexandrov committed Mar 7, 2013
1 parent 3319141 commit 73112ac
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
4 changes: 0 additions & 4 deletions src/asp/Sessions/DG/StereoSessionDG.cc
Expand Up @@ -196,10 +196,6 @@ namespace asp {
VW_ASSERT( eph.start_time == att.start_time && eph.time_interval == att.time_interval,
MathErr() << "Ephemeris and Attitude don't seem to sample with the same t0 or dt." );

// I also don't support optical distortion yet.
VW_ASSERT( geo.optical_polyorder <= 0,
NoImplErr() << "Cameras with optical distortion are not supported currently." );

// Convert ephemeris to be position of camera. Change attitude to be
// be the rotation from camera frame to world frame. We also add an
// additional rotation to the camera frame so X is the horizontal
Expand Down
37 changes: 35 additions & 2 deletions src/asp/Sessions/DG/XML.cc
Expand Up @@ -93,8 +93,41 @@ void asp::GeometricXML::parse_principal_distance( xercesc::DOMElement* node ) {
void asp::GeometricXML::parse_optical_distortion( xercesc::DOMElement* node ) {
cast_xmlch( get_node<DOMElement>( node, "POLYORDER" )->getTextContent(),
optical_polyorder );
if ( optical_polyorder > 0 )
vw_throw( NoImplErr() << "We don't support optical distortion.\n" );

// If the optical polyorder is >= 1 and some of the polynomial
// coefficients are non-zero, then throw an error as we did not
// implement optical distortion.

if ( optical_polyorder == 0 ) return;

std::string list_list_types[] = {"ALISTList", "BLISTList"};
for (unsigned ls = 0; ls < sizeof(list_list_types)/sizeof(std::string); ls++){
std::string list_list_type = list_list_types[ls];

DOMElement* list_list = get_node<DOMElement>( node, list_list_type );
if (list_list == NULL) return;

DOMNodeList* children = list_list->getChildNodes();
if (children == NULL) return;

for ( XMLSize_t i = 0; i < children->getLength(); ++i ) {

DOMNode* current = children->item(i);
if ( current->getNodeType() != DOMNode::ELEMENT_NODE ) continue;

DOMElement* element = dynamic_cast< xercesc::DOMElement* >( current );
std::string buffer;
cast_xmlch( element->getTextContent(), buffer );

std::istringstream istr( buffer );
double val;
while (istr >> val){
if (val != 0)
vw_throw( NoImplErr() << "Optical distortion is not implemented.\n" );
}
}
}

}

void asp::GeometricXML::parse_perspective_center( xercesc::DOMElement* node ) {
Expand Down

0 comments on commit 73112ac

Please sign in to comment.