44int main(
int argc,
char** argv) {
48 if (argc > 1) num_points = atoi(argv[1]);
50 double euc_noise = 0.1;
51 double pix_noise = 1.0;
65 vector<Vector3d> true_points;
66 for (
size_t i = 0; i < 1000; ++i) {
67 true_points.push_back(
74 Vector2d focal_length(500, 500);
75 Vector2d principal_point(320, 240);
76 double baseline = 0.075;
80 principal_point[1], baseline);
84 for (
size_t i = 0; i < 2; ++i) {
90 Eigen::Isometry3d cam;
92 cam.translation() = t;
99 cerr << t.transpose() <<
" | " << q.coeffs().transpose() << endl;
114 for (
size_t i = 0; i < true_points.size(); ++i) {
123 pt0 = vp0->
estimate().inverse() * true_points[i];
124 pt1 = vp1->
estimate().inverse() * true_points[i];
176 for (
int i = 0; i < num_points; ++i) {
177 true_points.push_back(
184 for (
size_t i = 0; i < true_points.size(); ++i) {
187 v_p->
setId(vertex_id++);
196 for (
size_t j = 0; j < 2; ++j) {
199 ->mapPoint(z, true_points.at(i));
201 if (z[0] >= 0 && z[1] >= 0 && z[0] < 640 && z[1] < 480) {
211 optimizer.
vertices().find(j)->second);
228 Eigen::Isometry3d cam = vc->
estimate();
229 cam.translation() = Vector3d(-0.1, 0.1, 0.2);
233 cout <<
"Initial chi2 = " << FIXED(optimizer.
chi2()) << endl;
239 cout << endl <<
"Second vertex should be near 0,0,1" << endl;
240 cout << dynamic_cast<VertexSE3*>(optimizer.
vertices().find(0)->second)
245 cout << dynamic_cast<VertexSE3*>(optimizer.
vertices().find(1)->second)
EIGEN_STRONG_INLINE const Measurement & measurement() const
accessor functions for the measurement represented by the edge
virtual void setMeasurement(const Measurement &m)
EIGEN_STRONG_INLINE const InformationType & information() const
information matrix of the constraint
const EstimateType & estimate() const
return the current estimate of the vertex
void setEstimate(const EstimateType &et)
set the estimate for the vertex also calls updateCache()
Point vertex, XYZ, is in types_sba.
const VertexContainer & vertices() const
const VertexIDMap & vertices() const
linear solver which uses the sparse Cholesky solver from Eigen
A general case Vertex for optimization.
virtual void setId(int id)
void setFixed(bool fixed)
true => this node should be considered fixed during the optimization
void setMarginalized(bool marginalized)
true => this node should be marginalized out during the optimization
Implementation of the Levenberg Algorithm.
static double gaussRand(double mean, double sigma)
static double uniformRand(double lowerBndr, double upperBndr)
void computeActiveErrors()
int optimize(int iterations, bool online=false)
void setVerbose(bool verbose)
virtual bool initializeOptimization(HyperGraph::EdgeSet &eset)
void setAlgorithm(OptimizationAlgorithm *algorithm)
Vertex for a tracked point in space.
Stereo camera vertex, derived from SE3 class. Note that we use the actual pose of the vertex as its p...
static void setKcam(double fx, double fy, double cx, double cy, double tx)
3D pose Vertex, represented as an Isometry3
virtual bool addEdge(HyperGraph::Edge *e)
virtual bool addVertex(HyperGraph::Vertex *v, Data *userData)
double chi2() const
returns the chi2 of the current configuration