Skip to content

Commit

Permalink
Merge pull request #1306 from fspindle/fix_msvc17_warnings
Browse files Browse the repository at this point in the history
Fix msvc17 warnings
  • Loading branch information
fspindle authored Jan 13, 2024
2 parents edcf9ce + 137454d commit fde6d41
Show file tree
Hide file tree
Showing 14 changed files with 148 additions and 129 deletions.
175 changes: 96 additions & 79 deletions 3rdparty/catch2/catch.hpp

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions doc/tutorial/tracking/tutorial-tracking-mb-generic-json.dox
Original file line number Diff line number Diff line change
Expand Up @@ -227,48 +227,48 @@ Let's now look at an example of how to use JSON to track an object.
This example is similar to tutorial-mb-generic-tracker-rgbd-realsense.cpp, where an XML configuration file is used to configure camera per camera.
Instead, here, we will use a JSON file to fully configure the tracker.

The full code can be found in tutorial-mb-generic-tracker-rgbd-realsense-json-settings.cpp
The full code can be found in tutorial-mb-generic-tracker-rgbd-realsense-json.cpp

To run the example:
\code{.sh}
// If no CAD model is defined in the JSON file
$ cd $VISP_WS/visp-build/tutorial/tracking/model-based/generic-rgbd
$ ./tutorial-mb-generic-tracker-rgbd-realsense-json-settings \
$ ./tutorial-mb-generic-tracker-rgbd-realsense-json \
--config model/cube/realsense-color-and-depth.json \
--model model/cube/cube.cao

// If CAD model is defined in JSON
$ ./tutorial-mb-generic-tracker-rgbd-realsense-json-settings \
$ ./tutorial-mb-generic-tracker-rgbd-realsense-json \
--config model/cube/realsense-color-and-depth.json
\endcode

The main difference between tutorial-mb-generic-tracker-rgbd-realsense.cpp and
tutorial-mb-generic-tracker-rgbd-realsense-json-settings.cpp is that in the latter we specify which features
tutorial-mb-generic-tracker-rgbd-realsense-json.cpp is that in the latter we specify which features
to use in the JSON config file.

First, we initialize the camera (here, a vpRealsense2 camera) and query the camera intrinsics,
as well as declare the vpImage we will use to store the data feed and display it:
\snippet tutorial-mb-generic-tracker-rgbd-realsense-json-settings.cpp Init
\snippet tutorial-mb-generic-tracker-rgbd-realsense-json.cpp Init

To load the json configuration, we simply call:
\snippet tutorial-mb-generic-tracker-rgbd-realsense-json-settings.cpp Loading
\snippet tutorial-mb-generic-tracker-rgbd-realsense-json.cpp Loading

We then query what features are used by the tracker and update its input accordingly
\snippet tutorial-mb-generic-tracker-rgbd-realsense-json-settings.cpp Init maps
\snippet tutorial-mb-generic-tracker-rgbd-realsense-json.cpp Init maps

To finish with the configuration, we load the 3D CAD model if none was defined in the JSON file.
If none is given by the user, then an exception is thrown.
\snippet tutorial-mb-generic-tracker-rgbd-realsense-json-settings.cpp Load 3D model
\snippet tutorial-mb-generic-tracker-rgbd-realsense-json.cpp Load 3D model

To ensure the best performance, we might still prefer to use the camera intrinsics and transformation
between color and depth cameras provided by the Realsense SDK.
\snippet tutorial-mb-generic-tracker-rgbd-realsense-json-settings.cpp Update params
\snippet tutorial-mb-generic-tracker-rgbd-realsense-json.cpp Update params

We then initialize tracking by click:
\snippet tutorial-mb-generic-tracker-rgbd-realsense-json-settings.cpp Init tracking
\snippet tutorial-mb-generic-tracker-rgbd-realsense-json.cpp Init tracking

Finally, we can start tracking:
\snippet tutorial-mb-generic-tracker-rgbd-realsense-json-settings.cpp Tracking
\snippet tutorial-mb-generic-tracker-rgbd-realsense-json.cpp Tracking

\section json-settings-next Next tutorial

Expand Down
6 changes: 3 additions & 3 deletions modules/core/include/visp3/core/vpImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ class VISP_EXPORT vpImageFilter
const float &lowerThresholdRatio = 0.6, const float &upperThresholdRatio = 0.8,
const vpCannyFilteringAndGradientType &filteringType = CANNY_GBLUR_SOBEL_FILTERING)
{
double w = I.getWidth();
double h = I.getHeight();
unsigned int w = static_cast<unsigned int>(I.getWidth());
unsigned int h = static_cast<unsigned int>(I.getHeight());

vpImage<unsigned char> dI(h, w);
vpImage<OutType> dIx(h, w), dIy(h, w);
Expand Down Expand Up @@ -327,7 +327,7 @@ class VISP_EXPORT vpImageFilter
float t = (float)(upperThresholdRatio * w * h);
float bon = 0;
for (unsigned int i = 0; i < nbBins; ++i) {
float tf = hist[i];
float tf = static_cast<float>(hist[i]);
accu = accu + tf;
if (accu > t) {
bon = (float)i;
Expand Down
16 changes: 8 additions & 8 deletions modules/core/src/image/vpImageCircle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -910,16 +910,16 @@ float vpImageCircle::computeAngularCoverageInRoI(const vpRect &roi, const float
{
float delta_theta = 0.f;
vpImagePoint center = m_center;
float u_c = center.get_u();
float v_c = center.get_v();
float u_c = static_cast<float>(center.get_u());
float v_c = static_cast<float>(center.get_v());
float radius = m_radius;
float roi_w = roi.getWidth();
float roi_h = roi.getHeight();
float roi_w = static_cast<float>(roi.getWidth());
float roi_h = static_cast<float>(roi.getHeight());
vpImagePoint topLeft = roi.getTopLeft();
float umin_roi = topLeft.get_u();
float vmin_roi = topLeft.get_v();
float umax_roi = topLeft.get_u() + roi_w;
float vmax_roi = topLeft.get_v() + roi_h;
float umin_roi = static_cast<float>(topLeft.get_u());
float vmin_roi = static_cast<float>(topLeft.get_v());
float umax_roi = umin_roi + roi_w;
float vmax_roi = vmin_roi + roi_h;
bool touchLeftBorder = (u_c - radius) <= umin_roi;
bool touchRightBorder = (u_c + radius) >= umax_roi;
bool touchTopBorder = (v_c - radius) <= vmin_roi;
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/image/vpImageFilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ void vpImageFilter::canny(const vpImage<unsigned char> &Isrc, vpImage<unsigned c
cannyFilteringSteps);
}
else if (lowerCannyThresh < 0.f) {
lowerCannyThresh = upperCannyThresh / 3.;
lowerCannyThresh = upperCannyThresh / 3.f;
}
vpCannyEdgeDetection edgeDetector(gaussianFilterSize, gaussianStdev, apertureGradient, lowerCannyThresh, upperCannyThresh,
lowerThresholdRatio, upperThresholdRatio, cannyFilteringSteps);
Expand Down
2 changes: 2 additions & 0 deletions modules/imgproc/include/visp3/imgproc/vpContours.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ struct vpDirection
*/
vpDirection()
{
m_direction = NORTH;

m_dirx[0] = 0;
m_dirx[1] = 1;
m_dirx[2] = 1;
Expand Down
6 changes: 3 additions & 3 deletions modules/imgproc/src/vpCircleHoughTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ vpCircleHoughTransform::computeCenterCandidates()
}
}

unsigned int nbPeaks = peak_positions_votes.size();
unsigned int nbPeaks = static_cast<unsigned int>(peak_positions_votes.size());
if (nbPeaks > 0) {
std::vector<bool> has_been_merged(nbPeaks, false);
std::vector<std::pair<std::pair<float, float>, float>> merged_peaks_position_votes;
Expand Down Expand Up @@ -672,7 +672,7 @@ vpCircleHoughTransform::computeCenterCandidates()

std::sort(merged_peaks_position_votes.begin(), merged_peaks_position_votes.end(), sortingCenters);

nbPeaks = merged_peaks_position_votes.size();
nbPeaks = static_cast<unsigned int>(merged_peaks_position_votes.size());
int nbPeaksToKeep = (m_algoParams.m_expectedNbCenters > 0 ? m_algoParams.m_expectedNbCenters : nbPeaks);
nbPeaksToKeep = std::min<int>(nbPeaksToKeep, (int)nbPeaks);
for (int i = 0; i < nbPeaksToKeep; i++) {
Expand Down Expand Up @@ -793,7 +793,7 @@ vpCircleHoughTransform::computeCircleCandidates()
}
}

unsigned int nbCandidates = v_r_effective.size();
unsigned int nbCandidates = static_cast<unsigned int>(v_r_effective.size());
for (unsigned int idBin = 0; idBin < nbCandidates; ++idBin) {
// If the circle of center CeC_i and radius RCB_k has enough votes, it is added to the list
// of Circle Candidates
Expand Down
14 changes: 7 additions & 7 deletions modules/robot/src/real-robot/pololu-maestro/vpRobotPololuPtu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ vpRobotPololuPtu::vpRobotPololuPtu(const std::string &device, int baudrate, bool
nDof = 2;
m_pan.connect(device, baudrate, 0);
m_pan.setPwmRange(4095, 7905);
m_pan.setAngularRange(vpMath::rad(-45), vpMath::rad(45));
m_pan.setAngularRange(static_cast<float>(vpMath::rad(-45)), static_cast<float>(vpMath::rad(45)));
m_pan.setVerbose(verbose);

m_tilt.connect(device, baudrate, 1);
m_tilt.setPwmRange(4095, 7905);
m_tilt.setAngularRange(vpMath::rad(-45), vpMath::rad(45));
m_tilt.setAngularRange(static_cast<float>(vpMath::rad(-45)), static_cast<float>(vpMath::rad(45)));
m_tilt.setVerbose(verbose);
}

Expand Down Expand Up @@ -151,9 +151,9 @@ void vpRobotPololuPtu::setPosition(const vpRobot::vpControlFrameType frame, cons
break;
}

float pos_vel = m_positioning_velocity_percentage * getMaxRotationVelocity();
m_pan.setAngularPosition(q[0], pos_vel);
m_tilt.setAngularPosition(q[1], pos_vel);
float pos_vel = m_positioning_velocity_percentage * static_cast<float>(getMaxRotationVelocity());
m_pan.setAngularPosition(static_cast<float>(q[0]), pos_vel);
m_tilt.setAngularPosition(static_cast<float>(q[1]), pos_vel);
}

void vpRobotPololuPtu::setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &q_dot)
Expand Down Expand Up @@ -227,8 +227,8 @@ void vpRobotPololuPtu::setVelocity(const vpRobot::vpControlFrameType frame, cons

std::cout << "Send velocity: " << q_dot_sat.t() << std::endl;

m_pan.setAngularVelocity(q_dot_sat[0]);
m_tilt.setAngularVelocity(q_dot_sat[1]);
m_pan.setAngularVelocity(static_cast<float>(q_dot_sat[0]));
m_tilt.setAngularVelocity(static_cast<float>(q_dot_sat[1]));
}

vpRobot::vpRobotStateType vpRobotPololuPtu::setRobotState(vpRobot::vpRobotStateType newState)
Expand Down
6 changes: 3 additions & 3 deletions modules/robot/test/servo-pololu/testPololuPosition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ int main(int argc, const char **argv)
bool opt_calibrate = false;
unsigned short opt_pwm_min = 4000;
unsigned short opt_pwm_max = 8000;
float opt_angle_min = vpMath::rad(-45);
float opt_angle_max = vpMath::rad(45);
float opt_positioning_velocity = vpMath::rad(10);
float opt_angle_min = static_cast<float>(vpMath::rad(-45));
float opt_angle_max = static_cast<float>(vpMath::rad(45));
float opt_positioning_velocity = static_cast<float>(vpMath::rad(10));
float last_angle = 0;
int time_s = 0;

Expand Down
6 changes: 3 additions & 3 deletions modules/robot/test/servo-pololu/testPololuVelocity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ int main(int argc, const char **argv)
bool opt_calibrate = false;
unsigned short opt_pwm_min = 4000;
unsigned short opt_pwm_max = 8000;
float opt_angle_min = vpMath::rad(-45);
float opt_angle_max = vpMath::rad(45);
float opt_velocity = vpMath::rad(5);
float opt_angle_min = static_cast<float>(vpMath::rad(-45));
float opt_angle_max = static_cast<float>(vpMath::rad(45));
float opt_velocity = static_cast<float>(vpMath::rad(5));
float last_angle = 0;

for (int i = 1; i < argc; i++) {
Expand Down
12 changes: 6 additions & 6 deletions tutorial/image/tutorial-canny.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void computeMeanMaxStdev(const vpImage<T> &I, float &mean, float &max, float &st
stdev = 0.;
unsigned int nbRows = I.getRows();
unsigned int nbCols = I.getCols();
float scale = 1. / ((float)nbRows * (float)nbCols);
float scale = 1.f / (static_cast<float>(nbRows) * static_cast<float>(nbCols));
for (unsigned int r = 0; r < nbRows; r++) {
for (unsigned int c = 0; c < nbCols; c++) {
mean += I[r][c];
Expand Down Expand Up @@ -178,12 +178,12 @@ int main(int argc, const char *argv[])
else if ((argv_str == "-g" || argv_str == "--gradient") && i + 2 < argc) {
opt_gradientOutsideClass = true;
opt_gaussianKernelSize = atoi(argv[i + 1]);
opt_gaussianStdev = atoi(argv[i + 2]);
opt_gaussianStdev = static_cast<float>(atof(argv[i + 2]));
i += 2;
}
else if ((argv_str == "-t" || argv_str == "--thresh") && i + 2 < argc) {
opt_lowerThresh = atof(argv[i + 1]);
opt_upperThresh = atof(argv[i + 2]);
opt_lowerThresh = static_cast<float>(atof(argv[i + 1]));
opt_upperThresh = static_cast<float>(atof(argv[i + 2]));
i += 2;
}
else if ((argv_str == "-a" || argv_str == "--aperture") && i + 1 < argc) {
Expand All @@ -195,8 +195,8 @@ int main(int argc, const char *argv[])
i++;
}
else if ((argv_str == "-r" || argv_str == "--ratio") && i + 2 < argc) {
opt_lowerThreshRatio = std::atof(argv[i + 1]);
opt_upperThreshRatio = std::atof(argv[i + 2]);
opt_lowerThreshRatio = static_cast<float>(std::atof(argv[i + 1]));
opt_upperThreshRatio = static_cast<float>(std::atof(argv[i + 2]));
i += 2;
}
else if ((argv_str == "-b" || argv_str == "--backend") && i + 1 < argc) {
Expand Down
6 changes: 3 additions & 3 deletions tutorial/imgproc/hough-transform/tutorial-circle-hough.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ int main(int argc, char **argv)
i++;
}
else if (argName == "--lower-canny-ratio" && i + 1 < argc) {
opt_lowerCannyThreshRatio = atof(argv[i + 1]);
opt_lowerCannyThreshRatio = static_cast<float>(atof(argv[i + 1]));
i++;
}
else if (argName == "--upper-canny-ratio" && i + 1 < argc) {
opt_upperCannyThreshRatio = atof(argv[i + 1]);
opt_upperCannyThreshRatio = static_cast<float>(atof(argv[i + 1]));
i++;
}
else if (argName == "--expected-nb-centers" && i + 1 < argc) {
Expand Down Expand Up @@ -247,7 +247,7 @@ int main(int argc, char **argv)
std::cout << "DESCRIPTION" << std::endl
<< "\t--input" << std::endl
<< "\t\tPermit to choose the input of the Hough Circle Algorithm." << std::endl
<< "\t\tIf you want to use a succession of images as video, their name must be in the format ${BASENAME}\%d.{jpg, png}." << std::endl
<< "\t\tIf you want to use a succession of images as video, their name must be in the format ${BASENAME}%d.{jpg, png}." << std::endl
<< "\t\tDefault: " << def_input << std::endl
<< std::endl
#ifdef VISP_HAVE_NLOHMANN_JSON
Expand Down
2 changes: 1 addition & 1 deletion tutorial/tracking/model-based/generic-rgbd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set(tutorial_cpp
tutorial-mb-generic-tracker-rgbd.cpp
tutorial-mb-generic-tracker-rgbd-realsense.cpp
tutorial-mb-generic-tracker-rgbd-structure-core.cpp
tutorial-mb-generic-tracker-rgbd-realsense-json-settings.cpp)
tutorial-mb-generic-tracker-rgbd-realsense-json.cpp)

foreach(cpp ${tutorial_cpp})
visp_add_target(${cpp})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! \example tutorial-mb-generic-tracker-rgbd-realsense-json-settings.cpp
//! \example tutorial-mb-generic-tracker-rgbd-realsense-json.cpp
#include <iostream>

#include <visp3/core/vpConfig.h>
Expand Down

0 comments on commit fde6d41

Please sign in to comment.