Skip to content

Commit

Permalink
Small change to allow me to run with cubes and match files in differe…
Browse files Browse the repository at this point in the history
…nt directories on pleiades.
  • Loading branch information
Zack Moratto committed Jun 2, 2009
1 parent eb2c328 commit f9d9a42
Showing 1 changed file with 44 additions and 31 deletions.
75 changes: 44 additions & 31 deletions src/ControlNetworkLoader.cc
Expand Up @@ -74,6 +74,14 @@ static std::string prefix_from_filename( std::string const& filename ){
return result;
}

static std::string remove_path( std::string const& filename ){
std::string result = filename;
int index = result.rfind("/");
if (index != -1)
result.erase(0,index+1);
return result;
}

// Secondary Layer of Camera Relations Network. This contains the
// match relations and is doubly linked.
struct InterestPtRelation {
Expand Down Expand Up @@ -193,51 +201,56 @@ void build_control_network( boost::shared_ptr<ControlNetwork> cnet,
for ( unsigned i = 0; i < image_files.size(); i++ )
crn.push_back( CameraRelation( i,
prefix_from_filename( image_files[i] )));
std::cout << "Loading matches:\n";
vw_out(0) << "Loading matches:\n";
for ( unsigned i = 0; i < image_files.size(); ++i ) {
for ( unsigned j = i+1; j < image_files.size(); ++j ) {
std::string match_filename =
prefix_from_filename( image_files[i] ) + "__" +
prefix_from_filename( image_files[j] ) + ".match";

if ( fs::exists( match_filename ) ) {
std::vector<InterestPoint> ip1, ip2;
read_binary_match_file( match_filename, ip1, ip2 );
if ( int( ip1.size() ) < min_matches ) {
std::cout << "\t" << match_filename << " " << i << " <-> "
<< j << " : " << ip1.size() << " matches. [rejected]\n";
} else {
std::cout << "\t" << match_filename << " " << i << " <-> "
<< j << " : " << ip1.size() << " matches.\n";

// Loading individual matches now
for ( unsigned k = 0; k < ip1.size(); k++ ) {
boost::shared_ptr<InterestPtRelation> ipr1, ipr2;
ipr1 = crn[i].FindMatching( ip1[k] );
ipr2 = crn[j].FindMatching( ip2[k] );

// Match hasn't been previously loaded
if ( ipr1 == boost::shared_ptr<InterestPtRelation>() ) {
ipr1 = boost::shared_ptr<InterestPtRelation>( new InterestPtRelation( ip1[k], i ) );
crn[i].AttachIpr( ipr1 );
}
if ( ipr2 == boost::shared_ptr<InterestPtRelation>() ) {
ipr2 = boost::shared_ptr<InterestPtRelation>( new InterestPtRelation( ip2[k], j ) );
crn[j].AttachIpr( ipr2 );
}
if ( !fs::exists( match_filename ) ) {
match_filename = remove_path(prefix_from_filename( image_files[i] ) )
+ "__" + remove_path(prefix_from_filename(image_files[j]))+".match";
if (!fs::exists( match_filename))
continue;
}

// Doubly linking
ipr1->AttachIpr( ipr2 );
ipr2->AttachIpr( ipr1 );
std::vector<InterestPoint> ip1, ip2;
read_binary_match_file( match_filename, ip1, ip2 );
if ( int( ip1.size() ) < min_matches ) {
vw_out(0) << "\t" << match_filename << " " << i << " <-> "
<< j << " : " << ip1.size() << " matches. [rejected]\n";
} else {
vw_out(0) << "\t" << match_filename << " " << i << " <-> "
<< j << " : " << ip1.size() << " matches.\n";

// Loading individual matches now
for ( unsigned k = 0; k < ip1.size(); k++ ) {
boost::shared_ptr<InterestPtRelation> ipr1, ipr2;
ipr1 = crn[i].FindMatching( ip1[k] );
ipr2 = crn[j].FindMatching( ip2[k] );

// Match hasn't been previously loaded
if ( ipr1 == boost::shared_ptr<InterestPtRelation>() ) {
ipr1 = boost::shared_ptr<InterestPtRelation>( new InterestPtRelation( ip1[k], i ) );
crn[i].AttachIpr( ipr1 );
}
if ( ipr2 == boost::shared_ptr<InterestPtRelation>() ) {
ipr2 = boost::shared_ptr<InterestPtRelation>( new InterestPtRelation( ip2[k], j ) );
crn[j].AttachIpr( ipr2 );
}

// Doubly linking
ipr1->AttachIpr( ipr2 );
ipr2->AttachIpr( ipr1 );
}
}
}
}

// 2.) Build Control Network finally
int spiral_error_count = 0;
std::cout << "Assembling Control Network:\n";
vw_out(0) << "Assembling Control Network:\n";
for ( unsigned i = 0; i < crn.size() -1; ++i ) {
typedef boost::shared_ptr<InterestPtRelation> ipr;

Expand Down Expand Up @@ -309,7 +322,7 @@ void build_control_network( boost::shared_ptr<ControlNetwork> cnet,
}
}
if ( spiral_error_count != 0 )
std::cout << "\t" << spiral_error_count << " control points removed because of spiral errors.\n";
vw_out(0) << "\t" << spiral_error_count << " control points removed because of spiral errors.\n";

VW_ASSERT( cnet->size() != 0, vw::Aborted() << "Failed to load any points, Control Network Empty\n");

Expand Down

0 comments on commit f9d9a42

Please sign in to comment.