#include <iostream>
#include <vector>
#include <random>
#include <Eigen/Core>
#include "SimpleRansac.h"
#include "PlaneModel.h"
int main()
{
std::random_device dev;
std::mt19937 engine{dev()};
std::uniform_real_distribution<double> dis{-1.0,1.0};
auto draw=[&]() { return dis(engine); };
std::vector<Eigen::Vector3d> points;
// add some outliers (1000 randomly sampled points with coordinates in [-1,1])
for (int i=0;i<1000;i++)
points.push_back(Eigen::Vector3d(draw(),draw(),draw()));
// add some inliers (200 randomly sampled points on a plane through point p, spanned by the vectors v1, v2)
const Eigen::Vector3d p(2.0,2.0,0.0);
const Eigen::Vector3d v1(0.3,0.7,0.2);
const Eigen::Vector3d v2(-0.3,0.3,0.0);
for (int i=0;i<200;i++)
points.push_back(p+draw()*v1+draw()*v2);
// compute ground truth plane
const Eigen::Vector3d n=v1.cross(v2).normalized();
const double d=n.transpose()*p;
std::cout << "Ground truth plane: n=" << n.transpose() << " d=" << d << std::endl;
// run ransac
// we do 300 iterations
// points need to be closer than 0.05 in order to be considered an inlier
const PlaneModel m=ransac<PlaneModel>(points,0.05,300);
std::cout << "Ransac computed plane: n=" << m.n.transpose() << " d=" << m.d << std::endl;
}
</div>
#include <iostream>
#include <Eigen/Core>
#include "NumJac.h"
Eigen::Vector2d f(const Eigen::Vector3d& x)
{
Eigen::Vector2d ret;
ret << x(0)*x(0)+5.0*x(1)+x(2),
x(0)+7.0*x(2);
return ret;
}
int main()
{
const Eigen::Matrix<double,2,3> jac=numJacobian(f,Eigen::Vector3d(1,2,3));
std::cout << jac << std::endl;
}
#!/bin/sh
find . \( -name '*.py' -o -name '*.h' -o -name '*.hxx' -o -name '*.hpp' -o -name '*.hh' -o -name '*.h++' -o -name '*.H' -o -name '*.tlh' -o -name '*.cpp' -o -name '*.cc' -o -name '*.C' -o -name '*.c++' -o -name '*.cxx' -o -name '*.ocl' -o -name '*.inl' -o -name '*.idl' -o -name '*.c' -o -name '*.m' -o -name '*.mm' -o -name '*.M' \) -print -follow 2>/dev/null | grep -v -e '/CVS/' -e '/SCCS/' -e '/\.svn/' -e '/_darcs/' | sed "s/ /\\\ /g" | xargs egrep --color=auto -H -n -s -i -e "$1"