Skip to content

Commit

Permalink
Fix warnings detected on cdash ci like conversion de 'size_t' en 'uns…
Browse files Browse the repository at this point in the history
…igned int', perte possible de données

Fix various typos
  • Loading branch information
fspindle committed Jul 3, 2024
1 parent a19b3c5 commit 40e6bf9
Show file tree
Hide file tree
Showing 14 changed files with 107 additions and 105 deletions.
2 changes: 1 addition & 1 deletion doc/tutorial/detection_dnn/tutorial-detection-tensorrt.dox
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ Include TensorRT header files.
\subsection preprocessing Pre-processing
Prepare input image for inference with OpenCV.
First, upload image to GPU, resize it to match model's input dimensions, normalize with `meanR` `meanG` `meanB` being
the values used for mean substraction.
the values used for mean subtraction.
Transform data to tensor (copy data to channel by channel to `gpu_input`).
In the case of `ssd_mobilenet.onnx`, the input dimension is 1x3x300x300.
\snippet tutorial-dnn-tensorrt-live.cpp Preprocess image
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorial/imgproc/tutorial-imgproc-count-coins.dox
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The fill holes algorithm is basic:

\image html img-tutorial-count-coins-mask.png "Left: binary image, right: result of the flood fill operation"

- substract the flood fill image from a white image to get only the holes
- subtract the flood fill image from a white image to get only the holes

\image html img-tutorial-count-coins-white-holes.png "Top left: white image, bottom left: flood fill image, right: I_holes = I_white - I_flood_fill"

Expand Down
8 changes: 4 additions & 4 deletions doc/tutorial/misc/tutorial-ukf.dox
Original file line number Diff line number Diff line change
Expand Up @@ -357,17 +357,17 @@ Finally, we create the UKF and initialize its state:

\snippet tutorial-ukf.cpp Init_UKF

If the internal state cannot use the standard addition and substraction, it would be necessary to write other methods:
If the internal state cannot use the standard addition and subtraction, it would be necessary to write other methods:
- a method permitting to add two state vectors (see vpUnscentedKalman::setStateAddFunction),
- a method permitting to substract two state vectors (see vpUnscentedKalman::setStateResidualFunction),
- a method permitting to subtract two state vectors (see vpUnscentedKalman::setStateResidualFunction),
- and a method permitting to compute the mean of several state vectors (see vpUnscentedKalman::setStateMeanFunction).

If some commands are known to have an effect on the internal state, it would be necessary to write other methods:
- a method for the effects of the commands on the state, without knowing the state (see vpUnscentedKalman::setCommandOnlyFunction),
- and/or a method for the effects of the commands on the state, knowing the state (see vpUnscentedKalman::setCommandStateFunction).

If the measurement space cannot use the standard addition and substraction, it would be necessary to write other methods:
- a method permitting to substract two measurement vectors (see vpUnscentedKalman::setMeasurementResidualFunction),
If the measurement space cannot use the standard addition and subtraction, it would be necessary to write other methods:
- a method permitting to subtract two measurement vectors (see vpUnscentedKalman::setMeasurementResidualFunction),
- and a method permitting to compute the mean of several measurement vectors (see vpUnscentedKalman::setMeasurementMeanFunction).

\subsubsection tuto-ukf-tutorial-explained-initgui Details on the initialization of the Graphical User Interface
Expand Down
43 changes: 22 additions & 21 deletions example/kalman/ukf-nonlinear-complex-example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/

/** \example ukf-nonlinear-complex-example.cpp
/**
* \example ukf-nonlinear-complex-example.cpp
* Example of a complex non-linear use-case of the Unscented Kalman Filter (UKF).
* The system we are interested in is a 4-wheel robot, moving at a low velocity.
* As such, it can be modeled using a bicycle model.
Expand Down Expand Up @@ -118,7 +119,7 @@ double normalizeAngle(const double &angle)
*/
vpColVector measurementMean(const std::vector<vpColVector> &measurements, const std::vector<double> &wm)
{
const unsigned int nbPoints = measurements.size();
const unsigned int nbPoints = static_cast<unsigned int>(measurements.size());
const unsigned int sizeMeasurement = measurements[0].size();
const unsigned int nbLandmarks = sizeMeasurement / 2;
vpColVector mean(sizeMeasurement, 0.);
Expand All @@ -138,16 +139,16 @@ vpColVector measurementMean(const std::vector<vpColVector> &measurements, const
}

/**
* \brief Compute the substraction between two vectors expressed in the measurement space,
* \brief Compute the subtraction between two vectors expressed in the measurement space,
* such as v[0] = dist_0 ; v[1] = bearing_0; v[2] = dist_1 ; v[3] = bearing_1 ...
*
* \param[in] meas Measurement to which we must substract something.
* \param[in] toSubstract The something we must substract.
* \return vpColVector \b meas - \b toSubstract .
* \param[in] meas Measurement to which we must subtract something.
* \param[in] toSubtract The something we must subtract.
* \return vpColVector \b meas - \b toSubtract .
*/
vpColVector measurementResidual(const vpColVector &meas, const vpColVector &toSubstract)
vpColVector measurementResidual(const vpColVector &meas, const vpColVector &toSubtract)
{
vpColVector res = meas - toSubstract;
vpColVector res = meas - toSubtract;
unsigned int nbMeasures = res.size();
for (unsigned int i = 1; i < nbMeasures; i += 2) {
res[i] = normalizeAngle(res[i]);
Expand Down Expand Up @@ -180,7 +181,7 @@ vpColVector stateAdd(const vpColVector &state, const vpColVector &toAdd)
vpColVector stateMean(const std::vector<vpColVector> &states, const std::vector<double> &wm)
{
vpColVector mean(3, 0.);
unsigned int nbPoints = states.size();
unsigned int nbPoints = static_cast<unsigned int>(states.size());
double sumCos = 0.;
double sumSin = 0.;
for (unsigned int i = 0; i < nbPoints; ++i) {
Expand All @@ -194,16 +195,16 @@ vpColVector stateMean(const std::vector<vpColVector> &states, const std::vector<
}

/**
* \brief Compute the substraction between two vectors expressed in the state space,
* \brief Compute the subtraction between two vectors expressed in the state space,
* such as v[0] = x ; v[1] = y; v[2] = heading .
*
* \param[in] state State to which we must substract something.
* \param[in] toSubstract The something we must substract.
* \return vpColVector \b state - \b toSubstract .
* \param[in] state State to which we must subtract something.
* \param[in] toSubtract The something we must subtract.
* \return vpColVector \b state - \b toSubtract .
*/
vpColVector stateResidual(const vpColVector &state, const vpColVector &toSubstract)
vpColVector stateResidual(const vpColVector &state, const vpColVector &toSubtract)
{
vpColVector res = state - toSubstract;
vpColVector res = state - toSubtract;
res[2] = normalizeAngle(res[2]);
return res;
}
Expand Down Expand Up @@ -474,7 +475,7 @@ class vpLandmarksGrid
*/
vpColVector state_to_measurement(const vpColVector &chi)
{
unsigned int nbLandmarks = m_landmarks.size();
unsigned int nbLandmarks = static_cast<unsigned int>(m_landmarks.size());
vpColVector measurements(2*nbLandmarks);
for (unsigned int i = 0; i < nbLandmarks; ++i) {
vpColVector landmarkMeas = m_landmarks[i].state_to_measurement(chi);
Expand All @@ -494,7 +495,7 @@ class vpLandmarksGrid
*/
vpColVector measureGT(const vpColVector &pos)
{
unsigned int nbLandmarks = m_landmarks.size();
unsigned int nbLandmarks = static_cast<unsigned int>(m_landmarks.size());
vpColVector measurements(2*nbLandmarks);
for (unsigned int i = 0; i < nbLandmarks; ++i) {
vpColVector landmarkMeas = m_landmarks[i].measureGT(pos);
Expand All @@ -514,7 +515,7 @@ class vpLandmarksGrid
*/
vpColVector measureWithNoise(const vpColVector &pos)
{
unsigned int nbLandmarks = m_landmarks.size();
unsigned int nbLandmarks = static_cast<unsigned int>(m_landmarks.size());
vpColVector measurements(2*nbLandmarks);
for (unsigned int i = 0; i < nbLandmarks; ++i) {
vpColVector landmarkMeas = m_landmarks[i].measureWithNoise(pos);
Expand Down Expand Up @@ -560,10 +561,10 @@ int main(const int argc, const char *argv[])
, vpLandmarkMeasurements(20, 5, sigmaRange, sigmaBearing)
, vpLandmarkMeasurements(0, 30, sigmaRange, sigmaBearing)
, vpLandmarkMeasurements(50, 30, sigmaRange, sigmaBearing)
, vpLandmarkMeasurements(40, 10, sigmaRange, sigmaBearing) }; // Vector of landmarks constituing the grid
const unsigned int nbLandmarks = landmarks.size(); // Number of landmarks constituing the grid
, vpLandmarkMeasurements(40, 10, sigmaRange, sigmaBearing) }; // Vector of landmarks constituting the grid
const unsigned int nbLandmarks = static_cast<unsigned int>(landmarks.size()); // Number of landmarks constituting the grid
std::vector<vpColVector> cmds = generateCommands();
const unsigned int nbCmds = cmds.size();
const unsigned int nbCmds = static_cast<unsigned int>(cmds.size());

// Initialize the attributes of the UKF
std::shared_ptr<vpUKSigmaDrawerAbstract> drawer = std::make_shared<vpUKSigmaDrawerMerwe>(3, 0.1, 2., 0, stateResidual, stateAdd);
Expand Down
16 changes: 8 additions & 8 deletions example/kalman/ukf-nonlinear-example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
where \f$ w_m^i \f$ is the weight associated to the \f$ i^{th} \f$ measurements for the weighted mean.
Additionnally, the addition and substraction of angles must be carefully done, as the result
Additionnally, the addition and subtraction of angles must be carefully done, as the result
must stay in the interval \f$[- \pi ; \pi ]\f$ or \f$[0 ; 2 \pi ]\f$ . We decided to use
the interval \f$[- \pi ; \pi ]\f$ .
*/
Expand Down Expand Up @@ -143,7 +143,7 @@ double normalizeAngle(const double &angle)
*/
vpColVector measurementMean(const std::vector<vpColVector> &measurements, const std::vector<double> &wm)
{
const unsigned int nbPoints = measurements.size();
const unsigned int nbPoints = static_cast<unsigned int>(measurements.size());
const unsigned int sizeMeasurement = measurements[0].size();
vpColVector mean(sizeMeasurement, 0.);
double sumCos(0.);
Expand All @@ -160,16 +160,16 @@ vpColVector measurementMean(const std::vector<vpColVector> &measurements, const
}

/**
* \brief Compute the substraction between two vectors expressed in the measurement space,
* \brief Compute the subtraction between two vectors expressed in the measurement space,
* such as v[0] = range ; v[1] = elevation_angle
*
* \param[in] meas Measurement to which we must substract something.
* \param[in] toSubstract The something we must substract.
* \return vpColVector \b meas - \b toSubstract .
* \param[in] meas Measurement to which we must subtract something.
* \param[in] toSubtract The something we must subtract.
* \return vpColVector \b meas - \b toSubtract .
*/
vpColVector measurementResidual(const vpColVector &meas, const vpColVector &toSubstract)
vpColVector measurementResidual(const vpColVector &meas, const vpColVector &toSubtract)
{
vpColVector res = meas - toSubstract;
vpColVector res = meas - toSubtract;
res[1] = normalizeAngle(res[1]);
return res;
}
Expand Down
36 changes: 18 additions & 18 deletions modules/core/include/visp3/core/vpUnscentedKalman.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,19 +175,19 @@ class VISP_EXPORT vpUnscentedKalman

/**
* \brief Function that computes either the equivalent of an addition or the equivalent
* of a substraction in the state space or in the measurement space.
* The first argument is the vector to which we must add/substract something
* and the second argument is the thing to be added/substracted. The return is the
* of a subtraction in the state space or in the measurement space.
* The first argument is the vector to which we must add/subtract something
* and the second argument is the thing to be added/subtracted. The return is the
* result of this operation.
*/
typedef std::function<vpColVector(const vpColVector &, const vpColVector &)> vpAddSubFunction;

/**
* \brief Residual function, which computes either the equivalent of the substraction in the
* state space or the equivalent of the substraction in the measurement space.
* The first argument is the vector to which we must substract something
* and the second argument is the thing to be substracted. The return is the
* result of this "substraction".
* \brief Residual function, which computes either the equivalent of the subtraction in the
* state space or the equivalent of the subtraction in the measurement space.
* The first argument is the vector to which we must subtract something
* and the second argument is the thing to be subtracted. The return is the
* result of this "subtraction".
*/
typedef std::function<vpColVector(const vpColVector &, const vpColVector &)> vpAddFunction;

Expand Down Expand Up @@ -246,7 +246,7 @@ class VISP_EXPORT vpUnscentedKalman
}

/**
* \brief Set the measurement residual function to use when computing a substraction
* \brief Set the measurement residual function to use when computing a subtraction
* in the measurement space.
*
* \param measResFunc The residual function to use.
Expand Down Expand Up @@ -279,7 +279,7 @@ class VISP_EXPORT vpUnscentedKalman
}

/**
* \brief Set the state residual function to use when computing a substraction
* \brief Set the state residual function to use when computing a subtraction
* in the state space.
*
* \param stateResFunc The residual function to use.
Expand Down Expand Up @@ -393,15 +393,15 @@ class VISP_EXPORT vpUnscentedKalman
}

/**
* \brief Simple function to compute a residual, which just does \f$ \textbf{res} = \textbf{a} - \textbf{toSubstract} \f$
* \brief Simple function to compute a residual, which just does \f$ \textbf{res} = \textbf{a} - \textbf{toSubtract} \f$
*
* \param[in] a Vector to which we must substract something.
* \param[in] toSubstract The something we must substract to \b a .
* \return vpColVector \f$ \textbf{res} = \textbf{a} - \textbf{toSubstract} \f$
* \param[in] a Vector to which we must subtract something.
* \param[in] toSubtract The something we must subtract to \b a .
* \return vpColVector \f$ \textbf{res} = \textbf{a} - \textbf{toSubtract} \f$
*/
inline static vpColVector simpleResidual(const vpColVector &a, const vpColVector &toSubstract)
inline static vpColVector simpleResidual(const vpColVector &a, const vpColVector &toSubtract)
{
vpColVector res = a - toSubstract;
vpColVector res = a - toSubtract;
return res;
}

Expand Down Expand Up @@ -448,10 +448,10 @@ class VISP_EXPORT vpUnscentedKalman
vpCommandOnlyFunction m_b; /*!< Function that permits to compute the effect of the commands on the prior, without knowledge of the state.*/
vpCommandStateFunction m_bx; /*!< Function that permits to compute the effect of the commands on the prior, with knowledge of the state.*/
vpMeanFunction m_measMeanFunc; /*!< Function to compute a weighted mean in the measurement space.*/
vpAddSubFunction m_measResFunc; /*!< Function to compute a substraction in the measurement space.*/
vpAddSubFunction m_measResFunc; /*!< Function to compute a subtraction in the measurement space.*/
vpAddSubFunction m_stateAddFunction; /*!< Function to compute an addition in the state space.*/
vpMeanFunction m_stateMeanFunc; /*!< Function to compute a weighted mean in the state space.*/
vpAddSubFunction m_stateResFunc; /*!< Function to compute a substraction in the state space.*/
vpAddSubFunction m_stateResFunc; /*!< Function to compute a subtraction in the state space.*/

/**
* \brief Structure that stores the results of the unscented transform.
Expand Down
16 changes: 8 additions & 8 deletions modules/core/src/math/matrix/vpColVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,16 @@ vpColVector::vpColVector(const vpMatrix &M) : vpArray2D<double>(M.getRows(), 1)

vpColVector::vpColVector(const std::vector<double> &v) : vpArray2D<double>(static_cast<unsigned int>(v.size()), 1)
{
size_t v_size = v.size();
for (size_t i = 0; i < v_size; ++i) {
unsigned int v_size = static_cast<unsigned int>(v.size());
for (unsigned int i = 0; i < v_size; ++i) {
(*this)[i] = v[i];
}
}

vpColVector::vpColVector(const std::vector<float> &v) : vpArray2D<double>(static_cast<unsigned int>(v.size()), 1)
{
size_t v_size = v.size();
for (size_t i = 0; i < v_size; ++i) {
unsigned int v_size = static_cast<unsigned int>(v.size());
for (unsigned int i = 0; i < v_size; ++i) {
(*this)[i] = static_cast<double>(v[i]);
}
}
Expand Down Expand Up @@ -350,19 +350,19 @@ vpColVector &vpColVector::operator=(const vpMatrix &M)

vpColVector &vpColVector::operator=(const std::vector<double> &v)
{
size_t v_size = v.size();
unsigned int v_size = static_cast<unsigned int>(v.size());

Check warning on line 353 in modules/core/src/math/matrix/vpColVector.cpp

View check run for this annotation

Codecov / codecov/patch

modules/core/src/math/matrix/vpColVector.cpp#L353

Added line #L353 was not covered by tests
resize(v_size, false);
for (size_t i = 0; i < v_size; ++i) {
for (unsigned int i = 0; i < v_size; ++i) {
(*this)[i] = v[i];
}
return *this;
}

vpColVector &vpColVector::operator=(const std::vector<float> &v)
{
size_t v_size = v.size();
unsigned int v_size = static_cast<unsigned int>(v.size());

Check warning on line 363 in modules/core/src/math/matrix/vpColVector.cpp

View check run for this annotation

Codecov / codecov/patch

modules/core/src/math/matrix/vpColVector.cpp#L363

Added line #L363 was not covered by tests
resize(v_size, false);
for (size_t i = 0; i < v_size; ++i) {
for (unsigned int i = 0; i < v_size; ++i) {
(*this)[i] = static_cast<float>(v[i]);
}
return *this;
Expand Down
17 changes: 9 additions & 8 deletions modules/core/src/math/matrix/vpRowVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ vpRowVector &vpRowVector::operator=(const vpMatrix &M)
*/
vpRowVector &vpRowVector::operator=(const std::vector<double> &v)
{
size_t v_size = v.size();
unsigned int v_size = static_cast<unsigned int>(v.size());

Check warning on line 101 in modules/core/src/math/matrix/vpRowVector.cpp

View check run for this annotation

Codecov / codecov/patch

modules/core/src/math/matrix/vpRowVector.cpp#L101

Added line #L101 was not covered by tests
resize(v_size);
for (size_t i = 0; i < v_size; ++i) {
for (unsigned int i = 0; i < v_size; ++i) {
(*this)[i] = v[i];
}
return *this;
Expand All @@ -110,9 +110,9 @@ vpRowVector &vpRowVector::operator=(const std::vector<double> &v)
*/
vpRowVector &vpRowVector::operator=(const std::vector<float> &v)
{
size_t v_size = v.size();
unsigned int v_size = static_cast<unsigned int>(v.size());

Check warning on line 113 in modules/core/src/math/matrix/vpRowVector.cpp

View check run for this annotation

Codecov / codecov/patch

modules/core/src/math/matrix/vpRowVector.cpp#L113

Added line #L113 was not covered by tests
resize(v_size);
for (size_t i = 0; i < v_size; ++i) {
for (unsigned int i = 0; i < v_size; ++i) {
(*this)[i] = static_cast<float>(v[i]);
}
return *this;
Expand Down Expand Up @@ -579,18 +579,19 @@ vpRowVector::vpRowVector(const vpMatrix &M) : vpArray2D<double>(1, M.getCols())
*/
vpRowVector::vpRowVector(const std::vector<double> &v) : vpArray2D<double>(1, static_cast<unsigned int>(v.size()))
{
size_t v_size = v.size();
for (size_t j = 0; j < v_size; ++j) {
unsigned int v_size = static_cast<unsigned int>(v.size());
for (unsigned int j = 0; j < v_size; ++j) {
(*this)[j] = v[j];
}
}

/*!
Constructor that creates a row vector from a std vector of float.
*/
vpRowVector::vpRowVector(const std::vector<float> &v) : vpArray2D<double>(1, static_cast<unsigned int>(v.size()))
{
size_t v_size = v.size();
for (size_t j = 0; j < v_size; ++j) {
unsigned int v_size = static_cast<unsigned int>(v.size());
for (unsigned int j = 0; j < v_size; ++j) {
(*this)[j] = static_cast<double>(v[j]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/tools/geometry/vpPolygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ void vpPolygon::updateBoundingBox()

std::set<double> setI;
std::set<double> setJ;
unsigned int v_corners_size = _corners.size();
unsigned int v_corners_size = static_cast<unsigned int>(_corners.size());
for (unsigned int i = 0; i < v_corners_size; ++i) {
setI.insert(_corners[i].get_i());
setJ.insert(_corners[i].get_j());
Expand Down
Loading

0 comments on commit 40e6bf9

Please sign in to comment.