Skip to content

Commit

Permalink
[build] Move static header functions to inline functions. openMVG#520
Browse files Browse the repository at this point in the history
  • Loading branch information
pmoulon committed Apr 7, 2016
1 parent f32860d commit cd17098
Show file tree
Hide file tree
Showing 23 changed files with 47 additions and 57 deletions.
8 changes: 4 additions & 4 deletions src/openMVG/features/descriptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ std::istream& Descriptor<T,N>::read(std::istream& in)

/// Read descriptors from file
template<typename DescriptorsT >
static bool loadDescsFromFile(
inline bool loadDescsFromFile(
const std::string & sfileNameDescs,
DescriptorsT & vec_desc)
{
Expand All @@ -139,7 +139,7 @@ static bool loadDescsFromFile(

/// Write descriptors to file
template<typename DescriptorsT >
static bool saveDescsToFile(
inline bool saveDescsToFile(
const std::string & sfileNameDescs,
DescriptorsT & vec_desc)
{
Expand All @@ -156,7 +156,7 @@ static bool saveDescsToFile(

/// Read descriptors from file (in binary mode)
template<typename DescriptorsT >
static bool loadDescsFromBinFile(
inline bool loadDescsFromBinFile(
const std::string & sfileNameDescs,
DescriptorsT & vec_desc)
{
Expand All @@ -182,7 +182,7 @@ static bool loadDescsFromBinFile(

/// Write descriptors to file (in binary mode)
template<typename DescriptorsT >
static bool saveDescsToBinFile(
inline bool saveDescsToBinFile(
const std::string & sfileNameDescs,
DescriptorsT & vec_desc)
{
Expand Down
4 changes: 2 additions & 2 deletions src/openMVG/image/image_converter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void rgb2Float( const ImageIn& imaIn,
* @param[out] Output color
* @param factor scaling factor applied to input color components
*/
static inline
inline
void convertFloatToInt
(
const RGBfColor& valIn,
Expand All @@ -182,7 +182,7 @@ void convertFloatToInt
* @param[out] imaOut Output image
* @param factor scaling factor applied to each input color component
*/
static void rgbFloat2rgbInt(
inline void rgbFloat2rgbInt(
const Image< RGBfColor >& imaIn,
Image< RGBColor > *imaOut,
float factor = 255.f )
Expand Down
4 changes: 2 additions & 2 deletions src/openMVG/image/image_convolution.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void ImageConvolution( const Image & img , const Mat & kernel , Image & out )
** @param out Output image
**/
template< typename ImageTypeIn , typename ImageTypeOut, typename Kernel >
static void ImageHorizontalConvolution( const ImageTypeIn & img , const Kernel & kernel , ImageTypeOut & out )
void ImageHorizontalConvolution( const ImageTypeIn & img , const Kernel & kernel , ImageTypeOut & out )
{
typedef typename ImageTypeIn::Tpixel pix_t ;

Expand Down Expand Up @@ -186,7 +186,7 @@ void ImageSeparableConvolution( const ImageType & img ,
typedef Eigen::Matrix<float, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> RowMatrixXf;

/// Specialization for Float based image (for arbitrary sized kernel)
static void SeparableConvolution2d( const RowMatrixXf& image,
inline void SeparableConvolution2d( const RowMatrixXf& image,
const Eigen::Matrix<float, 1, Eigen::Dynamic>& kernel_x,
const Eigen::Matrix<float, 1, Eigen::Dynamic>& kernel_y,
RowMatrixXf* out )
Expand Down
4 changes: 2 additions & 2 deletions src/openMVG/image/image_diffusion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void ImageFEDCycle( Image & self , const Image & diff , const std::vector< typen
* @retval false if number is not prime
* @todo Move this function elsewhere since it's not an image related function
*/
static bool IsPrime( const int i )
inline bool IsPrime( const int i )
{
if( i == 1 )
{
Expand Down Expand Up @@ -278,7 +278,7 @@ static bool IsPrime( const int i )
* @param i Input number
* @return next prime greater or equal to input
*/
static inline int NextPrimeGreaterOrEqualTo( const int i )
inline int NextPrimeGreaterOrEqualTo( const int i )
{
if( IsPrime( i ) )
{
Expand Down
2 changes: 1 addition & 1 deletion src/openMVG/image/image_filtering.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ void ImageGaussianFilter( const Image & img , const double sigma , Image & out ,
** @param sigma Gaussian scale
** @return Kernel using specified parameters
**/
static inline Vec ComputeGaussianKernel( const size_t size , const double sigma )
inline Vec ComputeGaussianKernel( const size_t size , const double sigma )
{
// If kernel size is 0 computes it's size using uber formula
size_t k_size = ( size == 0 ) ? ceil( 2.0 * ( 1.0 + ( sigma - 0.8 ) / ( 0.3 ) ) ) : size ;
Expand Down
6 changes: 3 additions & 3 deletions src/openMVG/image/image_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ using namespace std;
namespace openMVG {
namespace image {

static bool CmpFormatExt(const char *a, const char *b) {
size_t len_a = strlen(a);
size_t len_b = strlen(b);
inline bool CmpFormatExt(const char *a, const char *b) {
const size_t len_a = strlen(a);
const size_t len_b = strlen(b);
if (len_a != len_b) return false;
for (size_t i = 0; i < len_a; ++i)
if (tolower(a[i]) != tolower(b[i]))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ using namespace linearProgramming;
// directions in a common global coordinate system.
//- Implementation of the LINEAR PROGRAM (8) page 5 of [1]:
//--
static void EncodeTi_from_tij(
inline void EncodeTi_from_tij(
const size_t nTranslation,
const std::vector<relativeInfo > & vec_relative,
sRMat & A, Vec & C,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ using namespace linearProgramming;
// directions in a common global coordinate system.
//- Implementation of the LINEAR PROGRAM (9) page 5 of [1]:
//--
static void EncodeTi_from_tij_OneLambdaPerTrif(
inline void EncodeTi_from_tij_OneLambdaPerTrif(
const size_t nTranslation,
const std::vector<relativeInfo > & vec_relative,
sRMat & A, Vec & C,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ using namespace linearProgramming;
//

/// Encode translation and structure linear program
static void EncodeTiXi(const Mat & M, //Scene representation
inline void EncodeTiXi(const Mat & M, //Scene representation
const std::vector<Mat3> & Ri,
double sigma, // Start upper bound
sRMat & A, Vec & C,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ using namespace linearProgramming;

/// Encode translation and structure linear program with slack variables
/// in order to handle noisy measurements.
static void EncodeTiXi_withNoise(const Mat & M, //Scene representation
inline void EncodeTiXi_withNoise(const Mat & M, //Scene representation
const std::vector<Mat3> & Ri,
double sigma, // Start upper bound
sRMat & A, Vec & C,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ using namespace linearProgramming;
// Implementation by Pierre Moulon
//

static void EncodeTriangulation(
inline void EncodeTriangulation(
const std::vector<Mat34> & Pi, // Projection matrices
const Mat2X & x_ij, // corresponding observations
double gamma, // Start upper bound
Expand Down
6 changes: 3 additions & 3 deletions src/openMVG/matching/indMatch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ struct IndMatch
IndexT i_, j_; // Left, right index
};

static inline std::ostream& operator<<(std::ostream & out, const IndMatch & obj) {
inline std::ostream& operator<<(std::ostream & out, const IndMatch & obj) {
return out << obj.i_ << " " << obj.j_;
}

static inline std::istream& operator>>(std::istream & in, IndMatch & obj) {
inline std::istream& operator>>(std::istream & in, IndMatch & obj) {
return in >> obj.i_ >> obj.j_;
}

Expand All @@ -74,7 +74,7 @@ typedef std::vector<matching::IndMatch> IndMatches;
/// The structure used to store corresponding point indexes per images pairs
typedef std::map< Pair, IndMatches > PairWiseMatches;

static Pair_Set getPairs(const PairWiseMatches & matches)
inline Pair_Set getPairs(const PairWiseMatches & matches)
{
Pair_Set pairs;
for(PairWiseMatches::const_iterator it = matches.begin(); it != matches.end(); ++it)
Expand Down
4 changes: 2 additions & 2 deletions src/openMVG/matching/indMatch_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
namespace openMVG {
namespace matching {

static bool Load
inline bool Load
(
PairWiseMatches & matches,
const std::string & filename
Expand Down Expand Up @@ -75,7 +75,7 @@ static bool Load
return false;
}

static bool Save
inline bool Save
(
const PairWiseMatches & matches,
const std::string & filename
Expand Down
8 changes: 4 additions & 4 deletions src/openMVG/matching/matching_filters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ using namespace std;
* \return void.
*/
template <typename DataInputIterator>
static void NNdistanceRatio
inline void NNdistanceRatio
(
DataInputIterator first, // distance start
DataInputIterator last, // distance end
Expand Down Expand Up @@ -74,7 +74,7 @@ static void NNdistanceRatio
* \return void.
*/
// TODO
static void SymmetricMatches(const vector<int> & vec_matches,
inline void SymmetricMatches(const vector<int> & vec_matches,
const vector<int> & vec_reversematches,
int NN,
vector<int> & vec_goodIndex)
Expand Down Expand Up @@ -104,7 +104,7 @@ static void SymmetricMatches(const vector<int> & vec_matches,
* \return void.
*/
template <typename Iterator, typename Type>
static void IntersectMatches( Iterator aStart, Iterator aEnd,
inline void IntersectMatches( Iterator aStart, Iterator aEnd,
Iterator bStart, Iterator bEnd,
vector<Type> & vec_out)
{
Expand All @@ -125,7 +125,7 @@ enum eMatchFilter
MATCHFILER_SYM_AND_NNDISTANCERATIO = MATCHFILTER_SYMMETRIC | MATCHFILTER_NNDISTANCERATIO
};

static void Filter( int NN,
inline void Filter( int NN,
const vector<int> & vec_Matches01,
const vector<float> & vec_distance01,
const vector<int> & vec_Matches10,
Expand Down
4 changes: 2 additions & 2 deletions src/openMVG/multiview/rotation_averaging_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ typedef std::vector<RelativeRotation> RelativeRotations;
typedef std::map<Pair, RelativeRotation> RelativeRotations_map;

/// List the pairs used by the relative rotations
static Pair_Set getPairs(const RelativeRotations & relRots)
inline Pair_Set getPairs(const RelativeRotations & relRots)
{
Pair_Set pairs;
for(RelativeRotations::const_iterator it = relRots.begin(); it != relRots.end(); ++it)
Expand All @@ -41,7 +41,7 @@ static Pair_Set getPairs(const RelativeRotations & relRots)
}

/// Convert a relative motion iterable sequence to RelativeRotation indexed by pairs
static RelativeRotations_map getMap(const RelativeRotations & relRots)
inline RelativeRotations_map getMap(const RelativeRotations & relRots)
{
RelativeRotations_map map_rots;
for(RelativeRotations::const_iterator it = relRots.begin(); it != relRots.end(); ++it)
Expand Down
4 changes: 2 additions & 2 deletions src/openMVG/multiview/solver_resection_p3p.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace euclidean_resection {

typedef Eigen::Matrix<double, 5, 1> Vec5;

static void solveQuartic( const Vec5 & factors, Vec4 & realRoots)
inline void solveQuartic( const Vec5 & factors, Vec4 & realRoots)
{
double A = factors[0];
double B = factors[1];
Expand Down Expand Up @@ -108,7 +108,7 @@ static void solveQuartic( const Vec5 & factors, Vec4 & realRoots)
* false if world points aligned
*/

static bool compute_P3P_Poses( const Mat3 & featureVectors, const Mat3 & worldPoints, Mat & solutions )
inline bool compute_P3P_Poses( const Mat3 & featureVectors, const Mat3 & worldPoints, Mat & solutions )
{
solutions = Mat(3, 4*4);

Expand Down
4 changes: 2 additions & 2 deletions src/openMVG/multiview/translation_averaging_common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ typedef std::vector< relativeInfo > RelativeInfo_Vec;
typedef std::map< Pair, std::pair<Mat3, Vec3> > RelativeInfo_Map;

// List the pairs used by the relative motions
static Pair_Set getPairs(const RelativeInfo_Vec & vec_relative)
inline Pair_Set getPairs(const RelativeInfo_Vec & vec_relative)
{
Pair_Set pair_set;
for(size_t i = 0; i < vec_relative.size(); ++i)
Expand All @@ -34,7 +34,7 @@ static Pair_Set getPairs(const RelativeInfo_Vec & vec_relative)
}

// List the index used by the relative motions
static std::set<IndexT> getIndexT(const RelativeInfo_Vec & vec_relative)
inline std::set<IndexT> getIndexT(const RelativeInfo_Vec & vec_relative)
{
std::set<IndexT> indexT_set;
for (RelativeInfo_Vec::const_iterator iter = vec_relative.begin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ using namespace openMVG::geometry;


/// Camera pair epipole (Projection of camera center 2 in the image plane 1)
static Vec3 epipole_from_P(const Mat34& P1, const Pose3& P2)
inline Vec3 epipole_from_P(const Mat34& P1, const Pose3& P2)
{
const Vec3 c = P2.center();
Vec4 center;
Expand All @@ -36,7 +36,7 @@ static Vec3 epipole_from_P(const Mat34& P1, const Pose3& P2)
/// Export point feature based vector to a matrix [(x,y)'T, (x,y)'T]
/// Use the camera intrinsics in order to get undistorted pixel coordinates
template<typename MatT >
static void PointsToMat(
void PointsToMat(
const IntrinsicBase * cam,
const PointFeatures & vec_feats,
MatT & m)
Expand Down
2 changes: 1 addition & 1 deletion src/openMVG/sfm/sfm_data_io_baf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace sfm {
// The ids allow to establish a link between 3D point observations & the corresponding views
//--
// Export missing poses as Identity pose to keep tracking of the original id_pose indexes
static bool Save_BAF(
inline bool Save_BAF(
const SfM_Data & sfm_data,
const std::string & filename,
ESfM_Data flags_part)
Expand Down
2 changes: 1 addition & 1 deletion src/openMVG/sfm/sfm_data_io_ply.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace openMVG {
namespace sfm {

/// Save the structure and camera positions of a SfM_Data container as 3D points in a PLY ASCII file.
static bool Save_PLY(
inline bool Save_PLY(
const SfM_Data & sfm_data,
const std::string & filename,
ESfM_Data flags_part)
Expand Down
24 changes: 7 additions & 17 deletions src/openMVG/sfm/sfm_filters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace openMVG {
namespace sfm {

template<typename IterableIndexTSequence>
static std::set<IndexT> getIndexes(const IterableIndexTSequence & seq)
inline std::set<IndexT> getIndexes(const IterableIndexTSequence & seq)
{
std::set<IndexT> setOut;
for(typename IterableIndexTSequence::const_iterator it = seq.begin(); it != seq.end(); ++it)
Expand All @@ -26,7 +26,7 @@ static std::set<IndexT> getIndexes(const IterableIndexTSequence & seq)
/// Filter the toFilter iterable sequence (keep only the element that share a common index
/// with the provided Ids index list).
template<typename T>
static void KeepOnlyReferencedElement(
inline void KeepOnlyReferencedElement(
const std::set<IndexT> & Ids,
T & toFilter)
{
Expand All @@ -35,9 +35,7 @@ static void KeepOnlyReferencedElement(

// Specialization for RelativeInfo_Map
template<>
#ifdef _MSC_VER
static
#endif
inline
void KeepOnlyReferencedElement(
const std::set<IndexT> & set_remainingIds,
RelativeInfo_Map& map_relatives)
Expand All @@ -58,9 +56,7 @@ void KeepOnlyReferencedElement(

// Specialization for RelativeInfo_Map
template<>
#ifdef _MSC_VER
static
#endif
inline
void KeepOnlyReferencedElement(
const std::set<IndexT> & set_remainingIds,
rotation_averaging::RelativeRotations& relative_info)
Expand All @@ -81,9 +77,7 @@ void KeepOnlyReferencedElement(

// Specialization for PairWiseMatches
template<>
#ifdef _MSC_VER
static
#endif
inline
void KeepOnlyReferencedElement(
const std::set<IndexT> & set_remainingIds,
openMVG::matching::PairWiseMatches& map_matches)
Expand All @@ -103,9 +97,7 @@ void KeepOnlyReferencedElement(

// Specialization for std::map<IndexT,Mat3>
template<>
#ifdef _MSC_VER
static
#endif
inline
void KeepOnlyReferencedElement(
const std::set<IndexT> & set_remainingIds,
std::map<IndexT,Mat3>& map_Mat3)
Expand All @@ -124,9 +116,7 @@ void KeepOnlyReferencedElement(

// Specialization for RelativeInfo_Vec
template<>
#ifdef _MSC_VER
static
#endif
inline
void KeepOnlyReferencedElement(
const std::set<IndexT> & set_remainingIds,
RelativeInfo_Vec & relativeInfo_vec)
Expand Down
Loading

0 comments on commit cd17098

Please sign in to comment.