Skip to content

Commit

Permalink
Correct ASP to align with changes in VW
Browse files Browse the repository at this point in the history
Specifically these are the changes in IP that return indices with
size_t.
  • Loading branch information
Zack Moratto committed Jul 28, 2011
1 parent 58f71a4 commit 46c1f15
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 92 deletions.
28 changes: 0 additions & 28 deletions src/asp/Sessions/StereoSession.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,6 @@ namespace {
ConstructMapType *stereo_session_construct_map = 0;
}

void asp::StereoSession::remove_duplicates(std::vector<vw::ip::InterestPoint> &ip1v,
std::vector<vw::ip::InterestPoint> &ip2v) {
using namespace vw;
typedef std::vector<ip::InterestPoint> IPVector;
IPVector new_ip1v, new_ip2v;
new_ip1v.reserve( ip1v.size() );
new_ip2v.reserve( ip2v.size() );

for ( IPVector::iterator ip1 = ip1v.begin(), ip2 = ip2v.begin();
ip1 < ip1v.end() - 1; ip1++, ip2++ ) {
bool bad_entry = false;
for ( IPVector::iterator ip1a = ip1 + 1, ip2a = ip2 + 1;
ip1a < ip1v.end(); ip1a++, ip2a++ ) {
if ( ip1->x == ip1a->x && ip1->y == ip1a->y &&
ip2->x == ip2a->x && ip2->y == ip2a->y ) {
bad_entry = true;
break;
}
}
if ( !bad_entry ) {
new_ip1v.push_back( *ip1 );
new_ip2v.push_back( *ip2 );
}
}
ip1v = new_ip1v;
ip2v = new_ip2v;
}

void asp::StereoSession::register_session_type( std::string const& id,
asp::StereoSession::construct_func func) {
if( ! stereo_session_construct_map )
Expand Down
9 changes: 2 additions & 7 deletions src/asp/Sessions/StereoSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ namespace asp {
std::string m_extra_argument1, m_extra_argument2,
m_extra_argument3, m_extra_argument4;

// Duplicate matches for any given interest point probably indicate a
// poor match, so we cull those out here.
void remove_duplicates(std::vector<vw::ip::InterestPoint> &ip1,
std::vector<vw::ip::InterestPoint> &ip2);

template <class ImageT1, class ImageT2>
vw::Matrix3x3
determine_image_align( std::string const& input_file1,
Expand Down Expand Up @@ -159,7 +154,7 @@ namespace asp {
<< " duplicate matches.\n";

Matrix<double> T;
std::vector<int> indices;
std::vector<size_t> indices;
try {

vw::math::RandomSampleConsensus<vw::math::HomographyFittingFunctor, vw::math::InterestPointErrorMetric> ransac( vw::math::HomographyFittingFunctor(), vw::math::InterestPointErrorMetric(), 10 );
Expand All @@ -177,7 +172,7 @@ namespace asp {

{ // Keeping only inliers
std::vector<ip::InterestPoint> inlier_ip1, inlier_ip2;
for ( unsigned i = 0; i < indices.size(); i++ ) {
for ( size_t i = 0; i < indices.size(); i++ ) {
inlier_ip1.push_back( matched_ip1[indices[i]] );
inlier_ip2.push_back( matched_ip2[indices[i]] );
}
Expand Down
28 changes: 1 addition & 27 deletions src/asp/Tools/aligndem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,6 @@ class HomogeneousTransformFunctor : public UnaryReturnSameType {
}
};

// Duplicate matches for any given interest point probably indicate a
// poor match, so we cull those out here.
void remove_duplicates(std::vector<InterestPoint> &ip1,
std::vector<InterestPoint> &ip2) {
std::vector<InterestPoint> new_ip1, new_ip2;

for (size_t i = 0; i < ip1.size(); ++i) {
bool bad_entry = false;
for (size_t j = 0; j < ip1.size(); ++j) {
if (i != j &&
((ip1[i].x == ip1[j].x && ip1[i].y == ip1[j].y) ||
(ip2[i].x == ip2[j].x && ip2[i].y == ip2[j].y)) ) {
bad_entry = true;
}
}
if (!bad_entry) {
new_ip1.push_back(ip1[i]);
new_ip2.push_back(ip2[i]);
}
}

ip1 = new_ip1;
ip2 = new_ip2;
}

void match_orthoimages( string const& left_image_name,
string const& right_image_name,
std::vector<InterestPoint> & matched_ip1,
Expand Down Expand Up @@ -146,8 +121,7 @@ void match_orthoimages( string const& left_image_name,

matcher(ip1_copy, ip2_copy, matched_ip1, matched_ip2,
false, TerminalProgressCallback( "asp", "\t Matching: "));

remove_duplicates(matched_ip1, matched_ip2);
ip::remove_duplicates(matched_ip1, matched_ip2);
vw_out(InfoMessage) << "\t " << matched_ip1.size() << " putative matches.\n";
asp::cnettk::equalization( matched_ip1, matched_ip2, max_points );
vw_out(InfoMessage) << "\t " << matched_ip1.size() << " thinned matches.\n";
Expand Down
25 changes: 0 additions & 25 deletions src/asp/Tools/stereo.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,31 +71,6 @@ struct Options : asp::BaseOptions {
// Allows FileIO to correctly read/write these pixel types
namespace vw {

// Duplicate matches for any given interest point probably indicate a
// poor match, so we cull those out here.
void remove_duplicates(std::vector<ip::InterestPoint> &ip1,
std::vector<ip::InterestPoint> &ip2) {
std::vector<ip::InterestPoint> new_ip1, new_ip2;

for (unsigned i = 0; i < ip1.size(); ++i) {
bool bad_entry = false;
for (unsigned j = 0; j < ip1.size(); ++j) {
if (i != j &&
((ip1[i].x == ip1[j].x && ip1[i].y == ip1[j].y) ||
(ip2[i].x == ip2[j].x && ip2[i].y == ip2[j].y)) ) {
bad_entry = true;
}
}
if (!bad_entry) {
new_ip1.push_back(ip1[i]);
new_ip2.push_back(ip2[i]);
}
}

ip1 = new_ip1;
ip2 = new_ip2;
}

// Posix time is not fully supported in the version of Boost for RHEL
// Workstation 4
#ifndef __APPLE__
Expand Down
9 changes: 4 additions & 5 deletions src/asp/Tools/stereo_correlation.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,15 @@ namespace vw {
vw_out(InfoMessage) << "\t " << matched_ip1.size() << " putative matches.\n";

vw_out() << "\t * Rejecting outliers using RANSAC.\n";
remove_duplicates(matched_ip1, matched_ip2);
ip::remove_duplicates(matched_ip1, matched_ip2);
std::vector<Vector3> ransac_ip1 = ip::iplist_to_vectorlist(matched_ip1);
std::vector<Vector3> ransac_ip2 = ip::iplist_to_vectorlist(matched_ip2);
std::vector<int> indices;
std::vector<size_t> indices;

try {
Matrix<double> trans;
math::RandomSampleConsensus<math::HomographyFittingFunctor,math::InterestPointErrorMetric>
ransac( math::HomographyFittingFunctor(), math::InterestPointErrorMetric(), 25 );
trans = ransac( ransac_ip1, ransac_ip2 );
Matrix<double> trans = ransac( ransac_ip1, ransac_ip2 );
vw_out(DebugMessage) << "\t * Ransac Result: " << trans << std::endl;
indices = ransac.inlier_indices(trans, ransac_ip1, ransac_ip2 );
} catch ( vw::math::RANSACErr const& e ) {
Expand All @@ -132,7 +131,7 @@ namespace vw {

{ // Keeping only inliers
std::vector<ip::InterestPoint> inlier_ip1, inlier_ip2;
for ( unsigned i = 0; i < indices.size(); i++ ) {
for ( size_t i = 0; i < indices.size(); i++ ) {
inlier_ip1.push_back( matched_ip1[indices[i]] );
inlier_ip2.push_back( matched_ip2[indices[i]] );
}
Expand Down

0 comments on commit 46c1f15

Please sign in to comment.