Skip to content

Commit

Permalink
Merge pull request #1427 from fspindle/fix_ci
Browse files Browse the repository at this point in the history
Fix warnings detected by CDash ci and improve Doxygen doc
  • Loading branch information
fspindle authored Jun 27, 2024
2 parents 1e7e8e6 + 2d8f856 commit a19b3c5
Show file tree
Hide file tree
Showing 44 changed files with 244 additions and 179 deletions.
3 changes: 2 additions & 1 deletion example/device/framegrabber/grabV4l2MultiCpp11Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ bool getOptions(int argc, char **argv, unsigned int &deviceCount, bool &saveVide
return true;
}

#ifndef DOXYGEN_SHOULD_SKIP_THIS
// Code adapted from the original author Dan Mašek to be compatible with ViSP
// image
class vpFrameQueue
Expand Down Expand Up @@ -204,7 +205,6 @@ class vpFrameQueue

class vpStorageWorker
{

public:
vpStorageWorker(vpFrameQueue &queue, const std::string &filename, unsigned int width, unsigned int height)
: m_queue(queue), m_filename(filename), m_width(width), m_height(height)
Expand Down Expand Up @@ -430,6 +430,7 @@ void display(unsigned int width, unsigned int height, int win_x, int win_y, unsi
}

} // Namespace
#endif // DOXYGEN_SHOULD_SKIP_THIS

int main(int argc, char *argv[])
{
Expand Down
16 changes: 10 additions & 6 deletions example/device/framegrabber/saveRealSenseData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ bool getOptions(int argc, const char *argv[], bool &save, std::string &pattern,
return true;
}

#ifndef DOXYGEN_SHOULD_SKIP_THIS

// Code adapted from: https://stackoverflow.com/a/37146523
class vpFrameQueue
{
Expand Down Expand Up @@ -575,7 +577,7 @@ class vpStorageWorker
}
else if (m_save_pcl_npz_format) {
#ifdef VISP_HAVE_MINIZ
// Write Npz headers
// Write Npz headers
std::vector<char> vec_filename(filename_point_cloud.begin(), filename_point_cloud.end());
// Null-terminated character is handled at reading
// For null-terminated character handling, see:
Expand Down Expand Up @@ -662,6 +664,8 @@ class vpStorageWorker
};
} // Namespace

#endif // DOXYGEN_SHOULD_SKIP_THIS

int main(int argc, const char *argv[])
{
bool save = false;
Expand Down Expand Up @@ -935,10 +939,10 @@ int main(int argc, const char *argv[])
#else
if (save_pointcloud) {
ptr_pointCloud = std::make_unique<std::vector<vpColVector>>(pointCloud);
}
}
save_queue.push(ptr_colorImg, ptr_depthImg, ptr_pointCloud, ptr_infraredImg);
#endif
}
}

double delta_time = vpTime::measureTimeMs() - start;
vec_delta_time.push_back(delta_time);
Expand Down Expand Up @@ -982,10 +986,10 @@ int main(int argc, const char *argv[])
#else
if (save_pointcloud) {
ptr_pointCloud = std::make_unique<std::vector<vpColVector>>(pointCloud);
}
}
save_queue.push(ptr_colorImg, ptr_depthImg, ptr_pointCloud, ptr_infraredImg);
#endif
}
}
break;

case vpMouseButton::button2:
Expand All @@ -995,9 +999,9 @@ int main(int argc, const char *argv[])
quit = true;
save_queue.cancel();
break;
}
}
}
}
}

double mean_vec_delta_time = vpMath::getMean(vec_delta_time);
Expand Down
70 changes: 31 additions & 39 deletions modules/core/include/visp3/core/vpGaussRand.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,51 +49,43 @@ BEGIN_VISP_NAMESPACE
their mean equal to 10 with a standard deviation equal to 0.5.
\code
#include <iostream>
#include <visp3/core/vpGaussRand.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
#include <iostream>
#include <visp3/core/vpGaussRand.h>
int main()
{
vpGaussRand noise(0.5, 10);
for(int i=0; i< 10; i++) {
std::cout << "noise " << i << ": " << noise() << std::endl;
int main()
{
vpGaussRand noise(0.5, 10);
for(int i=0; i< 10; i++) {
std::cout << "noise " << i << ": " << noise() << std::endl;
}
return 0;
}
return 0;
}
\endcode
The previous example produces the following printings:
\verbatim
noise 0: 10.645
noise 1: 9.67129
noise 2: 10.1208
noise 3: 10.1039
noise 4: 10.8667
noise 5: 9.89823
noise 6: 9.81414
noise 7: 9.96076
noise 8: 11.0795
noise 9: 9.79229
noise 0: 10.645
noise 1: 9.67129
noise 2: 10.1208
noise 3: 10.1039
noise 4: 10.8667
noise 5: 9.89823
noise 6: 9.81414
noise 7: 9.96076
noise 8: 11.0795
noise 9: 9.79229
\endverbatim
Note that the previous example produces always the same "random" results. To
produce real random values, you need to initialize the random generator with
different values using seed(). For example, this could be done using the
current time. The code becomes:
produce real random values, you need to initialize the random generator with
different values using seed(). For example, this could be done using the
current time. The code becomes:
\verbatim
#include <iostream>
#include <visp3/core/vpGaussRand.h>
#include <visp3/core/vpTime.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
vpGaussRand noise(0.5, 10);
Expand Down Expand Up @@ -123,15 +115,6 @@ current time. The code becomes:
*/
class VISP_EXPORT vpGaussRand
{
private:
double gaussianDraw();

vpUniRand m_rng;
double m_mean;
double m_sigma;
bool m_AlreadyDone;
double m_x2;

public:
/*!
Default noise generator constructor.
Expand Down Expand Up @@ -172,6 +155,15 @@ class VISP_EXPORT vpGaussRand
Return a random value from the Gaussian noise generator.
*/
double operator()() { return m_sigma * gaussianDraw() + m_mean; }

private:
double gaussianDraw();

vpUniRand m_rng;
double m_mean;
double m_sigma;
bool m_AlreadyDone;
double m_x2;
};
END_VISP_NAMESPACE
#endif
8 changes: 4 additions & 4 deletions modules/core/include/visp3/core/vpImageTools_warp.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ void vpImageTools::warpLinear(const vpImage<Type> &src, const vpMatrix &T, vpIma
const Type val11 = src[y_ + 1][x_ + 1];
const int64_t interp_i64 =
static_cast<int64_t>(((s_1 * t_1) * val00) + ((s * t_1) * val01) + ((s_1 * t) * val10) + ((s * t) * val11));
const float interp = (interp_i64 >> (nbits * 2)) + ((interp_i64 & 0xFFFFFFFF) * precision_2);
const float interp = (interp_i64 >> (nbits * 2)) + ((interp_i64 & 0xFFFFFFFFU) * precision_2);
dst[i][j] = vpMath::saturate<Type>(interp);
}
else if (y_ < (static_cast<int>(src.getHeight()) - 1)) {
Expand Down Expand Up @@ -498,15 +498,15 @@ inline void vpImageTools::warpLinearFixedPointNotCenter(const vpImage<vpRGBa> &s
const vpRGBa val11 = src[y_ + 1][x_ + 1];
const int64_t interpR_i64 =
static_cast<int64_t>((s_1 * t_1 * val00.R) + (s * t_1 * val01.R) + (s_1 * t * val10.R) + (s * t * val11.R));
const float interpR = (interpR_i64 >> (nbits * 2)) + ((interpR_i64 & 0xFFFFFFFF) * precision_2);
const float interpR = (interpR_i64 >> (nbits * 2)) + ((interpR_i64 & 0xFFFFFFFFU) * precision_2);

const int64_t interpG_i64 =
static_cast<int64_t>((s_1 * t_1 * val00.G) + (s * t_1 * val01.G) + (s_1 * t * val10.G) + (s * t * val11.G));
const float interpG = (interpG_i64 >> (nbits * 2)) + ((interpG_i64 & 0xFFFFFFFF) * precision_2);
const float interpG = (interpG_i64 >> (nbits * 2)) + ((interpG_i64 & 0xFFFFFFFFU) * precision_2);

const int64_t interpB_i64 =
static_cast<int64_t>((s_1 * t_1 * val00.B) + (s * t_1 * val01.B) + (s_1 * t * val10.B) + (s * t * val11.B));
const float interpB = (interpB_i64 >> (nbits * 2)) + ((interpB_i64 & 0xFFFFFFFF) * precision_2);
const float interpB = (interpB_i64 >> (nbits * 2)) + ((interpB_i64 & 0xFFFFFFFFU) * precision_2);

dst[i][j] = vpRGBa(vpMath::saturate<unsigned char>(interpR), vpMath::saturate<unsigned char>(interpG),
vpMath::saturate<unsigned char>(interpB), 255);
Expand Down
5 changes: 3 additions & 2 deletions modules/core/include/visp3/core/vpIoTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@
#include <complex>

#if VISP_CXX_STANDARD > VISP_CXX_STANDARD_98

namespace visp
{
#ifndef DOXYGEN_SHOULD_SKIP_THIS
// 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 All @@ -73,6 +75,7 @@ static inline unsigned long vp_mz_crc32(unsigned long crc, const unsigned char *
}
return ~crcu32;
}
#endif // DOXYGEN_SHOULD_SKIP_THIS

#ifdef VISP_HAVE_MINIZ
namespace cnpy
Expand Down Expand Up @@ -126,8 +129,6 @@ struct NpyArray

using npz_t = std::map<std::string, NpyArray>;
VISP_EXPORT npz_t npz_load(std::string fname);


VISP_EXPORT char BigEndianTest();
VISP_EXPORT char map_type(const std::type_info &t);
template<typename T> std::vector<char> create_npy_header(const std::vector<size_t> &shape);
Expand Down
1 change: 1 addition & 0 deletions modules/core/include/visp3/core/vpRGBf.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class VISP_EXPORT vpRGBf
float B; //!< Blue component.

friend VISP_EXPORT vpRGBf operator*(double x, const vpRGBf &rgb);
friend VISP_EXPORT vpRGBf operator*(float x, const vpRGBf &rgb);
};
END_VISP_NAMESPACE
#endif
4 changes: 2 additions & 2 deletions modules/core/include/visp3/core/vpUnscentedKalman.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,12 @@ class VISP_EXPORT vpUnscentedKalman
*/
inline static vpColVector simpleMean(const std::vector<vpColVector> &vals, const std::vector<double> &wm)
{
unsigned int nbPoints = vals.size();
size_t nbPoints = vals.size();
if (nbPoints == 0) {
throw(vpException(vpException::dimensionError, "No points to add when computing the mean"));
}
vpColVector mean = vals[0] * wm[0];
for (unsigned int i = 1; i < nbPoints; ++i) {
for (size_t i = 1; i < nbPoints; ++i) {
mean += vals[i] * wm[i];
}
return mean;
Expand Down
12 changes: 6 additions & 6 deletions modules/core/src/camera/vpCameraParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,8 @@ bool vpCameraParameters::operator==(const vpCameraParameters &c) const
return false;
}

unsigned int m_dist_coefs_size = m_dist_coefs.size();
for (unsigned int i = 0; i < m_dist_coefs_size; ++i) {
size_t m_dist_coefs_size = m_dist_coefs.size();
for (size_t i = 0; i < m_dist_coefs_size; ++i) {
if (!vpMath::equal(m_dist_coefs[i], c.m_dist_coefs[i], std::numeric_limits<double>::epsilon())) {
return false;
}
Expand Down Expand Up @@ -633,7 +633,7 @@ vpMatrix vpCameraParameters::get_K_inverse() const
*/
void vpCameraParameters::printParameters()
{
unsigned int m_dist_coefs_size = m_dist_coefs.size();
size_t m_dist_coefs_size = m_dist_coefs.size();
std::ios::fmtflags original_flags(std::cout.flags());
switch (m_projModel) {
case vpCameraParameters::perspectiveProjWithoutDistortion: {
Expand All @@ -654,7 +654,7 @@ void vpCameraParameters::printParameters()
}
case vpCameraParameters::ProjWithKannalaBrandtDistortion: {
std::cout << " Coefficients: ";
for (unsigned int i = 0; i < m_dist_coefs_size; ++i) {
for (size_t i = 0; i < m_dist_coefs_size; ++i) {
std::cout << " " << m_dist_coefs[i];
}
std::cout << std::endl;
Expand Down Expand Up @@ -700,8 +700,8 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpCameraParameters
os << " px = " << cam.get_px() << "\t py = " << cam.get_py() << std::endl << " u0 = " << cam.get_u0() << "\t v0 = " << cam.get_v0() << std::endl;
os << " Coefficients: ";
std::vector<double> tmp_coefs = cam.getKannalaBrandtDistortionCoefficients();
unsigned int tmp_coefs_size = tmp_coefs.size();
for (unsigned int i = 0; i < tmp_coefs_size; ++i) {
size_t tmp_coefs_size = tmp_coefs.size();
for (size_t i = 0; i < tmp_coefs_size; ++i) {
os << " " << tmp_coefs[i];
}
os << std::endl;
Expand Down
4 changes: 4 additions & 0 deletions modules/core/src/camera/vpColorDepthConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
#include <visp3/core/vpPixelMeterConversion.h>

BEGIN_VISP_NAMESPACE

#ifndef DOXYGEN_SHOULD_SKIP_THIS
namespace
{

Expand Down Expand Up @@ -134,6 +136,8 @@ vpColVector deproject(const vpCameraParameters &intrinsic_cam_params, const vpIm

} // namespace

#endif // DOXYGEN_SHOULD_SKIP_THIS

/*!
* Project color image point to depth frame.
*
Expand Down
9 changes: 4 additions & 5 deletions modules/core/src/image/vpRGBa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
*
* Description:
* RGBA pixel.
*
*****************************************************************************/
*/

/*!
\file vpRGBa.cpp
Expand Down Expand Up @@ -291,9 +290,9 @@ bool vpRGBa::operator>(const vpRGBa &v) const
vpRGBa operator*(const double &x, const vpRGBa &rgb)
{
vpRGBa rgba;
rgba.R = rgb.R * x;
rgba.G = rgb.G * x;
rgba.B = rgb.B * x;
rgba.R = static_cast<unsigned char>(rgb.R * x);
rgba.G = static_cast<unsigned char>(rgb.G * x);
rgba.B = static_cast<unsigned char>(rgb.B * x);
rgba.A = rgb.A;
return rgba;
}
Expand Down
25 changes: 20 additions & 5 deletions modules/core/src/image/vpRGBf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
*
* Description:
* 32-bit floating point RGB pixel.
*
*****************************************************************************/
*/

/*!
\file vpRGBf.cpp
Expand Down Expand Up @@ -64,9 +63,9 @@ vpRGBf &vpRGBf::operator=(float v)
*/
vpRGBf &vpRGBf::operator=(int v)
{
this->R = v;
this->G = v;
this->B = v;
this->R = static_cast<float>(v);
this->G = static_cast<float>(v);
this->B = static_cast<float>(v);
return *this;
}

Expand Down Expand Up @@ -273,6 +272,22 @@ bool vpRGBf::operator>(const vpRGBf &v) const
* @return Rescaled components with RGB * x.
*/
vpRGBf operator*(double x, const vpRGBf &rgb)
{
vpRGBf rgbf;
rgbf.R = static_cast<float>(rgb.R * x);
rgbf.G = static_cast<float>(rgb.G * x);
rgbf.B = static_cast<float>(rgb.B * x);
return rgbf;
}

/*!
* Scale RGB components by x.
*
* @param x : Value used to scale RGB color components.
* @param rgb : RGB color components to rescale.
* @return Rescaled components with RGB * x.
*/
vpRGBf operator*(float x, const vpRGBf &rgb)
{
vpRGBf rgbf;
rgbf.R = rgb.R * x;
Expand Down
Loading

0 comments on commit a19b3c5

Please sign in to comment.