Skip to content

Commit

Permalink
Merge pull request #1446 from fspindle/fix_warnings
Browse files Browse the repository at this point in the history
Fix warnings
  • Loading branch information
fspindle authored Jul 23, 2024
2 parents 7be927f + 3e0e2d3 commit 1ae3d96
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 41 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/macos-ustk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ jobs:
run: |
export LDFLAGS="-L/usr/local/opt/openblas/lib"
export CPPFLAGS="-I/usr/local/opt/openblas/include"
export Qt5_DIR="$(brew --prefix qt5)/lib/cmake/Qt5"
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/tmp/usr/local -DVISP_CONTRIB_MODULES_PATH=${HOME}/ustk/modules -DQt5_DIR=$(brew --prefix qt5)/lib/cmake/Qt5
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/tmp/usr/local -DVISP_CONTRIB_MODULES_PATH=${HOME}/ustk/modules
cat ViSP-third-party.txt
- name: Compile
Expand Down
3 changes: 3 additions & 0 deletions cmake/PCLTools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries)
mark_as_advanced(HDF5_C_LIBRARY_crypto)
mark_as_advanced(HDF5_C_LIBRARY_curl)
mark_as_advanced(HDF5_C_LIBRARY_pthread)
mark_as_advanced(HDF5_DIR)

mark_as_advanced(ICU_INCLUDE_DIR) # Requested on macOS with pcl 1.12.1

Expand All @@ -339,6 +340,7 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries)
mark_as_advanced(Qt6OpenGL_DIR Qt6WidgetsTools_DIR Qt6Widgets_DIR)
mark_as_advanced(Qt6DBusTools_DIR Qt6DBus_DIR Qt6Network_DIR Qt6QmlCompilerPlusPrivate_DIR)
mark_as_advanced(Qt6QmlIntegration_DIR Qt6QmlModels_DIR Qt6QmlTools_DIR Qt6Qml_DIR Qt6Quick_DIR Qt6Sql_DIR)
mark_as_advanced(Qt6QmlBuiltins_DIR Qt6QuickTools_DIR)
mark_as_advanced(Qt6_DIR)
mark_as_advanced(QT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH)
mark_as_advanced(QT_ADDITIONAL_PACKAGES_PREFIX_PATH)
Expand Down Expand Up @@ -381,6 +383,7 @@ macro(vp_find_pcl pcl_libraries pcl_deps_include_dirs pcl_deps_libraries)
mark_as_advanced(VTK_DIR) # Requested on macOS with pcl 1.12.1

mark_as_advanced(TBB_DIR)
mark_as_advanced(Tiff_DIR)

mark_as_advanced(synchronization_LOCATION) # Requested for pcl 1.13.1 on windows
mark_as_advanced($<$<CONFIG:debug:bcrypt_LOCATION) # Requested for pcl 1.13.1 on windows
Expand Down
3 changes: 2 additions & 1 deletion example/device/framegrabber/readRealSenseData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ bool readData(int cpt, const std::string &input_directory, const std::string &pa
assert(arr_depth_data.shape.size() == 3); // H x W x C
assert(arr_depth_data.shape[2] == 1); // Single channel

unsigned int height = arr_depth_data.shape[0], width = arr_depth_data.shape[1];
unsigned int height = static_cast<unsigned int>(arr_depth_data.shape[0]);
unsigned int width = static_cast<unsigned int>(arr_depth_data.shape[1]);
const bool copyData = true;
I_depth_raw = vpImage<uint16_t>(depth_data_ptr, height, width, copyData);
}
Expand Down
8 changes: 4 additions & 4 deletions example/particle-filter/pf-nonlinear-example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class vpMarkersMeasurements
*/
double likelihoodParticle(const vpColVector &x, const vpColVector &meas)
{
unsigned int nbMarkers = m_markers.size();
unsigned int nbMarkers = static_cast<unsigned int>(m_markers.size());
double likelihood = 0.;
vpHomogeneousMatrix wMo;
vpTranslationVector wTo(x[0], x[1], x[2]);
Expand Down Expand Up @@ -224,7 +224,7 @@ class vpMarkersMeasurements
*/
vpColVector state_to_measurement(const vpColVector &x)
{
unsigned int nbMarkers = m_markers.size();
unsigned int nbMarkers = static_cast<unsigned int>(m_markers.size());
vpColVector meas(2*nbMarkers);
vpHomogeneousMatrix wMo;
vpTranslationVector wTo(x[0], x[1], x[2]);
Expand All @@ -249,7 +249,7 @@ class vpMarkersMeasurements
*/
vpColVector measureGT(const vpColVector &wX)
{
unsigned int nbMarkers = m_markers.size();
unsigned int nbMarkers = static_cast<unsigned int>(m_markers.size());
vpColVector meas(2*nbMarkers);
vpHomogeneousMatrix wMo;
vpTranslationVector wTo(wX[0], wX[1], wX[2]);
Expand Down Expand Up @@ -526,7 +526,7 @@ int main(const int argc, const char *argv[])
, vpColVector({0.05, 0.05, 0., 1.})
, vpColVector({0.05, -0.05, 0., 1.})
, vpColVector({-0.05, -0.05, 0., 1.}) }; // Vector of the markers sticked on the object
const unsigned int nbMarkers = markers.size();
const unsigned int nbMarkers = static_cast<const unsigned int>(markers.size());
std::vector<vpPoint> markersAsVpPoint;
for (unsigned int i = 0; i < nbMarkers; ++i) {
vpColVector marker = markers[i];
Expand Down
6 changes: 3 additions & 3 deletions modules/core/include/visp3/core/vpParticleFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,14 +406,14 @@ vpParticleFilter<MeasurementsType>::vpParticleFilter(const unsigned int &N, cons
}
#endif
// Generating the random generators
unsigned int sizeState = stdev.size();
unsigned int sizeState = static_cast<unsigned int>(stdev.size());
m_noiseGenerators.resize(m_nbMaxThreads);
unsigned long long seedForGenerator;
if (seed > 0) {
seedForGenerator = seed;
}
else {
seedForGenerator = vpTime::measureTimeMicros();
seedForGenerator = static_cast<unsigned long long>(vpTime::measureTimeMicros());
}

// Sampler for the simpleImportanceResampling method
Expand Down Expand Up @@ -543,7 +543,7 @@ bool vpParticleFilter<MeasurementsType>::simpleResamplingCheck(const unsigned in
template <typename MeasurementsType>
typename vpParticleFilter<MeasurementsType>::vpParticlesWithWeights vpParticleFilter<MeasurementsType>::simpleImportanceResampling(const std::vector<vpColVector> &particles, const std::vector<double> &weights)
{
unsigned int nbParticles = particles.size();
unsigned int nbParticles = static_cast<unsigned int>(particles.size());
double x = 0.;
double sumWeights = 0.;
std::vector<int> idx(nbParticles);
Expand Down
16 changes: 8 additions & 8 deletions modules/core/test/image-with-dataset/testColorConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1387,12 +1387,12 @@ TEST_CASE("RGB to HSV conversion", "[image_conversion]")
vpImageConvert::RGBToHSV(reinterpret_cast<unsigned char *>(&rgb_truth_continuous.front()),
reinterpret_cast<unsigned char *>(&hue.front()),
reinterpret_cast<unsigned char *>(&saturation.front()),
reinterpret_cast<unsigned char *>(&value.front()), size, h_full);
reinterpret_cast<unsigned char *>(&value.front()), static_cast<unsigned int>(size), h_full);
CHECK(test_hsv(hue, saturation, value, rgb_truth, hsv_truth, 3, size, 1.));

std::cout << "Test hsv (unsigned char) -> rgb conversion with h full scale: " << (h_full ? "yes" : "no") << std::endl;
std::vector< unsigned char> rgb_continuous(rgb_truth_continuous.size() * 3);
vpImageConvert::HSVToRGB(&hue.front(), &saturation.front(), &value.front(), &rgb_continuous.front(), size, h_full);
vpImageConvert::HSVToRGB(&hue.front(), &saturation.front(), &value.front(), &rgb_continuous.front(), static_cast<unsigned int>(size), h_full);
CHECK(test_rgb(rgb_continuous, rgb_truth, hsv_truth, 3, size, 5.));
}
SECTION("RGBa -> HSV (unsigned char) -> RGBa")
Expand All @@ -1404,12 +1404,12 @@ TEST_CASE("RGB to HSV conversion", "[image_conversion]")
vpImageConvert::RGBaToHSV(reinterpret_cast<unsigned char *>(&rgba_truth_continuous.front()),
reinterpret_cast<unsigned char *>(&hue.front()),
reinterpret_cast<unsigned char *>(&saturation.front()),
reinterpret_cast<unsigned char *>(&value.front()), size, h_full);
reinterpret_cast<unsigned char *>(&value.front()), static_cast<unsigned int>(size), h_full);
CHECK(test_hsv(hue, saturation, value, rgb_truth, hsv_truth, 4, size, 1.));

std::cout << "Test hsv (unsigned char) -> rgba conversion with h full scale: " << (h_full ? "yes" : "no") << std::endl;
std::vector< unsigned char> rgba_continuous(rgb_truth_continuous.size() * 4);
vpImageConvert::HSVToRGBa(&hue.front(), &saturation.front(), &value.front(), &rgba_continuous.front(), size, h_full);
vpImageConvert::HSVToRGBa(&hue.front(), &saturation.front(), &value.front(), &rgba_continuous.front(), static_cast<unsigned int>(size), h_full);
CHECK(test_rgb(rgba_continuous, rgb_truth, hsv_truth, 4, size, 5.));
}
if (h_full) {
Expand All @@ -1422,12 +1422,12 @@ TEST_CASE("RGB to HSV conversion", "[image_conversion]")
vpImageConvert::RGBToHSV(reinterpret_cast<unsigned char *>(&rgb_truth_continuous.front()),
reinterpret_cast<double *>(&hue.front()),
reinterpret_cast<double *>(&saturation.front()),
reinterpret_cast<double *>(&value.front()), size);
reinterpret_cast<double *>(&value.front()), static_cast<unsigned int>(size));
CHECK(test_hsv(hue, saturation, value, rgb_truth, hsv_truth, 3, size, 255.));

std::cout << "Test hsv (double) -> rgb conversion" << std::endl;
std::vector< unsigned char> rgb_continuous(rgb_truth_continuous.size());
vpImageConvert::HSVToRGB(&hue.front(), &saturation.front(), &value.front(), &rgb_continuous.front(), size);
vpImageConvert::HSVToRGB(&hue.front(), &saturation.front(), &value.front(), &rgb_continuous.front(), static_cast<unsigned int>(size));
CHECK(test_rgb(rgb_continuous, rgb_truth, hsv_truth, 3, size));
}
}
Expand All @@ -1442,12 +1442,12 @@ TEST_CASE("RGB to HSV conversion", "[image_conversion]")
vpImageConvert::RGBaToHSV(reinterpret_cast<unsigned char *>(&rgba_truth_continuous.front()),
reinterpret_cast<double *>(&hue.front()),
reinterpret_cast<double *>(&saturation.front()),
reinterpret_cast<double *>(&value.front()), size);
reinterpret_cast<double *>(&value.front()), static_cast<unsigned int>(size));
CHECK(test_hsv(hue, saturation, value, rgb_truth, hsv_truth, 4, size, 255.));

std::cout << "Test hsv (double) -> rgba conversion" << std::endl;
std::vector< unsigned char> rgba_continuous(rgb_truth_continuous.size()*4);
vpImageConvert::HSVToRGBa(&hue.front(), &saturation.front(), &value.front(), &rgba_continuous.front(), size);
vpImageConvert::HSVToRGBa(&hue.front(), &saturation.front(), &value.front(), &rgba_continuous.front(), static_cast<unsigned int>(size));
CHECK(test_rgb(rgba_continuous, rgb_truth, hsv_truth, 4, size));
}
}
Expand Down
20 changes: 10 additions & 10 deletions modules/core/test/image-with-dataset/testConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,16 +509,16 @@ int main(int argc, const char **argv)
vpImageConvert::HSVToRGBa(&hue.front(), &saturation.front(), &value.front(), reinterpret_cast<unsigned char *>(Ic_from_hsv.bitmap), size);
for (unsigned int i = 0; i < Ic.getHeight(); i++) {
for (unsigned int j = 0; j < Ic.getWidth(); j++) {
int precision = 10.; // Due to cast to unsigned char
if ((!vpMath::equal(static_cast<unsigned>(Ic[i][j].R), static_cast<unsigned>(Ic_from_hsv[i][j].R), precision))
|| (!vpMath::equal(static_cast<unsigned>(Ic[i][j].G), static_cast<unsigned>(Ic_from_hsv[i][j].G), precision))
|| (!vpMath::equal(static_cast<unsigned>(Ic[i][j].B), static_cast<unsigned>(Ic_from_hsv[i][j].B), precision))) {
std::cerr << "Ic[i][j].R=" << static_cast<unsigned>(Ic[i][j].R)
<< " ; Ic_from_hsv[i][j].R=" << static_cast<unsigned>(Ic_from_hsv[i][j].R) << " precision: " << precision << std::endl;
std::cerr << "Ic[i][j].G=" << static_cast<unsigned>(Ic[i][j].G)
<< " ; Ic_from_hsv[i][j].G=" << static_cast<unsigned>(Ic_from_hsv[i][j].G) << " precision: " << precision << std::endl;
std::cerr << "Ic[i][j].B=" << static_cast<unsigned>(Ic[i][j].B)
<< " ; Ic_from_hsv[i][j].B=" << static_cast<unsigned>(Ic_from_hsv[i][j].B) << " precision: " << precision << std::endl;
double precision = 10.; // Due to cast to unsigned char
if ((!vpMath::equal(static_cast<double>(Ic[i][j].R), static_cast<double>(Ic_from_hsv[i][j].R), precision))
|| (!vpMath::equal(static_cast<double>(Ic[i][j].G), static_cast<double>(Ic_from_hsv[i][j].G), precision))
|| (!vpMath::equal(static_cast<double>(Ic[i][j].B), static_cast<double>(Ic_from_hsv[i][j].B), precision))) {
std::cerr << "Ic[i][j].R=" << static_cast<unsigned int>(Ic[i][j].R)
<< " ; Ic_from_hsv[i][j].R=" << static_cast<unsigned int>(Ic_from_hsv[i][j].R) << " precision: " << precision << std::endl;
std::cerr << "Ic[i][j].G=" << static_cast<unsigned int>(Ic[i][j].G)
<< " ; Ic_from_hsv[i][j].G=" << static_cast<unsigned int>(Ic_from_hsv[i][j].G) << " precision: " << precision << std::endl;
std::cerr << "Ic[i][j].B=" << static_cast<unsigned int>(Ic[i][j].B)
<< " ; Ic_from_hsv[i][j].B=" << static_cast<unsigned int>(Ic_from_hsv[i][j].B) << " precision: " << precision << std::endl;
throw vpException(vpException::fatalError, "Problem with conversion between RGB <==> HSV(unsigned char)");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,7 @@ class VISP_EXPORT vpDetectorAprilTag : public vpDetectorBase
m_displayTagThickness = thickness;
}

inline friend VISP_EXPORT void swap(vpDetectorAprilTag &o1, vpDetectorAprilTag &o2)
{
inline friend void swap(vpDetectorAprilTag& o1, vpDetectorAprilTag& o2) {
using std::swap;
swap(o1.m_impl, o2.m_impl);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/imgproc/src/vpCircleHoughTransform_circles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ vpCircleHoughTransform::computeCircleCandidates()
radiusActualValueList.clear();
radiusActualValueList.resize(nbBins, 0.);

const unsigned int nbEdgePoints = m_edgePointsList.size();
const unsigned int nbEdgePoints = static_cast<unsigned int>(m_edgePointsList.size());
for (unsigned int e = 0; e < nbEdgePoints; ++e) {
const std::pair<unsigned int, unsigned int> &edgePoint = m_edgePointsList[e];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ void vpLuminancePCA::save(const std::string &basisFilename, const std::string &m
vpLuminancePCA vpLuminancePCA::learn(const std::vector<vpImage<unsigned char>> &images, const unsigned int projectionSize, const unsigned int border)
{
vpMatrix matrix;
for (unsigned i = 0; i < images.size(); ++i) {
for (unsigned int i = 0; i < static_cast<unsigned int>(images.size()); ++i) {
const vpImage<unsigned char> &I = images[i];
if (i == 0) {
matrix.resize(images.size(), (I.getHeight() - 2 * border) * (I.getWidth() - 2 * border));
matrix.resize(static_cast<unsigned int>(images.size()), (I.getHeight() - 2 * border) * (I.getWidth() - 2 * border));
}
if ((I.getHeight() - 2 * border) * (I.getWidth() - 2 * border) != matrix.getCols()) {
throw vpException(vpException::badValue, "Not all images have the same dimensions when learning pca");
Expand All @@ -211,10 +211,10 @@ vpLuminancePCA vpLuminancePCA::learn(const std::vector<std::string> &imageFiles,
{
vpMatrix matrix;
vpImage<unsigned char> I;
for (unsigned i = 0; i < imageFiles.size(); ++i) {
for (unsigned int i = 0; i < static_cast<unsigned int>(imageFiles.size()); ++i) {
vpImageIo::read(I, imageFiles[i]);
if (i == 0) {
matrix.resize(imageFiles.size(), (I.getHeight() - 2 * border) * (I.getWidth() - 2 * border));
matrix.resize(static_cast<unsigned int>(imageFiles.size()), (I.getHeight() - 2 * border) * (I.getWidth() - 2 * border));
}
if ((I.getHeight() - 2 * border) * (I.getWidth() - 2 * border) != matrix.getCols()) {
throw vpException(vpException::badValue, "Not all images have the same dimensions when learning pca");
Expand Down
8 changes: 4 additions & 4 deletions tutorial/kalman/tutorial-ukf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class vpObjectSimulator
* \param[in] t The current time.
* \return vpColVector The new position of the object in the world frame, expressed as homogeneous coordinates.
*/
vpColVector move(const double &t)
vpColVector move(const double &t) const
{
vpColVector wX(4, 1.);
wX[0] = m_R * std::cos(m_w * t + m_phi);
Expand Down Expand Up @@ -157,7 +157,7 @@ class vpMarkersMeasurements
*/
vpColVector state_to_measurement(const vpColVector &x)
{
unsigned int nbMarkers = m_markers.size();
unsigned int nbMarkers = static_cast<unsigned int>(m_markers.size());
vpColVector meas(2*nbMarkers);
vpHomogeneousMatrix wMo;
vpTranslationVector wTo(x[0], x[1], x[2]);
Expand All @@ -183,7 +183,7 @@ class vpMarkersMeasurements
*/
vpColVector measureGT(const vpColVector &wX)
{
unsigned int nbMarkers = m_markers.size();
unsigned int nbMarkers = static_cast<unsigned int>(m_markers.size());
vpColVector meas(2*nbMarkers);
vpHomogeneousMatrix wMo;
vpTranslationVector wTo(wX[0], wX[1], wX[2]);
Expand Down Expand Up @@ -267,7 +267,7 @@ int main(/*const int argc, const char *argv[]*/)
, vpColVector({0.05, 0.05, 0., 1.})
, vpColVector({0.05, -0.05, 0., 1.})
, vpColVector({-0.05, -0.05, 0., 1.}) }; // Vector of the markers sticked on the object
const unsigned int nbMarkers = markers.size();
const unsigned int nbMarkers = static_cast<unsigned int>(markers.size());
std::vector<vpPoint> markersAsVpPoint;
for (unsigned int i = 0; i < nbMarkers; ++i) {
vpColVector marker = markers[i];
Expand Down
4 changes: 2 additions & 2 deletions tutorial/misc/npz/tutorial-npz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ int main()
if (it_img != npz_data.end()) {
visp::cnpy::NpyArray arr_data_img = it_img->second;
const bool copy_data = false;
vpImage<vpRGBa> img(arr_data_img.data<vpRGBa>(), arr_data_img.shape[0], arr_data_img.shape[1], copy_data);
vpImage<vpRGBa> img(arr_data_img.data<vpRGBa>(), static_cast<unsigned int>(arr_data_img.shape[0]), static_cast<unsigned int>(arr_data_img.shape[1]), copy_data);
std::cout << "Img: " << img.getWidth() << "x" << img.getHeight() << std::endl;

std::unique_ptr<vpDisplay> ptr_display;
Expand Down Expand Up @@ -190,7 +190,7 @@ int main()

if (it_img != npz_data.end()) {
visp::cnpy::NpyArray arr_data_img = it_img->second;
vpImage<vpRGBa> img(arr_data_img.shape[0], arr_data_img.shape[1]);
vpImage<vpRGBa> img(static_cast<unsigned int>(arr_data_img.shape[0]), static_cast<unsigned int>(arr_data_img.shape[1]));
vpImageConvert::RGBToRGBa(arr_data_img.data<unsigned char>(), reinterpret_cast<unsigned char *>(img.bitmap),
img.getSize());

Expand Down

0 comments on commit 1ae3d96

Please sign in to comment.