Skip to content

Commit

Permalink
Fix quality adding "U" suffix to this constant, to make it explicitly…
Browse files Browse the repository at this point in the history
… "unsigned"

Doxygen doc indentation
  • Loading branch information
fspindle committed Jun 27, 2024
1 parent 542dba5 commit 2d8f856
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 47 deletions.
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
8 changes: 4 additions & 4 deletions modules/core/src/tools/endian/vpEndian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ uint32_t swap32bits(uint32_t val)
{
const unsigned int magic_8 = 8;
const unsigned int magic_24 = 24;
const unsigned int magic_0x000000FF = 0x000000FF;
const unsigned int magic_0x0000FF00 = 0x0000FF00;
const unsigned int magic_0x00FF0000 = 0x00FF0000;
const unsigned int magic_0xFF000000 = 0xFF000000;
const unsigned int magic_0x000000FF = 0x000000FFU;
const unsigned int magic_0x0000FF00 = 0x0000FF00U;
const unsigned int magic_0x00FF0000 = 0x00FF0000U;
const unsigned int magic_0xFF000000 = 0xFF000000U;
return (((val >> magic_24) & magic_0x000000FF) | ((val >> magic_8) & magic_0x0000FF00) | ((val << magic_8) & magic_0x00FF0000) |
((val << magic_24) & magic_0xFF000000));
}
Expand Down

0 comments on commit 2d8f856

Please sign in to comment.