Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add max_outlier_frac parameter to vxl homography estimation #1623

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 71 additions & 2 deletions arrows/vxl/estimate_homography.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,75 @@ namespace kwiver {
namespace arrows {
namespace vxl {

class estimate_homography::priv
{
public:
double max_outlier_frac = 0.8;

/// Write configuration into the provided config block
void get_configuration( config_block_sptr config ) const;
/// Set configuration from the provided config block
void set_configuration( config_block_sptr config );
};

void
estimate_homography::priv
::get_configuration( config_block_sptr config ) const
{
config->set_value(
"max_outlier_frac", max_outlier_frac,
"Maximum expected fraction of outliers" );
}

void
estimate_homography::priv
::set_configuration( config_block_sptr in_config )
{
config_block_sptr config = config_block::empty_config();
get_configuration( config );
config->merge_config( in_config );

max_outlier_frac = config->get_value< double >( "max_outlier_frac" );
}

estimate_homography
::estimate_homography()
: d{ new priv{} }
{}

estimate_homography
::~estimate_homography()
= default;

config_block_sptr
estimate_homography
::get_configuration() const
{
auto config = algo::estimate_homography::get_configuration();
d->get_configuration( config );
return config;
}

void
estimate_homography
::set_configuration( vital::config_block_sptr in_config )
{
d->set_configuration( std::move( in_config ) );
}

bool
estimate_homography
::check_configuration( vital::config_block_sptr config ) const
{
priv p;
p.set_configuration( std::move( config ) );
if( p.max_outlier_frac < 0 || p.max_outlier_frac >= 1 )
{
return false;
}
return true;
}

/// Estimate a homography matrix from corresponding points
homography_sptr
estimate_homography
Expand Down Expand Up @@ -52,9 +121,9 @@ ::estimate(const std::vector<vector_2d>& pts1,
hg.set_prior_scale(inlier_scale);

rrel_trunc_quad_obj msac;
// TODO expose these parameters
// TODO expose all these parameters
rrel_ran_sam_search ransam( 42 );
ransam.set_sampling_params(0.80);
ransam.set_sampling_params( d->max_outlier_frac );
ransam.set_trace_level(0);

bool result = ransam.estimate( &hg, &msac );
Expand Down
23 changes: 16 additions & 7 deletions arrows/vxl/estimate_homography.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ class KWIVER_ALGO_VXL_EXPORT estimate_homography
PLUGIN_INFO( "vxl",
"Use VXL (rrel) to robustly estimate a homography from matched features." )

// No configuration yet for this class.
/// \cond DoxygenSuppress
virtual void set_configuration(vital::config_block_sptr /*config*/) {}
virtual bool check_configuration(vital::config_block_sptr /*config*/) const { return true; }
/// \endcond
estimate_homography();
~estimate_homography() override;

/// Get this algorithm's \link vital::config_block configuration block
/// \endlink.
vital::config_block_sptr get_configuration() const override;
/// Set this algorithm's properties via a config block.
void set_configuration( vital::config_block_sptr config ) override;
/// Check that the algorithm's currently configuration is valid.
bool check_configuration( vital::config_block_sptr config ) const override;

/// Estimate a homography matrix from corresponding points
///
Expand All @@ -39,13 +44,17 @@ class KWIVER_ALGO_VXL_EXPORT estimate_homography
/// \param [out] inliers for each point pair, the value is true if
/// this pair is an inlier to the homography estimate
/// \param [in] inlier_scale error distance tolerated for matches to be inliers
virtual vital::homography_sptr
vital::homography_sptr
estimate(const std::vector<vital::vector_2d>& pts1,
const std::vector<vital::vector_2d>& pts2,
std::vector<bool>& inliers,
double inlier_scale = 1.0) const;
double inlier_scale = 1.0) const override;
using vital::algo::estimate_homography::estimate;

private:
class priv;
std::unique_ptr< priv > const d;

};

} // end namespace vxl
Expand Down
4 changes: 4 additions & 0 deletions doc/release-notes/master.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ Arrows
Arrows: FFmpeg

* Added basic configuration options to ffmpeg_video_output.

Arrows: VXL

* Added max_outlier_frac configuration option to estimate_homography.