Browse files

Sessions and InterestPointMatching: Consistent notation

  • Loading branch information...
1 parent 438aca1 commit 6ccf3e7a4d0f2fde6f89f3e77317b916ae6d8145 @oleg-alexandrov oleg-alexandrov committed Mar 18, 2013
View
35 src/asp/Core/InterestPointMatching.cc
@@ -204,13 +204,11 @@ namespace asp {
math::RandomSampleConsensus<hfit_func, math::InterestPointErrorMetric>
ransac( hfit_func(), math::InterestPointErrorMetric(),
100, // num iterations
- norm_2(Vector2(box1.height(),box1.width())) / 10, // inlier threshold
+ norm_2(Vector2(box1.width(),box1.height())) / 10, // inlier threshold
left_points.size()/2 // min output inliers
);
-
Matrix<double> H = ransac( right_points, left_points );
std::vector<size_t> indices = ransac.inlier_indices(H, right_points, left_points);
-
check_homography_matrix(H, left_points, right_points, indices);
VW_OUT( DebugMessage, "asp" ) << "Projected " << left_points.size()
@@ -221,32 +219,31 @@ namespace asp {
}
vw::Matrix<double>
- homography_fit( std::vector<vw::ip::InterestPoint> const& ip1,
- std::vector<vw::ip::InterestPoint> const& ip2,
- vw::BBox2i const& image_size ) {
+ homography_fit( std::vector<vw::ip::InterestPoint> const& right_ip,
+ std::vector<vw::ip::InterestPoint> const& left_ip,
+ vw::BBox2i const& left_image_size ) {
using namespace vw;
- std::vector<Vector3> copy1, copy2;
- copy1.reserve( ip1.size() );
- copy2.reserve( ip1.size() );
- for ( size_t i = 0; i < ip1.size(); i++ ) {
- copy1.push_back( Vector3(ip1[i].x, ip1[i].y, 1) );
- copy2.push_back( Vector3(ip2[i].x, ip2[i].y, 1) );
+ std::vector<Vector3> right_copy, left_copy;
+ right_copy.reserve( right_ip.size() );
+ left_copy.reserve( right_ip.size() );
+ for ( size_t i = 0; i < right_ip.size(); i++ ) {
+ right_copy.push_back( Vector3(right_ip[i].x, right_ip[i].y, 1) );
+ left_copy.push_back( Vector3(left_ip[i].x, left_ip[i].y, 1) );
}
typedef math::HomographyFittingFunctor hfit_func;
math::RandomSampleConsensus<hfit_func, math::InterestPointErrorMetric>
ransac( hfit_func(), math::InterestPointErrorMetric(),
100, // num iter
- norm_2(Vector2(image_size.width(),image_size.height())) / 10, // inlier threshold
- copy1.size()/2 // min output inliers
+ norm_2(Vector2(left_image_size.width(),left_image_size.height())) / 10, // inlier threshold
+ left_copy.size()/2 // min output inliers
);
+ Matrix<double> H = ransac(right_copy, left_copy);
+ std::vector<size_t> indices = ransac.inlier_indices(H, right_copy, left_copy);
+ check_homography_matrix(H, left_copy, right_copy, indices);
- Matrix<double> H = ransac(copy1, copy2);
- std::vector<size_t> indices = ransac.inlier_indices(H, copy1, copy2);
- check_homography_matrix(H, copy1, copy2, indices);
-
- return hfit_func()(copy1, copy2, H);
+ return hfit_func()(right_copy, left_copy, H);
}
bool
View
6 src/asp/Core/InterestPointMatching.h
@@ -121,9 +121,9 @@ namespace asp {
// Homography fit to interest points
vw::Matrix<double>
- homography_fit( std::vector<vw::ip::InterestPoint> const& ip1,
- std::vector<vw::ip::InterestPoint> const& ip2,
- vw::BBox2i const& image_size );
+ homography_fit( std::vector<vw::ip::InterestPoint> const& right_ip,
+ std::vector<vw::ip::InterestPoint> const& left_ip,
+ vw::BBox2i const& left_image_size );
// Detect InterestPoints
View
6 src/asp/Sessions/DG/StereoSessionDG.cc
@@ -425,10 +425,10 @@ namespace asp {
vw_out() << "\t--> Using cached match file: " << match_filename << "\n";
}
- std::vector<ip::InterestPoint> ip1, ip2;
- ip::read_binary_match_file( match_filename, ip1, ip2 );
+ std::vector<ip::InterestPoint> left_ip, right_ip;
+ ip::read_binary_match_file( match_filename, left_ip, right_ip );
Matrix<double> align_matrix =
- homography_fit(ip2, ip1, bounding_box(left_disk_image) );
+ homography_fit(right_ip, left_ip, bounding_box(left_disk_image) );
write_matrix( m_out_prefix + "-align.exr", align_matrix );
vw_out() << "\t--> Aligning right image to left using homography:\n"
View
12 src/asp/Sessions/ISIS/StereoSessionIsis.cc
@@ -267,9 +267,9 @@ asp::StereoSessionIsis::pre_preprocessing_hook(std::string const& left_input_fil
vw_out() << "\t--> Using cached match file: " << match_filename << "\n";
}
- std::vector<ip::InterestPoint> ip1, ip2;
- ip::read_binary_match_file( match_filename, ip1, ip2 );
- align_matrix = homography_fit(ip2, ip1, bounding_box(DiskImageView<float>(left_input_file)) );
+ std::vector<ip::InterestPoint> left_ip, right_ip;
+ ip::read_binary_match_file( match_filename, left_ip, right_ip );
+ align_matrix = homography_fit(right_ip, left_ip, bounding_box(DiskImageView<float>(left_input_file)) );
write_matrix( m_out_prefix + "-align.exr", align_matrix );
vw_out() << "\t--> Aligning right image to left using homography:\n"
@@ -401,9 +401,9 @@ asp::StereoSessionIsis::pre_pointcloud_hook(std::string const& input_file) {
ImageViewRef<PixelMask<Vector2f> > result;
if ( stereo_settings().alignment_method == "homography" ) {
- // We used a homography to line up the images, we may want
- // to generate pre-alignment disparities before passing this information
- // onto the camera model in the next stage of the stereo pipeline.
+ // We used a homography to line up the images, so we must undo the
+ // homography transform in the disparity_map before triangulation
+ // happens.
Matrix<double> align_matrix;
read_matrix(align_matrix, m_out_prefix + "-align.exr");
vw_out(DebugMessage,"asp") << "Alignment Matrix: " << align_matrix << "\n";

0 comments on commit 6ccf3e7

Please sign in to comment.