Skip to content

Commit

Permalink
[CORE] Made vp an alias for visp namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
rlagneau committed Jun 5, 2024
1 parent 567441d commit a2aba12
Show file tree
Hide file tree
Showing 26 changed files with 144 additions and 208 deletions.
3 changes: 3 additions & 0 deletions cmake/templates/vpConfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@
#define END_VISP_NAMESPACE }
// Create an empty namespace to ensure that "using VISP_NAMESPACE_NAME;" does not raise an error
namespace VISP_NAMESPACE_NAME {}

// Create an alias for compatibility with older versions of ViSP
namespace vp = VISP_NAMESPACE_NAME;
#else
#define VISP_NAMESPACE_ADDRESSING
#define BEGIN_VISP_NAMESPACE
Expand Down
11 changes: 2 additions & 9 deletions modules/core/include/visp3/core/vpEigenConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,7 @@
#endif
#include <visp3/core/vpMatrix.h>

#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
// The following macro forces us to us
#define VISP_EIGEN_CONVERSION_NAMESPACE vp
#else
#define VISP_EIGEN_CONVERSION_NAMESPACE VISP_NAMESPACE_NAME
#endif

namespace VISP_EIGEN_CONVERSION_NAMESPACE
namespace VISP_NAMESPACE_NAME
{
#ifdef VISP_HAVE_EIGEN3
/* Eigen to ViSP */
Expand Down Expand Up @@ -102,5 +95,5 @@ VISP_EXPORT void visp2eigen(const VISP_NAMESPACE_ADDRESSING vpColVector &src, Ei

VISP_EXPORT void visp2eigen(const VISP_NAMESPACE_ADDRESSING vpRowVector &src, Eigen::RowVectorXd &dst);
#endif
} // namespace vp
} // namespace VISP_NAMESPACE_NAME
#endif
4 changes: 2 additions & 2 deletions modules/core/src/math/matrix/vpEigenConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

#include <visp3/core/vpEigenConversion.h>

namespace VISP_EIGEN_CONVERSION_NAMESPACE
namespace VISP_NAMESPACE_NAME
{
#ifdef VISP_HAVE_EIGEN3
/* Eigen to ViSP */
Expand Down Expand Up @@ -91,4 +91,4 @@ void visp2eigen(const VISP_NAMESPACE_ADDRESSING vpRowVector &src, Eigen::RowVect
dst = Eigen::RowVectorXd::Map(src.data, src.size());
}
#endif
} // namespace vp
} // namespace VISP_NAMESPACE_NAME
66 changes: 33 additions & 33 deletions modules/core/test/math/testEigenConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,23 @@ TEST_CASE("vpMatrix <--> Eigen::MatrixXd/Matrix3Xd conversion", "[eigen_conversi

{
Eigen::MatrixXd eigen_m;
VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_m, eigen_m);
VISP_NAMESPACE_NAME::visp2eigen(visp_m, eigen_m);
std::cout << "Eigen MatrixXd:\n" << eigen_m << std::endl;

vpMatrix visp_m2;
VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_m, visp_m2);
VISP_NAMESPACE_NAME::eigen2visp(eigen_m, visp_m2);
std::cout << "ViSP vpMatrix:\n" << visp_m2 << std::endl;

REQUIRE(visp_m == visp_m2);
std::cout << std::endl;
}
{
Eigen::Matrix3Xd eigen_m;
VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_m, eigen_m);
VISP_NAMESPACE_NAME::visp2eigen(visp_m, eigen_m);
std::cout << "Eigen Matrix3Xd:\n" << eigen_m << std::endl;

vpMatrix visp_m2;
VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_m, visp_m2);
VISP_NAMESPACE_NAME::eigen2visp(eigen_m, visp_m2);
std::cout << "ViSP vpMatrix:\n" << visp_m2 << std::endl;

REQUIRE(visp_m == visp_m2);
Expand All @@ -114,15 +114,15 @@ TEST_CASE("Eigen::MatrixXd <--> vpMatrix conversion", "[eigen_conversion]")
std::cout << "Eigen Matrix (row major: " << eigen_m.IsRowMajor << "):\n" << eigen_m << std::endl;

vpMatrix visp_m;
VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_m, visp_m);
VISP_NAMESPACE_NAME::eigen2visp(eigen_m, visp_m);
std::cout << "ViSP vpMatrix:\n" << visp_m << std::endl;

Eigen::MatrixXd eigen_m2;
VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_m, eigen_m2);
VISP_NAMESPACE_NAME::visp2eigen(visp_m, eigen_m2);
std::cout << "Eigen MatrixXd (row major: " << eigen_m2.IsRowMajor << "):\n" << eigen_m2 << std::endl;

vpMatrix visp_m2;
VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_m2, visp_m2);
VISP_NAMESPACE_NAME::eigen2visp(eigen_m2, visp_m2);
REQUIRE(visp_m == visp_m2);
std::cout << std::endl;
}
Expand All @@ -143,15 +143,15 @@ TEST_CASE("Eigen::MatrixX4d <--> vpMatrix conversion", "[eigen_conversion]")
std::cout << "Eigen MatrixX4d (row major: " << eigen_m.IsRowMajor << "):\n" << eigen_m << std::endl;

vpMatrix visp_m;
VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_m, visp_m);
VISP_NAMESPACE_NAME::eigen2visp(eigen_m, visp_m);
std::cout << "ViSP vpMatrix:\n" << visp_m << std::endl;

Eigen::MatrixX4d eigen_m2;
VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_m, eigen_m2);
VISP_NAMESPACE_NAME::visp2eigen(visp_m, eigen_m2);
std::cout << "Eigen MatrixX4d (row major: " << eigen_m2.IsRowMajor << "):\n" << eigen_m2 << std::endl;

vpMatrix visp_m2;
VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_m2, visp_m2);
VISP_NAMESPACE_NAME::eigen2visp(eigen_m2, visp_m2);
REQUIRE(visp_m == visp_m2);
std::cout << std::endl;
}
Expand All @@ -172,15 +172,15 @@ TEST_CASE("Eigen::Matrix<double, Dynamic, Dynamic, RowMajor> <--> vpMatrix conve
std::cout << "Eigen Matrix (RowMajor):\n" << eigen_m << std::endl;

vpMatrix visp_m;
VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_m, visp_m);
VISP_NAMESPACE_NAME::eigen2visp(eigen_m, visp_m);
std::cout << "ViSP vpMatrix:\n" << visp_m << std::endl;

Eigen::MatrixXd eigen_m2;
VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_m, eigen_m2);
VISP_NAMESPACE_NAME::visp2eigen(visp_m, eigen_m2);
std::cout << "Eigen MatrixXd (row major: " << eigen_m2.IsRowMajor << "):\n" << eigen_m2 << std::endl;

vpMatrix visp_m2;
VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_m2, visp_m2);
VISP_NAMESPACE_NAME::eigen2visp(eigen_m2, visp_m2);
REQUIRE(visp_m == visp_m2);
std::cout << std::endl;
}
Expand All @@ -201,15 +201,15 @@ TEST_CASE("Eigen::Matrix<double, Dynamic, Dynamic, ColMajor> <--> vpMatrix conve
std::cout << "Eigen Matrix (ColMajor):\n" << eigen_m << std::endl;

vpMatrix visp_m;
VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_m, visp_m);
VISP_NAMESPACE_NAME::eigen2visp(eigen_m, visp_m);
std::cout << "ViSP vpMatrix:\n" << visp_m << std::endl;

Eigen::MatrixXd eigen_m2;
VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_m, eigen_m2);
VISP_NAMESPACE_NAME::visp2eigen(visp_m, eigen_m2);
std::cout << "Eigen MatrixXd (row major: " << eigen_m2.IsRowMajor << "):\n" << eigen_m2 << std::endl;

vpMatrix visp_m2;
VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_m2, visp_m2);
VISP_NAMESPACE_NAME::eigen2visp(eigen_m2, visp_m2);
REQUIRE(visp_m == visp_m2);
std::cout << std::endl;
}
Expand All @@ -218,11 +218,11 @@ TEST_CASE("vpHomogeneousMatrix <--> Eigen::Matrix4d conversion", "[eigen_convers
{
vpHomogeneousMatrix visp_cMo(0.1, 0.2, 0.3, 0.1, 0.2, 0.3);
Eigen::Matrix4d eigen_cMo;
VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_cMo, eigen_cMo);
VISP_NAMESPACE_NAME::visp2eigen(visp_cMo, eigen_cMo);
std::cout << "Eigen Matrix4d cMo:\n" << eigen_cMo << std::endl;

vpHomogeneousMatrix visp_cMo2;
VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_cMo, visp_cMo2);
VISP_NAMESPACE_NAME::eigen2visp(eigen_cMo, visp_cMo2);
std::cout << "ViSP vpHomogeneousMatrix cMo:\n" << visp_cMo2 << std::endl;
REQUIRE(visp_cMo == visp_cMo2);
std::cout << std::endl;
Expand All @@ -232,12 +232,12 @@ TEST_CASE("vpHomogeneousMatrix <--> Eigen::Matrix4f + double casting conversion"
{
vpHomogeneousMatrix visp_cMo; // identity for float to double casting
Eigen::Matrix4d eigen_cMo_tmp;
VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_cMo, eigen_cMo_tmp);
VISP_NAMESPACE_NAME::visp2eigen(visp_cMo, eigen_cMo_tmp);
Eigen::Matrix4f eigen_cMo = eigen_cMo_tmp.cast<float>();
std::cout << "Eigen Matrix4f cMo:\n" << eigen_cMo << std::endl;

vpHomogeneousMatrix visp_cMo2;
VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_cMo.cast<double>(), visp_cMo2);
VISP_NAMESPACE_NAME::eigen2visp(eigen_cMo.cast<double>(), visp_cMo2);
std::cout << "ViSP vpHomogeneousMatrix cMo:\n" << visp_cMo2 << std::endl;
REQUIRE(visp_cMo == visp_cMo2);
std::cout << std::endl;
Expand All @@ -247,11 +247,11 @@ TEST_CASE("vpQuaternionVector <--> Eigen::Quaternionf conversion", "[eigen_conve
{
vpQuaternionVector visp_quaternion(0, 1, 2, 3);
Eigen::Quaternionf eigen_quaternion;
VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_quaternion, eigen_quaternion);
VISP_NAMESPACE_NAME::visp2eigen(visp_quaternion, eigen_quaternion);
std::cout << "Eigen quaternion: " << eigen_quaternion << std::endl;

vpQuaternionVector visp_quaternion2;
VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_quaternion, visp_quaternion2);
VISP_NAMESPACE_NAME::eigen2visp(eigen_quaternion, visp_quaternion2);
std::cout << "ViSP quaternion: " << visp_quaternion2.t() << std::endl;
REQUIRE(visp_quaternion == visp_quaternion2);
std::cout << std::endl;
Expand All @@ -261,11 +261,11 @@ TEST_CASE("vpThetaUVector <--> Eigen::AngleAxisf conversion", "[eigen_conversion
{
vpThetaUVector visp_thetau(0, 1, 2);
Eigen::AngleAxisf eigen_angle_axis;
VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_thetau, eigen_angle_axis);
VISP_NAMESPACE_NAME::visp2eigen(visp_thetau, eigen_angle_axis);
std::cout << "Eigen AngleAxis: " << eigen_angle_axis << std::endl;

vpThetaUVector visp_thetau2;
VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_angle_axis, visp_thetau2);
VISP_NAMESPACE_NAME::eigen2visp(eigen_angle_axis, visp_thetau2);
std::cout << "ViSP AngleAxis: " << visp_thetau2.t() << std::endl;
REQUIRE(visp_thetau == visp_thetau2);
std::cout << std::endl;
Expand All @@ -276,11 +276,11 @@ TEST_CASE("vpColVector <--> Eigen::VectorXd conversion", "[eigen_conversion]")
vpColVector visp_col(4, 4);
visp_col = 10;
Eigen::VectorXd eigen_col;
VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_col, eigen_col);
VISP_NAMESPACE_NAME::visp2eigen(visp_col, eigen_col);
std::cout << "Eigen VectorXd: " << eigen_col.transpose() << std::endl;

vpColVector visp_col2;
VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_col, visp_col2);
VISP_NAMESPACE_NAME::eigen2visp(eigen_col, visp_col2);
std::cout << "ViSP vpColVector: " << visp_col2.t() << std::endl;
REQUIRE(visp_col == visp_col2);
std::cout << std::endl;
Expand All @@ -291,11 +291,11 @@ TEST_CASE("vpRowVector <--> Eigen::RowVectorXd conversion", "[eigen_conversion]"
vpRowVector visp_row(4, 10);
visp_row = 10;
Eigen::RowVectorXd eigen_row;
VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_row, eigen_row);
VISP_NAMESPACE_NAME::visp2eigen(visp_row, eigen_row);
std::cout << "Eigen RowVectorXd: " << eigen_row << std::endl;

vpRowVector visp_row2;
VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_row, visp_row2);
VISP_NAMESPACE_NAME::eigen2visp(eigen_row, visp_row2);
std::cout << "ViSP vpRowVector: " << visp_row2 << std::endl;
REQUIRE(visp_row == visp_row2);
std::cout << std::endl;
Expand All @@ -306,15 +306,15 @@ TEST_CASE("Eigen::RowVector4d <--> vpRowVector conversion", "[eigen_conversion]"
Eigen::RowVector4d eigen_row;
eigen_row << 9, 8, 7, 6;
vpRowVector visp_row;
VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_row, visp_row);
VISP_NAMESPACE_NAME::eigen2visp(eigen_row, visp_row);
std::cout << "ViSP vpRowVector: " << visp_row << std::endl;

Eigen::RowVector4d eigen_row2;
VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_row, eigen_row2);
VISP_NAMESPACE_NAME::visp2eigen(visp_row, eigen_row2);
std::cout << "Eigen RowVector4d: " << eigen_row2 << std::endl;

vpRowVector visp_row2;
VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_row2, visp_row2);
VISP_NAMESPACE_NAME::eigen2visp(eigen_row2, visp_row2);
REQUIRE(visp_row == visp_row2);
std::cout << std::endl;
}
Expand All @@ -324,11 +324,11 @@ TEST_CASE("vpRowVector <--> Eigen::RowVector4d conversion", "[eigen_conversion]"
vpRowVector visp_row(4, 10);
visp_row = 10;
Eigen::RowVector4d eigen_row;
VISP_EIGEN_CONVERSION_NAMESPACE::visp2eigen(visp_row, eigen_row);
VISP_NAMESPACE_NAME::visp2eigen(visp_row, eigen_row);
std::cout << "Eigen RowVector4d: " << eigen_row << std::endl;

vpRowVector visp_row2;
VISP_EIGEN_CONVERSION_NAMESPACE::eigen2visp(eigen_row, visp_row2);
VISP_NAMESPACE_NAME::eigen2visp(eigen_row, visp_row2);
std::cout << "ViSP vpRowVector: " << visp_row2 << std::endl;
REQUIRE(visp_row == visp_row2);
std::cout << std::endl;
Expand Down
8 changes: 1 addition & 7 deletions modules/imgproc/include/visp3/imgproc/vpContours.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,7 @@
#include <visp3/core/vpImage.h>
#include <visp3/core/vpPolygon.h>

#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
#define VISP_CONTOURS_NAMESPACE vp
#else
#define VISP_CONTOURS_NAMESPACE VISP_NAMESPACE_NAME
#endif

namespace VISP_CONTOURS_NAMESPACE
namespace VISP_NAMESPACE_NAME
{

/*!
Expand Down
8 changes: 1 addition & 7 deletions modules/imgproc/include/visp3/imgproc/vpImgproc.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,7 @@
#include <visp3/core/vpImageMorphology.h>
#include <visp3/imgproc/vpContours.h>

#ifdef VISP_BUILD_DEPRECATED_FUNCTIONS
#define VISP_IMGPROC_NAMESPACE vp
#else
#define VISP_IMGPROC_NAMESPACE VISP_NAMESPACE_NAME
#endif

namespace VISP_IMGPROC_NAMESPACE
namespace VISP_NAMESPACE_NAME
{

#define USE_OLD_FILL_HOLE 0
Expand Down
12 changes: 2 additions & 10 deletions modules/imgproc/src/vpCLAHE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,9 @@
#include <visp3/core/vpImageConvert.h>
#include <visp3/imgproc/vpImgproc.h>

#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
namespace vp
#else
namespace VISP_NAMESPACE_NAME
#endif
{

#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) && defined(ENABLE_VISP_NAMESPACE)
using namespace VISP_NAMESPACE_NAME;
#endif

int fastRound(float value) { return static_cast<int>(value + 0.5f); }

void clipHistogram(const std::vector<int> &hist, std::vector<int> &clippedHist, int limit)
Expand Down Expand Up @@ -405,7 +397,7 @@ void clahe(const vpImage<unsigned char> &I1, vpImage<unsigned char> &I2, int blo
++hist[fastRound((I1[yi][xi] / 255.0f) * bins)];
}
}
}
}
else {
hist = prev_hist;

Expand Down Expand Up @@ -454,9 +446,9 @@ void clahe(const vpImage<unsigned char> &I1, vpImage<unsigned char> &I2, int blo
int limit = static_cast<int>(((slope * n) / bins) + 0.5f);
I2[y][x] = fastRound(transferValue(v, hist, clippedHist, limit) * 255.0f);
}
}
}
}
}

void clahe(const vpImage<vpRGBa> &I1, vpImage<vpRGBa> &I2, int blockRadius, int bins, float slope, bool fast)
{
Expand Down
7 changes: 0 additions & 7 deletions modules/imgproc/src/vpConnectedComponents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,8 @@
#include <queue>
#include <visp3/imgproc/vpImgproc.h>

#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
namespace vp
#else
namespace VISP_NAMESPACE_NAME
#endif
{
#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) && defined(ENABLE_VISP_NAMESPACE)
using namespace VISP_NAMESPACE_NAME;
#endif

void getNeighbors(const vpImage<unsigned char> &I, std::queue<vpImagePoint> &listOfNeighbors, unsigned int i,
unsigned int j, const vpImageMorphology::vpConnexityType &connexity)
Expand Down
4 changes: 0 additions & 4 deletions modules/imgproc/src/vpContours.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@
#include <map>
#include <visp3/imgproc/vpImgproc.h>

#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
namespace vp
#else
namespace VISP_NAMESPACE_NAME
#endif
{
#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) && defined(ENABLE_VISP_NAMESPACE)
using namespace VISP_NAMESPACE_NAME;
Expand Down
7 changes: 0 additions & 7 deletions modules/imgproc/src/vpFloodFill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,8 @@
#include <queue>
#include <visp3/imgproc/vpImgproc.h>

#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
namespace vp
#else
namespace VISP_NAMESPACE_NAME
#endif
{
#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) && defined(ENABLE_VISP_NAMESPACE)
using namespace VISP_NAMESPACE_NAME;
#endif

void floodFill(vpImage<unsigned char> &I, const vpImagePoint &seedPoint, const unsigned char oldValue,
const unsigned char newValue, const vpImageMorphology::vpConnexityType &connexity)
Expand Down
2 changes: 1 addition & 1 deletion modules/imgproc/src/vpImgproc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#include <visp3/core/vpMath.h>
#include <visp3/imgproc/vpImgproc.h>

namespace VISP_IMGPROC_NAMESPACE
namespace VISP_NAMESPACE_NAME
{
#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS) && defined(ENABLE_VISP_NAMESPACE)
using namespace VISP_NAMESPACE_NAME;
Expand Down
Loading

0 comments on commit a2aba12

Please sign in to comment.