Skip to content

Commit

Permalink
[sfm/ba] Reduce memory usage openMVG#585
Browse files Browse the repository at this point in the history
Using a pointer to the 2D observation data rather than using a copy.
  • Loading branch information
pmoulon committed Jun 28, 2016
1 parent 20da3e2 commit 88573df
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions src/openMVG/sfm/sfm_data_BA_ceres_camera_functor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ struct WeightedCostFunction
struct ResidualErrorFunctor_Pinhole_Intrinsic
{
ResidualErrorFunctor_Pinhole_Intrinsic(const double* const pos_2dpoint)
:m_pos_2dpoint(pos_2dpoint)
{
m_pos_2dpoint[0] = pos_2dpoint[0];
m_pos_2dpoint[1] = pos_2dpoint[1];
}

// Enum to map intrinsics parameters between openMVG & ceres camera data parameter block.
Expand Down Expand Up @@ -166,7 +165,7 @@ struct ResidualErrorFunctor_Pinhole_Intrinsic
}
}

double m_pos_2dpoint[2]; // The 2D observation
const double * m_pos_2dpoint; // The 2D observation
};

/**
Expand All @@ -183,9 +182,8 @@ struct ResidualErrorFunctor_Pinhole_Intrinsic
struct ResidualErrorFunctor_Pinhole_Intrinsic_Radial_K1
{
ResidualErrorFunctor_Pinhole_Intrinsic_Radial_K1(const double* const pos_2dpoint)
:m_pos_2dpoint(pos_2dpoint)
{
m_pos_2dpoint[0] = pos_2dpoint[0];
m_pos_2dpoint[1] = pos_2dpoint[1];
}

// Enum to map intrinsics parameters between openMVG & ceres camera data parameter block.
Expand Down Expand Up @@ -256,7 +254,7 @@ struct ResidualErrorFunctor_Pinhole_Intrinsic_Radial_K1

return true;
}

static const int num_residuals() { return 2; }

// Factory to hide the construction of the CostFunction object from
Expand Down Expand Up @@ -284,7 +282,7 @@ struct ResidualErrorFunctor_Pinhole_Intrinsic_Radial_K1
}
}

double m_pos_2dpoint[2]; // The 2D observation
const double * m_pos_2dpoint; // The 2D observation
};

/**
Expand All @@ -301,9 +299,8 @@ struct ResidualErrorFunctor_Pinhole_Intrinsic_Radial_K1
struct ResidualErrorFunctor_Pinhole_Intrinsic_Radial_K3
{
ResidualErrorFunctor_Pinhole_Intrinsic_Radial_K3(const double* const pos_2dpoint)
:m_pos_2dpoint(pos_2dpoint)
{
m_pos_2dpoint[0] = pos_2dpoint[0];
m_pos_2dpoint[1] = pos_2dpoint[1];
}

// Enum to map intrinsics parameters between openMVG & ceres camera data parameter block.
Expand Down Expand Up @@ -385,7 +382,7 @@ struct ResidualErrorFunctor_Pinhole_Intrinsic_Radial_K3

// Factory to hide the construction of the CostFunction object from
// the client code.
static ceres::CostFunction* Create
static ceres::CostFunction* Create
(
const Vec2 & observation,
const double weight = 0.0
Expand All @@ -408,7 +405,7 @@ struct ResidualErrorFunctor_Pinhole_Intrinsic_Radial_K3
}
}

double m_pos_2dpoint[2]; // The 2D observation
const double * m_pos_2dpoint; // The 2D observation
};

/**
Expand All @@ -425,9 +422,8 @@ struct ResidualErrorFunctor_Pinhole_Intrinsic_Radial_K3
struct ResidualErrorFunctor_Pinhole_Intrinsic_Brown_T2
{
ResidualErrorFunctor_Pinhole_Intrinsic_Brown_T2(const double* const pos_2dpoint)
:m_pos_2dpoint(pos_2dpoint)
{
m_pos_2dpoint[0] = pos_2dpoint[0];
m_pos_2dpoint[1] = pos_2dpoint[1];
}

// Enum to map intrinsics parameters between openMVG & ceres camera data parameter block.
Expand Down Expand Up @@ -538,7 +534,7 @@ struct ResidualErrorFunctor_Pinhole_Intrinsic_Brown_T2
}
}

double m_pos_2dpoint[2]; // The 2D observation
const double * m_pos_2dpoint; // The 2D observation
};


Expand All @@ -557,9 +553,8 @@ struct ResidualErrorFunctor_Pinhole_Intrinsic_Brown_T2
struct ResidualErrorFunctor_Pinhole_Intrinsic_Fisheye
{
ResidualErrorFunctor_Pinhole_Intrinsic_Fisheye(const double* const pos_2dpoint)
:m_pos_2dpoint(pos_2dpoint)
{
m_pos_2dpoint[0] = pos_2dpoint[0];
m_pos_2dpoint[1] = pos_2dpoint[1];
}

// Enum to map intrinsics parameters between openMVG & ceres camera data parameter block.
Expand Down Expand Up @@ -676,7 +671,7 @@ struct ResidualErrorFunctor_Pinhole_Intrinsic_Fisheye
}
}

double m_pos_2dpoint[2]; // The 2D observation
const double * m_pos_2dpoint; // The 2D observation
};

} // namespace sfm
Expand Down

0 comments on commit 88573df

Please sign in to comment.