Skip to content

Commit

Permalink
[FIX] Various fixes related to VISP_BUILD_DEPRECATED_FUNCTIONS
Browse files Browse the repository at this point in the history
  • Loading branch information
rlagneau committed May 27, 2024
1 parent 13186d6 commit 1a8469e
Show file tree
Hide file tree
Showing 15 changed files with 122 additions and 87 deletions.
25 changes: 13 additions & 12 deletions modules/core/include/visp3/core/vpEigenConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#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
Expand All @@ -50,56 +51,56 @@ namespace VISP_EIGEN_CONVERSION_NAMESPACE
{
#ifdef VISP_HAVE_EIGEN3
/* Eigen to ViSP */
VISP_EXPORT void eigen2visp(const Eigen::MatrixXd &src, vpMatrix &dst);
VISP_EXPORT void eigen2visp(const Eigen::MatrixXd &src, VISP_NAMESPACE_ADDRESSING vpMatrix &dst);

VISP_EXPORT void eigen2visp(const Eigen::MatrixXd &src, vpHomogeneousMatrix &dst);
VISP_EXPORT void eigen2visp(const Eigen::MatrixXd &src, VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &dst);

template <typename Type> void eigen2visp(const Eigen::Quaternion<Type> &src, vpQuaternionVector &dst)
template <typename Type> void eigen2visp(const Eigen::Quaternion<Type> &src, VISP_NAMESPACE_ADDRESSING vpQuaternionVector &dst)
{
dst.build(src.x(), src.y(), src.z(), src.w());
}

template <typename Type> void eigen2visp(const Eigen::AngleAxis<Type> &src, vpThetaUVector &dst)
template <typename Type> void eigen2visp(const Eigen::AngleAxis<Type> &src, VISP_NAMESPACE_ADDRESSING vpThetaUVector &dst)
{
dst.build(src.angle() * src.axis()(0), src.angle() * src.axis()(1), src.angle() * src.axis()(2));
}

VISP_EXPORT void eigen2visp(const Eigen::VectorXd &src, vpColVector &dst);
VISP_EXPORT void eigen2visp(const Eigen::VectorXd &src, VISP_NAMESPACE_ADDRESSING vpColVector &dst);

VISP_EXPORT void eigen2visp(const Eigen::RowVectorXd &src, vpRowVector &dst);
VISP_EXPORT void eigen2visp(const Eigen::RowVectorXd &src, VISP_NAMESPACE_ADDRESSING vpRowVector &dst);

/* ViSP to Eigen */
template <typename Derived> void visp2eigen(const vpMatrix &src, Eigen::MatrixBase<Derived> &dst)
template <typename Derived> void visp2eigen(const VISP_NAMESPACE_ADDRESSING vpMatrix &src, Eigen::MatrixBase<Derived> &dst)
{
dst = Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> >(src.data, src.getRows(),
src.getCols());
}

template <typename Derived> void visp2eigen(const vpHomogeneousMatrix &src, Eigen::MatrixBase<Derived> &dst)
template <typename Derived> void visp2eigen(const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &src, Eigen::MatrixBase<Derived> &dst)
{
dst = Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> >(src.data, src.getRows(),
src.getCols());
}

template <typename Type> void visp2eigen(const vpQuaternionVector &src, Eigen::Quaternion<Type> &dst)
template <typename Type> void visp2eigen(const VISP_NAMESPACE_ADDRESSING vpQuaternionVector &src, Eigen::Quaternion<Type> &dst)
{
dst.w() = static_cast<Type>(src.w());
dst.x() = static_cast<Type>(src.x());
dst.y() = static_cast<Type>(src.y());
dst.z() = static_cast<Type>(src.z());
}

template <typename Type> void visp2eigen(const vpThetaUVector &src, Eigen::AngleAxis<Type> &dst)
template <typename Type> void visp2eigen(const VISP_NAMESPACE_ADDRESSING vpThetaUVector &src, Eigen::AngleAxis<Type> &dst)
{
dst.angle() = static_cast<Type>(src.getTheta());
dst.axis()(0) = static_cast<Type>(src.getU()[0]);
dst.axis()(1) = static_cast<Type>(src.getU()[1]);
dst.axis()(2) = static_cast<Type>(src.getU()[2]);
}

VISP_EXPORT void visp2eigen(const vpColVector &src, Eigen::VectorXd &dst);
VISP_EXPORT void visp2eigen(const VISP_NAMESPACE_ADDRESSING vpColVector &src, Eigen::VectorXd &dst);

VISP_EXPORT void visp2eigen(const vpRowVector &src, Eigen::RowVectorXd &dst);
VISP_EXPORT void visp2eigen(const VISP_NAMESPACE_ADDRESSING vpRowVector &src, Eigen::RowVectorXd &dst);
#endif
} // namespace vp
#endif
8 changes: 8 additions & 0 deletions modules/core/include/visp3/core/vpHinkley.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
#include <visp3/core/vpConfig.h>

#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)

#if defined(ENABLE_VISP_NAMESPACE)
namespace VISP_NAMESPACE_NAME
{
#endif
/*!
\class vpHinkley
\deprecated This class is deprecated. You should rather use vpStatisticalTestHinkley.
Expand Down Expand Up @@ -166,5 +171,8 @@ class VISP_EXPORT vpHinkley
double Tk;
double Nk;
};
#if defined(ENABLE_VISP_NAMESPACE)
}
#endif
#endif
#endif
2 changes: 1 addition & 1 deletion modules/core/include/visp3/core/vpIoTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#include <complex>

#if VISP_CXX_STANDARD > VISP_CXX_STANDARD_98
namespace VISP_NAMESPACE_NAME
namespace visp
{
// https://github.com/BinomialLLC/basis_universal/blob/ad9386a4a1cf2a248f7bbd45f543a7448db15267/encoder/basisu_miniz.h#L665
static inline unsigned long vp_mz_crc32(unsigned long crc, const unsigned char *ptr, size_t buf_len)
Expand Down
14 changes: 7 additions & 7 deletions modules/core/src/math/matrix/vpEigenConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,24 @@ namespace VISP_EIGEN_CONVERSION_NAMESPACE
{
#ifdef VISP_HAVE_EIGEN3
/* Eigen to ViSP */
void eigen2visp(const Eigen::MatrixXd &src, vpMatrix &dst)
void eigen2visp(const Eigen::MatrixXd &src, VISP_NAMESPACE_ADDRESSING vpMatrix &dst)
{
dst.resize(static_cast<unsigned int>(src.rows()), static_cast<unsigned int>(src.cols()), false, false);
Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> >(&dst.data[0], src.rows(),
src.cols()) = src;
}

void eigen2visp(const Eigen::MatrixXd &src, vpHomogeneousMatrix &dst)
void eigen2visp(const Eigen::MatrixXd &src, VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &dst)
{
if ((src.rows() != 4) || (src.cols() != 4)) {
throw vpException(vpException::dimensionError, "Input Eigen Matrix must be of size (4,4)!");
throw VISP_NAMESPACE_ADDRESSING vpException(VISP_NAMESPACE_ADDRESSING vpException::dimensionError, "Input Eigen Matrix must be of size (4,4)!");
}

Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> >(&dst.data[0], src.rows(),
src.cols()) = src;
}

void eigen2visp(const Eigen::VectorXd &src, vpColVector &dst)
void eigen2visp(const Eigen::VectorXd &src, VISP_NAMESPACE_ADDRESSING vpColVector &dst)
{
dst.resize(static_cast<unsigned int>(src.rows()));
#if (VP_VERSION_INT(EIGEN_WORLD_VERSION, EIGEN_MAJOR_VERSION, EIGEN_MINOR_VERSION) < 0x030300)
Expand All @@ -70,7 +70,7 @@ void eigen2visp(const Eigen::VectorXd &src, vpColVector &dst)
}
}

void eigen2visp(const Eigen::RowVectorXd &src, vpRowVector &dst)
void eigen2visp(const Eigen::RowVectorXd &src, VISP_NAMESPACE_ADDRESSING vpRowVector &dst)
{
dst.resize(static_cast<unsigned int>(src.cols()));
#if (VP_VERSION_INT(EIGEN_WORLD_VERSION, EIGEN_MAJOR_VERSION, EIGEN_MINOR_VERSION) < 0x030300)
Expand All @@ -84,9 +84,9 @@ void eigen2visp(const Eigen::RowVectorXd &src, vpRowVector &dst)
}
}

void visp2eigen(const vpColVector &src, Eigen::VectorXd &dst) { dst = Eigen::VectorXd::Map(src.data, src.size()); }
void visp2eigen(const VISP_NAMESPACE_ADDRESSING vpColVector &src, Eigen::VectorXd &dst) { dst = Eigen::VectorXd::Map(src.data, src.size()); }

void visp2eigen(const vpRowVector &src, Eigen::RowVectorXd &dst)
void visp2eigen(const VISP_NAMESPACE_ADDRESSING vpRowVector &src, Eigen::RowVectorXd &dst)
{
dst = Eigen::RowVectorXd::Map(src.data, src.size());
}
Expand Down
30 changes: 15 additions & 15 deletions modules/core/src/tools/file/vpIoTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ using namespace buminiz;

#include <regex>

char VISP_NAMESPACE_ADDRESSING cnpy::BigEndianTest()
char visp::cnpy::BigEndianTest()
{
int x = 1;
return (((reinterpret_cast<char *>(&x))[0]) ? '<' : '>');
}

char VISP_NAMESPACE_ADDRESSING cnpy::map_type(const std::type_info &t)
char visp::cnpy::map_type(const std::type_info &t)
{
if (t == typeid(float)) { return 'f'; }
if (t == typeid(double)) { return 'f'; }
Expand All @@ -159,7 +159,7 @@ char VISP_NAMESPACE_ADDRESSING cnpy::map_type(const std::type_info &t)
else { return '?'; }
}

void VISP_NAMESPACE_ADDRESSING cnpy::parse_npy_header(unsigned char *buffer, size_t &word_size, std::vector<size_t> &shape, bool &fortran_order)
void visp::cnpy::parse_npy_header(unsigned char *buffer, size_t &word_size, std::vector<size_t> &shape, bool &fortran_order)
{
uint16_t header_len = *reinterpret_cast<uint16_t *>(buffer+8);
std::string header(reinterpret_cast<char *>(buffer+9), header_len);
Expand Down Expand Up @@ -194,7 +194,7 @@ void VISP_NAMESPACE_ADDRESSING cnpy::parse_npy_header(unsigned char *buffer, siz
word_size = atoi(str_ws.substr(0, loc2).c_str());
}

void VISP_NAMESPACE_ADDRESSING cnpy::parse_npy_header(FILE *fp, size_t &word_size, std::vector<size_t> &shape, bool &fortran_order)
void visp::cnpy::parse_npy_header(FILE *fp, size_t &word_size, std::vector<size_t> &shape, bool &fortran_order)
{
char buffer[256];
size_t res = fread(buffer, sizeof(char), 11, fp);
Expand Down Expand Up @@ -250,7 +250,7 @@ void VISP_NAMESPACE_ADDRESSING cnpy::parse_npy_header(FILE *fp, size_t &word_siz
word_size = atoi(str_ws.substr(0, loc2).c_str());
}

void VISP_NAMESPACE_ADDRESSING cnpy::parse_zip_footer(FILE *fp, uint16_t &nrecs, size_t &global_header_size, size_t &global_header_offset)
void visp::cnpy::parse_zip_footer(FILE *fp, uint16_t &nrecs, size_t &global_header_size, size_t &global_header_offset)
{
std::vector<char> footer(22);
fseek(fp, -22, SEEK_END);
Expand All @@ -274,22 +274,22 @@ void VISP_NAMESPACE_ADDRESSING cnpy::parse_zip_footer(FILE *fp, uint16_t &nrecs,
UNUSED(comment_len); assert(comment_len == 0);
}

VISP_NAMESPACE_ADDRESSING cnpy::NpyArray load_the_npy_file(FILE *fp)
visp::cnpy::NpyArray load_the_npy_file(FILE *fp)
{
std::vector<size_t> shape;
size_t word_size;
bool fortran_order;
VISP_NAMESPACE_ADDRESSING cnpy::parse_npy_header(fp, word_size, shape, fortran_order);
visp::cnpy::parse_npy_header(fp, word_size, shape, fortran_order);

VISP_NAMESPACE_ADDRESSING cnpy::NpyArray arr(shape, word_size, fortran_order);
visp::cnpy::NpyArray arr(shape, word_size, fortran_order);
size_t nread = fread(arr.data<char>(), 1, arr.num_bytes(), fp);
if (nread != arr.num_bytes()) {
throw std::runtime_error("load_the_npy_file: failed fread");
}
return arr;
}

VISP_NAMESPACE_ADDRESSING cnpy::NpyArray load_the_npz_array(FILE *fp, uint32_t compr_bytes, uint32_t uncompr_bytes)
visp::cnpy::NpyArray load_the_npz_array(FILE *fp, uint32_t compr_bytes, uint32_t uncompr_bytes)
{
std::vector<unsigned char> buffer_compr(compr_bytes);
std::vector<unsigned char> buffer_uncompr(uncompr_bytes);
Expand Down Expand Up @@ -321,9 +321,9 @@ VISP_NAMESPACE_ADDRESSING cnpy::NpyArray load_the_npz_array(FILE *fp, uint32_t c
std::vector<size_t> shape;
size_t word_size;
bool fortran_order;
VISP_NAMESPACE_ADDRESSING cnpy::parse_npy_header(&buffer_uncompr[0], word_size, shape, fortran_order);
visp::cnpy::parse_npy_header(&buffer_uncompr[0], word_size, shape, fortran_order);

VISP_NAMESPACE_ADDRESSING cnpy::NpyArray array(shape, word_size, fortran_order);
visp::cnpy::NpyArray array(shape, word_size, fortran_order);

size_t offset = uncompr_bytes - array.num_bytes();
memcpy(array.data<unsigned char>(), &buffer_uncompr[0]+offset, array.num_bytes());
Expand All @@ -339,15 +339,15 @@ VISP_NAMESPACE_ADDRESSING cnpy::NpyArray load_the_npz_array(FILE *fp, uint32_t c
\warning This function has only been tested on little endian platform.
\note Original library: <a href="https://github.com/rogersce/cnpy">cnpy</a> with MIT license.
*/
VISP_NAMESPACE_ADDRESSING cnpy::npz_t VISP_NAMESPACE_ADDRESSING cnpy::npz_load(std::string fname)
visp::cnpy::npz_t visp::cnpy::npz_load(std::string fname)
{
FILE *fp = fopen(fname.c_str(), "rb");

if (!fp) {
throw std::runtime_error("npz_load: Error! Unable to open file "+fname+"!");
}

VISP_NAMESPACE_ADDRESSING cnpy::npz_t arrays;
visp::cnpy::npz_t arrays;
bool quit = false;
while (!quit) {
std::vector<char> local_header(30);
Expand Down Expand Up @@ -404,7 +404,7 @@ VISP_NAMESPACE_ADDRESSING cnpy::npz_t VISP_NAMESPACE_ADDRESSING cnpy::npz_load(s
\warning This function has only been tested on little endian platform.
\note Original library: <a href="https://github.com/rogersce/cnpy">cnpy</a> with MIT license.
*/
VISP_NAMESPACE_ADDRESSING cnpy::NpyArray VISP_NAMESPACE_ADDRESSING cnpy::npz_load(std::string fname, std::string varname)
visp::cnpy::NpyArray visp::cnpy::npz_load(std::string fname, std::string varname)
{
FILE *fp = fopen(fname.c_str(), "rb");

Expand Down Expand Up @@ -469,7 +469,7 @@ VISP_NAMESPACE_ADDRESSING cnpy::NpyArray VISP_NAMESPACE_ADDRESSING cnpy::npz_loa
\warning This function has only been tested on little endian platform.
\note Original library: <a href="https://github.com/rogersce/cnpy">cnpy</a> with MIT license.
*/
VISP_NAMESPACE_ADDRESSING cnpy::NpyArray VISP_NAMESPACE_ADDRESSING cnpy::npy_load(std::string fname)
visp::cnpy::NpyArray visp::cnpy::npy_load(std::string fname)
{

FILE *fp = fopen(fname.c_str(), "rb");
Expand Down
20 changes: 10 additions & 10 deletions modules/imgproc/include/visp3/imgproc/vpContours.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ struct vpDirection
{
vpDirection direction;
int directionSize = static_cast<int>(LAST_DIRECTION);
int idx = vpMath::modulo(static_cast<int>(m_direction) - 1, directionSize);
int idx = VISP_NAMESPACE_ADDRESSING vpMath::modulo(static_cast<int>(m_direction) - 1, directionSize);
direction.m_direction = vpDirectionType(idx);

return direction;
Expand All @@ -172,17 +172,17 @@ struct vpDirection
* @param point Current point coordinate.
* @return Next point coordinate along the contour.
*/
vpImagePoint active(const vpImage<int> &I, const vpImagePoint &point)
VISP_NAMESPACE_ADDRESSING vpImagePoint active(const VISP_NAMESPACE_ADDRESSING vpImage<int> &I, const VISP_NAMESPACE_ADDRESSING vpImagePoint &point)
{
int yy = static_cast<int>(point.get_i() + m_diry[static_cast<int>(m_direction)]);
int xx = static_cast<int>(point.get_j() + m_dirx[static_cast<int>(m_direction)]);

if ((xx < 0) || (xx >= static_cast<int>(I.getWidth())) || (yy < 0) || (yy >= static_cast<int>(I.getHeight()))) {
return vpImagePoint(-1, -1);
return VISP_NAMESPACE_ADDRESSING vpImagePoint(-1, -1);
}

int pixel = I[yy][xx];
return pixel != 0 ? vpImagePoint(yy, xx) : vpImagePoint(-1, -1);
return pixel != 0 ? VISP_NAMESPACE_ADDRESSING vpImagePoint(yy, xx) : VISP_NAMESPACE_ADDRESSING vpImagePoint(-1, -1);
}
};

Expand Down Expand Up @@ -218,7 +218,7 @@ struct vpContour
//! Parent contour
vpContour *m_parent;
//! Vector of points belonging to the contour
std::vector<vpImagePoint> m_points;
std::vector<VISP_NAMESPACE_ADDRESSING vpImagePoint> m_points;

/*!
* Default constructor.
Expand Down Expand Up @@ -319,7 +319,7 @@ struct vpContour
* \param contours : Detected contours.
* \param grayValue : Drawing grayscale color.
*/
VISP_EXPORT void drawContours(vpImage<unsigned char> &I, const std::vector<std::vector<vpImagePoint> > &contours,
VISP_EXPORT void drawContours(VISP_NAMESPACE_ADDRESSING vpImage<unsigned char> &I, const std::vector<std::vector<VISP_NAMESPACE_ADDRESSING vpImagePoint> > &contours,
unsigned char grayValue = 255);

/*!
Expand All @@ -331,8 +331,8 @@ VISP_EXPORT void drawContours(vpImage<unsigned char> &I, const std::vector<std::
* \param contours : Detected contours.
* \param color : Drawing color.
*/
VISP_EXPORT void drawContours(vpImage<vpRGBa> &I, const std::vector<std::vector<vpImagePoint> > &contours,
const vpColor &color);
VISP_EXPORT void drawContours(VISP_NAMESPACE_ADDRESSING vpImage<VISP_NAMESPACE_ADDRESSING vpRGBa> &I, const std::vector<std::vector<VISP_NAMESPACE_ADDRESSING vpImagePoint> > &contours,
const VISP_NAMESPACE_ADDRESSING vpColor &color);

/*!
* \ingroup group_imgproc_contours
Expand All @@ -345,8 +345,8 @@ VISP_EXPORT void drawContours(vpImage<vpRGBa> &I, const std::vector<std::vector<
* \param contourPts : List of contours, each contour contains a list of contour points.
* \param retrievalMode : Contour retrieval mode.
*/
VISP_EXPORT void findContours(const vpImage<unsigned char> &I_original, vpContour &contours,
std::vector<std::vector<vpImagePoint> > &contourPts,
VISP_EXPORT void findContours(const VISP_NAMESPACE_ADDRESSING vpImage<unsigned char> &I_original, vpContour &contours,
std::vector<std::vector<VISP_NAMESPACE_ADDRESSING vpImagePoint> > &contourPts,
const vpContourRetrievalType &retrievalMode = CONTOUR_RETR_TREE);

} // namespace
Expand Down
Loading

0 comments on commit 1a8469e

Please sign in to comment.