Skip to content

Commit

Permalink
Fix warnings detected on windows with msvc17
Browse files Browse the repository at this point in the history
  • Loading branch information
fspindle committed Sep 30, 2024
1 parent c07c9d1 commit 4c27c7c
Show file tree
Hide file tree
Showing 18 changed files with 109 additions and 108 deletions.
1 change: 1 addition & 0 deletions 3rdparty/apriltag/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ if(MSVC)
vp_set_source_file_compile_flag(tag25h9.c /wd4996)
vp_set_source_file_compile_flag(tag36h10.c /wd4996)
vp_set_source_file_compile_flag(tag36h11.c /wd4996)
vp_set_source_file_compile_flag(tagCircle21h7.c /wd4996)
# disable optimization
foreach(f ${tag_srcs})
vp_set_source_file_compile_flag(${f} /O0)
Expand Down
12 changes: 6 additions & 6 deletions example/device/framegrabber/readRealSenseData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
#endif
#endif

#ifdef VISP_HAVE_MINIZ
#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX)
#define GETOPTARGS "ci:e:jbzodh"
#else
#define GETOPTARGS "ci:e:jbodh"
Expand All @@ -94,7 +94,7 @@ void usage(const char *name, const char *badparam)
<< " [-c]"
<< " [-j]"
<< " [-b]"
#ifdef VISP_HAVE_MINIZ
#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX)
<< " [-z]"
#endif
<< " [-o]"
Expand All @@ -117,7 +117,7 @@ void usage(const char *name, const char *badparam)
<< " -b" << std::endl
<< " Depth and Pointcloud streams are saved in binary format." << std::endl
<< std::endl
#ifdef VISP_HAVE_MINIZ
#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX)
<< " -z" << std::endl
<< " Pointcloud stream is saved in NPZ format." << std::endl
<< std::endl
Expand Down Expand Up @@ -161,7 +161,7 @@ bool getOptions(int argc, const char *argv[], std::string &input_directory, std:
case 'b':
force_binary_format = true;
break;
#ifdef VISP_HAVE_MINIZ
#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX)
case 'z':
read_npz = true;
break;
Expand Down Expand Up @@ -252,7 +252,7 @@ bool readData(int cpt, const std::string &input_directory, const std::string &pa
}
}
}
#ifdef VISP_HAVE_MINIZ
#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX)
else {
visp::cnpy::npz_t npz_data = visp::cnpy::npz_load(filename_depth);

Expand Down Expand Up @@ -312,7 +312,7 @@ bool readData(int cpt, const std::string &input_directory, const std::string &pa
}
}
}
#ifdef VISP_HAVE_MINIZ
#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX)
else if (read_npz) {
visp::cnpy::npz_t npz_data = visp::cnpy::npz_load(filename_pointcloud);

Expand Down
14 changes: 7 additions & 7 deletions example/device/framegrabber/saveRealSenseData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
#define USE_REALSENSE2
#endif

#ifdef VISP_HAVE_MINIZ
#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX)
#define GETOPTARGS "se:o:acdpzijCf:bvh"
#else
#define GETOPTARGS "se:o:acdpijCf:bvh"
Expand All @@ -97,7 +97,7 @@ void usage(const char *name, const char *badparam, int fps)
<< " [-d]"
<< " [-p]"
<< " [-b]"
#ifdef VISP_HAVE_MINIZ
#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX)
<< " [-z]"
#endif
<< " [-i]"
Expand Down Expand Up @@ -133,7 +133,7 @@ void usage(const char *name, const char *badparam, int fps)
<< " -b" << std::endl
<< " Force depth and pointcloud to be saved in (little-endian) binary format." << std::endl
<< std::endl
#ifdef VISP_HAVE_MINIZ
#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX)
<< " -z" << std::endl
<< " Pointcloud is saved in NPZ format." << std::endl
<< std::endl
Expand Down Expand Up @@ -220,7 +220,7 @@ bool getOptions(int argc, const char *argv[], bool &save, std::string &pattern,
case 'v':
depth_hist_visu = true;
break;
#ifdef VISP_HAVE_MINIZ
#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX)
case 'z':
save_pcl_npz_format = true;
break;
Expand Down Expand Up @@ -481,7 +481,7 @@ class vpStorageWorker
}
}
}
#ifdef VISP_HAVE_MINIZ
#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX)
else {
ss << m_directory << "/depth_image_" << m_save_pattern << ".npz";
snprintf(buffer, FILENAME_MAX, ss.str().c_str(), m_cpt);
Expand Down Expand Up @@ -575,7 +575,7 @@ class vpStorageWorker
}
}
else if (m_save_pcl_npz_format) {
#ifdef VISP_HAVE_MINIZ
#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX)
// Write Npz headers
std::vector<char> vec_filename(filename_point_cloud.begin(), filename_point_cloud.end());
// Null-terminated character is handled at reading
Expand Down Expand Up @@ -708,7 +708,7 @@ int main(int argc, const char *argv[])
std::cout << "save_jpeg: " << save_jpeg << std::endl;
std::cout << "stream_fps: " << stream_fps << std::endl;
std::cout << "depth_hist_visu: " << depth_hist_visu << std::endl;
#ifdef VISP_HAVE_MINIZ
#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX)
std::cout << "save_pcl_npz_format: " << save_pcl_npz_format << std::endl;
#endif
std::cout << "save_force_binary_format: " << save_force_binary_format << std::endl;
Expand Down
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 @@ -77,7 +77,7 @@ static inline unsigned long vp_mz_crc32(unsigned long crc, const unsigned char *
}
#endif // DOXYGEN_SHOULD_SKIP_THIS

#ifdef VISP_HAVE_MINIZ
#if defined(VISP_HAVE_MINIZ) && defined(VISP_HAVE_WORKING_REGEX)
namespace cnpy
{
// Copyright (C) 2011 Carl Rogers
Expand Down
2 changes: 1 addition & 1 deletion modules/core/include/visp3/core/vpParticleFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ vpParticleFilter<MeasurementsType>::vpParticleFilter(const unsigned int &N, cons
vpUniRand seedGenerator(seedForGenerator);
for (unsigned int threadId = 0; threadId < m_nbMaxThreads; ++threadId) {
for (unsigned int stateId = 0; stateId < sizeState; ++stateId) {
m_noiseGenerators[threadId].push_back(vpGaussRand(stdev[stateId], 0., seedGenerator.uniform(0., 1e9)));
m_noiseGenerators[threadId].push_back(vpGaussRand(stdev[stateId], 0., static_cast<long>(seedGenerator.uniform(0., 1e9))));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/tools/network/vpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

// Specific case for UWP to introduce a workaround
// error C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
#if defined(WINRT)
#if defined(WINRT) || defined(_WIN32)
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/tools/network/vpNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

// Specific case for UWP to introduce a workaround
// error C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
#if defined(WINRT)
#if defined(WINRT) || defined(_WIN32)
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/tools/network/vpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

// Specific case for UWP to introduce a workaround
// error C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
#if defined(WINRT)
#if defined(WINRT) || defined(_WIN32)
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
Expand Down
38 changes: 19 additions & 19 deletions modules/core/test/math/testParticleFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ class vpParabolaModel
public:
inline vpParabolaModel(const unsigned int &degree, const unsigned int &height, const unsigned int &width)
: m_degree(degree)
, m_height(static_cast<double>(height))
, m_width(static_cast<double>(width))
, m_height(height)
, m_width(width)
, m_coeffs(degree + 1, 0.)
{ }

Expand All @@ -88,8 +88,8 @@ class vpParabolaModel
*/
inline vpParabolaModel(const vpColVector &coeffs, const unsigned int &height, const unsigned int &width)
: m_degree(coeffs.size() - 1)
, m_height(static_cast<double>(height))
, m_width(static_cast<double>(width))
, m_height(height)
, m_width(width)
, m_coeffs(coeffs)
{ }

Expand All @@ -103,8 +103,8 @@ class vpParabolaModel
*/
inline vpParabolaModel(const vpMatrix &coeffs, const unsigned int &height, const unsigned int &width)
: m_degree(coeffs.getRows() - 1)
, m_height(static_cast<double>(height))
, m_width(static_cast<double>(width))
, m_height(height)
, m_width(width)
, m_coeffs(coeffs.getCol(0))
{ }

Expand Down Expand Up @@ -163,9 +163,9 @@ class vpParabolaModel
* \param[out] b The matrix that contains the v-coordinates.
* \return Fill
*/
static void fillSystem(const unsigned int &degree, const double &height, const double &width, const std::vector< vpImagePoint> &pts, vpMatrix &A, vpMatrix &b)
static void fillSystem(const unsigned int &degree, const unsigned int &height, const unsigned int&width, const std::vector< vpImagePoint> &pts, vpMatrix &A, vpMatrix &b)
{
const unsigned int nbPts = pts.size();
const unsigned int nbPts = static_cast<unsigned int>(pts.size());
const unsigned int nbCoeffs = degree + 1;
std::vector<vpImagePoint> normalizedPts;
for (const auto &pt: pts) {
Expand Down Expand Up @@ -197,7 +197,7 @@ class vpParabolaModel
{
unsigned int width = I.getWidth();
for (unsigned int u = 0; u < width; ++u) {
int v = eval(u);
int v = static_cast<int>(eval(u));
vpDisplay::displayPoint(I, v, u, color, 1);
vpDisplay::displayText(I, vertPosLegend, horPosLegend, legend, color);
}
Expand All @@ -206,8 +206,8 @@ class vpParabolaModel

private:
unsigned int m_degree; /*!< The highest degree of the polynomial.*/
double m_height; /*!< The height of the input image*/
double m_width; /*!< The width of the input image*/
unsigned int m_height; /*!< The height of the input image*/
unsigned int m_width; /*!< The width of the input image*/
vpColVector m_coeffs; /*!< The coefficient of the polynomial, where m_coeffs[0] is the offset and m_coeffs[m_degree] is the coefficient applied to the highest degree.*/
};

Expand Down Expand Up @@ -292,7 +292,7 @@ template<typename T>
void displayGeneratedImage(const vpImage<T> &I, const std::vector<vpImagePoint> &pts, const vpColor &color,
const std::string &legend, const unsigned int &vertOffset, const unsigned int &horOffset)
{
unsigned int nbPts = pts.size();
unsigned int nbPts = static_cast<unsigned int>(pts.size());
for (unsigned int i = 1; i < nbPts; ++i) {
vpDisplay::displayPoint(I, pts[i], color, 1);
}
Expand All @@ -309,7 +309,7 @@ void displayGeneratedImage(const vpImage<T> &I, const std::vector<vpImagePoint>
* \param[in] width The maximum x-coordinate.
* \return vpParabolaModel The fitter model.
*/
vpParabolaModel computeInitialGuess(const std::vector<vpImagePoint> &pts, const unsigned int &degree, const double &height, const double &width)
vpParabolaModel computeInitialGuess(const std::vector<vpImagePoint> &pts, const unsigned int &degree, const unsigned int&height, const unsigned int &width)
{
vpMatrix A; // The matrix that contains the u^2, u and 1s
vpMatrix X; // The matrix we want to estimate, that contains the a, b and c coefficients.
Expand Down Expand Up @@ -370,7 +370,7 @@ class vpAverageFunctor

vpColVector averagePolynomials(const std::vector<vpColVector> &particles, const std::vector<double> &weights, const vpParticleFilter<std::vector<vpImagePoint>>::vpStateAddFunction &/**/)
{
const unsigned int nbParticles = particles.size();
const unsigned int nbParticles = static_cast<unsigned int>(particles.size());
const double nbParticlesAsDOuble = static_cast<double>(nbParticles);
const double sumWeight = std::accumulate(weights.begin(), weights.end(), 0.);
const double nbPointsForAverage = 10. * nbParticlesAsDOuble;
Expand Down Expand Up @@ -442,7 +442,7 @@ class vpLikelihoodFunctor
double likelihood(const vpColVector &coeffs, const std::vector<vpImagePoint> &meas)
{
double likelihood = 0.;
unsigned int nbPoints = meas.size();
unsigned int nbPoints = static_cast<unsigned int>(meas.size());
vpParabolaModel model(coeffs, m_height, m_width);
vpColVector residuals(nbPoints);
double rmse = evaluate(meas, model);
Expand All @@ -463,8 +463,8 @@ class vpLikelihoodFunctor
TEST_CASE("2nd-degree", "[vpParticleFilter][Polynomial interpolation]")
{
/// ----- Simulation parameters -----
const double width = 600.; //!< The width of the simulated image
const double height = 400.; //!< The height of the simulated image
const unsigned int width = 600; //!< The width of the simulated image
const unsigned int height = 400; //!< The height of the simulated image
const unsigned int degree = 2; //!< The degree of the polynomial in the simulated image
const unsigned int nbInitPoints = 10; //!< Number of points to compute the initial guess of the PF state
const uint64_t seedCurve = 4224; //!< The seed to generate the curve
Expand Down Expand Up @@ -648,8 +648,8 @@ TEST_CASE("2nd-degree", "[vpParticleFilter][Polynomial interpolation]")
TEST_CASE("3rd-degree", "[vpParticleFilter][Polynomial interpolation]")
{
/// ----- Simulation parameters -----
const double width = 600.; //!< The width of the simulated image
const double height = 400.; //!< The height of the simulated image
const unsigned int width = 600; //!< The width of the simulated image
const unsigned int height = 400; //!< The height of the simulated image
const unsigned int degree = 3; //!< The degree of the polynomial in the simulated image
const unsigned int nbInitPoints = 10; //!< Number of points to compute the initial guess of the PF state
const uint64_t seedCurve = 4224; //!< The seed to generate the curve
Expand Down
Loading

0 comments on commit 4c27c7c

Please sign in to comment.