Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
7dc2126
Mute warning: assuming signed overflow does not occur when reducing c…
fspindle Jun 24, 2026
2339f39
Fix warning: assuming signed overflow does not occur when simplifying…
fspindle Jun 24, 2026
19479df
Fix warning: assuming signed overflow does not occur when changing X …
fspindle Jun 24, 2026
868c8e2
Fix warning: assuming signed overflow does not occur when changing X …
fspindle Jun 24, 2026
7a464ff
Fix warning: assuming pointer wraparound does not occur when comparin…
fspindle Jun 24, 2026
1a0f046
Mute warning: assuming signed overflow does not occur when changing X…
fspindle Jun 24, 2026
a571336
Fix warning: assuming signed overflow does not occur when changing X …
fspindle Jun 26, 2026
ead32ab
Fix warning: assuming signed overflow does not occur when changing X …
fspindle Jun 26, 2026
b6563d2
Fix warning: assuming signed overflow does not occur when changing X …
fspindle Jun 26, 2026
33c2c00
Fix warning: assuming signed overflow does not occur when changing X …
fspindle Jun 26, 2026
a7bd097
Fix warning: assuming signed overflow does not occur when reducing co…
fspindle Jun 26, 2026
887318c
Fix warning: assuming signed overflow does not occur when reducing co…
fspindle Jun 26, 2026
f8ee93b
Fix warning: assuming signed overflow does not occur when changing X …
fspindle Jun 26, 2026
f41cdd2
Fix warning: assuming signed overflow does not occur when reducing co…
fspindle Jun 26, 2026
aaf09ad
Fix warning: assuming signed overflow does not occur when changing X …
fspindle Jun 26, 2026
34e1e98
Fix warning: assuming signed overflow does not occur when changing X …
fspindle Jun 26, 2026
d24cafe
Fix warning: assuming signed overflow does not occur when simplifying…
fspindle Jun 26, 2026
6d3ae44
Fix warning: assuming signed overflow does not occur when changing X …
fspindle Jun 26, 2026
a8b8740
Fix warning: assuming signed overflow does not occur when changing X …
fspindle Jun 26, 2026
533137e
Fix warning: assuming signed overflow does not occur when reducing co…
fspindle Jun 26, 2026
c253c77
Fix warning: assuming signed overflow does not occur when reducing co…
fspindle Jun 26, 2026
310b8d0
Mute warning due to basisu_miniz.h: assuming signed overflow does not…
fspindle Jun 26, 2026
11ac745
Fix warning: assuming signed overflow does not occur when reducing co…
fspindle Jun 26, 2026
b2cec25
Fix warning: assuming signed overflow does not occur when changing X …
fspindle Jun 26, 2026
3a1adbd
Fix warning: assuming signed overflow does not occur when changing X …
fspindle Jun 26, 2026
56e1ddd
Fix warning: assuming pointer wraparound does not occur when comparin…
fspindle Jun 26, 2026
e27b877
Fix warning: assuming signed overflow does not occur when changing X …
fspindle Jun 26, 2026
e0f451f
Fix warning: assuming signed overflow does not occur when changing X …
fspindle Jun 26, 2026
eeab71f
Merge branch 'master' into fix_warning_strict_overflow
fspindle Jul 16, 2026
87d8626
Fix testFeatureMoment and integer type usage in vpFeatureMomentCentered
fspindle Jul 17, 2026
0f92667
Fix segmentation fault in vpPoseFeatures::clear() and improve test re…
fspindle Jul 17, 2026
313b3b4
Resolve -Wstrict-overflow warnings in PFM I/O
fspindle Jul 17, 2026
1d0cba6
[FIX] Fixed segfault that occured when using RBT's KLT features
rolalaro Jul 20, 2026
631746c
[FIX] Fixed memory leaked that appeared when fixing sign-related warn…
rolalaro Jul 20, 2026
d1944de
[CLEAN] Clean signed overflow warning in vpCircleHoughTransform::comp…
rolalaro Jul 21, 2026
1469ab4
[CLEAN] Fixed warning related to signed overflow comparison in vpCLAHE
rolalaro Jul 21, 2026
060edef
[CLEAN] Fixed warning related to signed overflow comparison in vpJson…
rolalaro Jul 21, 2026
554007c
[CLEAN] Fixed warning related to signed overflow comparison in vpFloo…
rolalaro Jul 21, 2026
fe1abfa
[CLEAN] Fixed warning related to signed overflow comparison in vpThre…
rolalaro Jul 21, 2026
f5ed3c2
[CLEAN] Fixed warning related to signed overflow comparison in vpLeve…
rolalaro Jul 21, 2026
e656b23
[CLEAN] Fixed warning related to signed overflow comparison in vpLeve…
rolalaro Jul 21, 2026
75518cb
[FIX] Fixed a typo in vpFeatureLuminanceMapping.cpp
rolalaro Jul 21, 2026
266ba06
[FIX] Fixed deletion of KLT features in vpRBKltTracker
rolalaro Jul 21, 2026
09fd7eb
[CLEAN] Fixed warning related to implicit cast into/from int into/fro…
rolalaro Jul 22, 2026
cc6c6d7
[CLEAN] Fixed signed overflow warnings in apps
rolalaro Jul 22, 2026
e9cff06
Merge remote-tracking branch 'origin/master' into fix_warning_strict_…
rolalaro Jul 22, 2026
4335f00
[CLEAN] Fixed signed overflow warnings in tutorial
rolalaro Jul 22, 2026
208d360
[CLEAN] Fixed warning conversion to ‘unsigned int’ from ‘int’ may cha…
rolalaro Jul 22, 2026
b7252ba
Fix warning: assuming signed overflow does not occur when reducing co…
fspindle Jul 22, 2026
d916504
Fix warning: assuming signed overflow does not occur when changing X …
fspindle Jul 23, 2026
90f86c0
Mute warning: assuming signed overflow does not occur when changing X…
fspindle Jul 23, 2026
4477d8c
Turn ACTIVATE_WARNING_STRICT_OVERFLOW ON in Ubuntu GHA
fspindle Jul 23, 2026
c1e6ab9
Introduce new catch2 test for vpParseArgv class
fspindle Jul 28, 2026
db4ade3
[CLEAN] Fixed warning assuming signed overflow does not occur when si…
rolalaro Aug 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/ubuntu-dep-apt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ jobs:
-DUSE_CXX_STANDARD=$CXX_STANDARD \
-DACTIVATE_WARNING_SHADOW=ON \
-DACTIVATE_WARNING_FLOAT_EQUAL=ON \
-DACTIVATE_WARNING_SIGN_CONVERSION=ON
-DACTIVATE_WARNING_SIGN_CONVERSION=ON \
-DACTIVATE_WARNING_STRICT_OVERFLOW=ON
cat ViSP-third-party.txt

- name: Compile
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ubuntu-dep-src.yml
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ jobs:
cmake .. -DCMAKE_INSTALL_PREFIX=$(pwd)/install \
-DACTIVATE_WARNING_SHADOW=ON \
-DACTIVATE_WARNING_FLOAT_EQUAL=ON \
-DACTIVATE_WARNING_SIGN_CONVERSION=ON
-DACTIVATE_WARNING_SIGN_CONVERSION=ON \
-DACTIVATE_WARNING_STRICT_OVERFLOW=ON
cat ViSP-third-party.txt

- name: Build visp-config script
Expand Down
19 changes: 10 additions & 9 deletions apps/calibration/intrinsic/calibration-helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Tee
std::ofstream &file;

public:
Tee(std::ostream &os_, std::ofstream &file_) : os(os_), file(file_) {}
Tee(std::ostream &os_, std::ofstream &file_) : os(os_), file(file_) { }

template <typename T>
Tee &operator<<(const T &thing)
Expand Down Expand Up @@ -199,7 +199,7 @@ struct CalibInfo
CalibInfo(const vpImage<unsigned char> &img, const std::vector<vpPoint> &points,
const std::vector<vpImagePoint> &imPts, const std::string &frame_name)
: m_img(img), m_points(points), m_imPts(imPts), m_frame_name(frame_name)
{}
{ }

vpImage<unsigned char> m_img;
std::vector<vpPoint> m_points;
Expand Down Expand Up @@ -568,26 +568,27 @@ void calcChessboardCorners(cv::Size boardSize, float squareSize, std::vector<cv:
CvPattern patternType = CV_CHESSBOARD)
{
corners.resize(0);

unsigned int boardHeight = static_cast<unsigned int>(boardSize.height), boardHeightMinusOne = static_cast<unsigned int>(boardSize.height) - 1;
unsigned int boardWidth = static_cast<unsigned int>(boardSize.width), boardWidthMinusOne = static_cast<unsigned int>(boardSize.width) - 1;
switch (patternType) {
case CV_CHESSBOARD:
case CV_CIRCLES_GRID:
for (int i = 0; i < boardSize.height; i++)
for (int j = 0; j < boardSize.width; j++)
for (unsigned int i = 0; i < boardHeight; i++)
for (unsigned int j = 0; j < boardWidth; j++)
corners.push_back(cv::Point3f(float(j*squareSize),
float(i*squareSize), 0));
break;

case CV_ASYMMETRIC_CIRCLES_GRID:
for (int i = 0; i < boardSize.height; i++)
for (int j = 0; j < boardSize.width; j++)
for (unsigned int i = 0; i < boardHeight; i++)
for (unsigned int j = 0; j < boardWidth; j++)
corners.push_back(cv::Point3f(float((2*j + i % 2)*squareSize),
float(i*squareSize), 0));
break;

case CV_CHARUCOBOARD:
for (int i = 0; i < boardSize.height-1; i++)
for (int j = 0; j < boardSize.width-1; j++)
for (unsigned int i = 0; i < boardHeightMinusOne; i++)
for (unsigned int j = 0; j < boardWidthMinusOne; j++)
corners.push_back(cv::Point3f(float(j*squareSize),
float(i*squareSize), 0));
break;
Expand Down
29 changes: 17 additions & 12 deletions apps/calibration/intrinsic/visp-calibrate-camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,16 +344,18 @@ int main(int argc, const char *argv[])

// Create board 3D object points
#if (VISP_HAVE_OPENCV_VERSION >= 0x040700)
unsigned int boardHeight = static_cast<unsigned int>(s.boardSize.height), boardHeightMinusOne = static_cast<unsigned int>(s.boardSize.height)-1U;
unsigned int boardWidth = static_cast<unsigned int>(s.boardSize.width), boardWidthMinusOne = static_cast<unsigned int>(s.boardSize.width)-1U;
if (s.calibrationPattern == Settings::CHARUCOBOARD) {
for (int i = 0; i < s.boardSize.height-1; i++) {
for (int j = 0; j < s.boardSize.width-1; j++) {
for (unsigned int i = 0; i < boardHeightMinusOne; i++) {
for (unsigned int j = 0; j < boardWidthMinusOne; j++) {
model.push_back(vpPoint(j * s.squareSize, i * s.squareSize, 0));
}
}
}
else {
for (int i = 0; i < s.boardSize.height; i++) {
for (int j = 0; j < s.boardSize.width; j++) {
for (unsigned int i = 0; i < boardHeight; i++) {
for (unsigned int j = 0; j < boardWidth; j++) {
model.push_back(vpPoint(j * s.squareSize, i * s.squareSize, 0));
}
}
Expand All @@ -370,8 +372,10 @@ int main(int argc, const char *argv[])
ch_detector = cv::makePtr<cv::aruco::CharucoDetector>(cv::aruco::CharucoDetector(*ch_board));
}
#else
for (int i = 0; i < s.boardSize.height; i++) {
for (int j = 0; j < s.boardSize.width; j++) {
unsigned int boardHeight = static_cast<unsigned int>(s.boardSize.height);
unsigned int boardWidth = static_cast<unsigned int>(s.boardSize.width);
for (unsigned int i = 0; i < boardHeight; i++) {
for (unsigned int j = 0; j < boardWidth; j++) {
model.push_back(vpPoint(j * s.squareSize, i * s.squareSize, 0));
}
}
Expand Down Expand Up @@ -763,9 +767,10 @@ int main(int argc, const char *argv[])
#else
const int offset = 0;
#endif
for (int i = 0; i < s.boardSize.height+offset; i++) {
std::vector<vpImagePoint> current_line(grid_points.begin() + i * (s.boardSize.width+offset),
grid_points.begin() + (i + 1) * (s.boardSize.width+offset));
const unsigned int heightWithOffset = static_cast<unsigned int>(s.boardSize.height+offset);
for (unsigned int i = 0; i < heightWithOffset; i++) {
std::vector<vpImagePoint> current_line(grid_points.begin() + i * static_cast<unsigned int>(s.boardSize.width+offset),
grid_points.begin() + (i + 1U) * static_cast<unsigned int>(s.boardSize.width+offset));

std::vector<vpImagePoint> current_line_undist = undistort(cam, current_line);
double a = 0, b = 0, c = 0;
Expand Down Expand Up @@ -801,9 +806,9 @@ int main(int argc, const char *argv[])
vpDisplay::displayText(I_dist_undist, 15 * static_cast<int>(vpDisplay::getDownScalingFactor(I_dist_undist)),
static_cast<int>(I.getWidth()) + 15 * static_cast<int>(vpDisplay::getDownScalingFactor(I_dist_undist)),
calib_info[idx].m_frame_name + std::string(" undistorted"), vpColor::red);
for (int i = 0; i < s.boardSize.height+offset; i++) {
std::vector<vpImagePoint> current_line(found_grid_points.begin() + i * (s.boardSize.width+offset),
found_grid_points.begin() + (i + 1) * (s.boardSize.width+offset));
for (unsigned int i = 0; i < heightWithOffset; i++) {
std::vector<vpImagePoint> current_line(found_grid_points.begin() + i * static_cast<unsigned int>(s.boardSize.width+offset),
found_grid_points.begin() + (i + 1) * static_cast<unsigned int>(s.boardSize.width+offset));

double a = 0, b = 0, c = 0;
double line_fitting_error = vpMath::lineFitting(current_line, a, b, c);
Expand Down
13 changes: 11 additions & 2 deletions modules/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,11 @@ vp_create_module(${opt_libs})
vp_create_compat_headers("include/visp3/core/vpConfig.h")

if (UNIX)
vp_set_source_file_compile_flag(src/image/vpFont.cpp -Wno-misleading-indentation -Wno-float-equal -Wno-sign-conversion)
vp_set_source_file_compile_flag(src/tools/file/vpIoTools_npy.cpp -Wno-strict-aliasing -Wno-sign-conversion)
vp_set_source_file_compile_flag(src/image/vpFont.cpp -Wno-misleading-indentation -Wno-float-equal -Wno-sign-conversion -Wno-strict-overflow)
vp_set_source_file_compile_flag(src/tools/file/vpIoTools_npy.cpp -Wno-strict-aliasing -Wno-sign-conversion -Wno-strict-overflow)
vp_set_source_file_compile_flag(src/math/matrix/vpMatrix_cholesky.cpp -Wno-strict-overflow) # warnings due to eigen3
vp_set_source_file_compile_flag(src/math/matrix/vpMatrix_lu.cpp -Wno-strict-overflow) # warnings due to eigen3
vp_set_source_file_compile_flag(src/math/matrix/vpMatrix_svd.cpp -Wno-strict-overflow) # warnings due to eigen3
elseif(MSVC AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") # clang-cl usage
vp_set_source_file_compile_flag(src/image/vpFont.cpp -Wno-reserved-identifier -Wno-sign-conversion -Wno-zero-as-null-pointer-constant -Wno-old-style-cast -Wno-sign-conversion -Wno-float-equal -Wno-cast-qual -Wno-switch-default -Wno-c++23-extensions -Wno-implicit-fallthrough -Wno-implicit-int-float-conversion -Wno-cast-qual -Wno-comma -Wno-double-promotion)
vp_set_source_file_compile_flag(src/tools/file/vpIoTools_npy.cpp -Wno-old-style-cast -Wno-sign-conversion -Wno-switch-default -Wno-sign-conversion -Wno-comma -Wno-zero-as-null-pointer-constant -Wno-tautological-type-limit-compare -Wno-cast-align -Wno-extra-semi-stmt -Wno-missing-prototypes)
Expand Down Expand Up @@ -361,3 +364,9 @@ vp_add_tests(CTEST_EXCLUDE_PATH network DEPENDS_ON visp_io visp_gui PRIVATE_INCL
vp_glob_module_copy_data("test/math/data/*.pgm" "modules/core" NO_INSTALL)
# copy font
vp_glob_module_copy_data("src/image/private/Rubik-Regular.ttf" "data/font")

if(CMAKE_COMPILER_IS_GNUCXX)
set_source_files_properties(test/image/testHSVGradient.cpp PROPERTIES COMPILE_FLAGS "-Wno-strict-overflow")
set_source_files_properties(test/math/perfMatrixMultiplication.cpp PROPERTIES COMPILE_FLAGS "-Wno-strict-overflow")
set_source_files_properties(test/math/catchEigenConversion.cpp PROPERTIES COMPILE_FLAGS "-Wno-strict-overflow") # warnings due to eigen3
endif()
79 changes: 46 additions & 33 deletions modules/core/include/visp3/core/vpImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -1549,7 +1549,7 @@ class VISP_EXPORT vpImageFilter
#ifdef VISP_HAVE_OPENMP
}
#endif
}
}
}

/**
Expand Down Expand Up @@ -1880,23 +1880,23 @@ class VISP_EXPORT vpImageFilter
sigma = static_cast<FilterType>((size - 1) / 6.0);
}

int middle = (static_cast<int>(size) - 1) / 2;
// Utilisation de unsigned int
unsigned int middle = (size - 1) / 2;
FilterType sigma2 = static_cast<FilterType>(vpMath::sqr(static_cast<double>(sigma)));
FilterType coef1 = static_cast<FilterType>(1. / (static_cast<double>(sigma) * sqrt(2. * M_PI)));
FilterType v_2_sigma2 = static_cast<FilterType>(2. * static_cast<double>(sigma2));
for (int i = 0; i <= middle; ++i) {
filter[i] = coef1 * static_cast<FilterType>(exp(static_cast<double>(-static_cast<FilterType>(i * i) / v_2_sigma2)));

for (unsigned int i = 0; i <= middle; ++i) {
filter[i] = coef1 * static_cast<FilterType>(exp(static_cast<double>(-(double)(i * i) / v_2_sigma2)));
}

if (normalize) {
// renormalization
FilterType sum = 0;
const unsigned int val2 = 2U;
for (int i = 1; i <= middle; ++i) {
sum += val2 * filter[i];
FilterType sum = filter[0];
for (unsigned int i = 1; i <= middle; ++i) {
sum += static_cast<FilterType>(2) * filter[i];
}
sum += filter[0];

for (int i = 0; i <= middle; ++i) {
for (unsigned int i = 0; i <= middle; ++i) {
filter[i] = filter[i] / sum;
}
}
Expand Down Expand Up @@ -1928,29 +1928,31 @@ class VISP_EXPORT vpImageFilter
sigma = static_cast<FilterType>((size - 1) / 6.0);
}

const int half = 2;
int middle = (static_cast<int>(size) - 1) / half;
const unsigned int half = 2;
unsigned int middle = (size - 1) / half;
FilterType sigma2 = static_cast<FilterType>(vpMath::sqr(static_cast<double>(sigma)));
FilterType coef_1 = static_cast<FilterType>(1. / (static_cast<double>(sigma) * sqrt(2. * M_PI)));
FilterType coef_1_over_2 = coef_1 / static_cast<FilterType>(2.);
FilterType v_2_coef_1 = static_cast<FilterType>(2.) * coef_1;
FilterType v_2_sigma2 = static_cast<FilterType>(2.) * sigma2;

filter[0] = 0.;
for (int i = 1; i <= middle; ++i) {
for (unsigned int i = 1; i <= middle; ++i) {
FilterType i_plus_1 = static_cast<FilterType>(i + 1);
FilterType i_minus_1 = static_cast<FilterType>(i - 1);
filter[i] = -coef_1_over_2 * (static_cast<FilterType>(exp(-static_cast<double>(i_plus_1 * i_plus_1 / v_2_sigma2))) - static_cast<FilterType>(exp(-static_cast<double>(i_minus_1 * i_minus_1 / v_2_sigma2))));
filter[i] = -coef_1_over_2 * (static_cast<FilterType>(exp(-(double)(i_plus_1 * i_plus_1) / v_2_sigma2)) -
static_cast<FilterType>(exp(-(double)(i_minus_1 * i_minus_1) / v_2_sigma2)));
}

if (normalize) {
FilterType sum = static_cast<FilterType>(0);
for (int i = 1; i <= middle; ++i) {
for (unsigned int i = 1; i <= middle; ++i) {
FilterType i_ = static_cast<FilterType>(i);
sum += v_2_coef_1 * static_cast<FilterType>(exp(-static_cast<double>(i_ * i_ / v_2_sigma2)));
}
sum += coef_1;

for (int i = 1; i <= middle; ++i) {
for (unsigned int i = 1; i <= middle; ++i) {
filter[i] = filter[i] / sum;
}
}
Expand Down Expand Up @@ -2585,7 +2587,8 @@ class VISP_EXPORT vpImageFilter
// Computing the difference and sign for row 1 column 0
Idiff[nbCols] = static_cast<OutputType>(I.bitmap[nbCols + 1].V - I.bitmap[nbCols].V);

for (unsigned int iter = 1; iter < nbCols - 1; ++iter) {
unsigned int limit = nbCols - 1;
for (unsigned int iter = 1; iter < limit; ++iter) {
// Computing the difference and sign for row 0
OutputType distanceRow0 = static_cast<OutputType>(I.bitmap[iter + 1].V - I.bitmap[iter].V);
Idiff[iter] = distanceRow0;
Expand Down Expand Up @@ -2714,31 +2717,34 @@ class VISP_EXPORT vpImageFilter
}

#ifdef VISP_HAVE_OPENMP

template <typename HSVType, bool useFullScale, typename OutputType>
static typename std::enable_if<std::is_arithmetic<OutputType>::value, void>::type initGradientFilterDifferenceImageX(
const vpImage<vpHSV<HSVType, useFullScale>> &I, std::vector<OutputType> &Idiff,
const int &istart, const int &iam
)
{
const int nbCols = static_cast<int>(I.getCols());
const unsigned int nbCols = I.getCols();
const unsigned int start = static_cast<unsigned int>(istart);

if (iam > 0) {
Idiff[0] = static_cast<OutputType>(I.bitmap[istart - nbCols + 1].V - I.bitmap[istart - nbCols].V);
Idiff[0] = static_cast<OutputType>(I.bitmap[start - nbCols + 1].V - I.bitmap[start - nbCols].V);
}

// Computing the difference and sign for row 1 column 0, which corresponds to the current row of the image
Idiff[static_cast<size_t>(nbCols)] = static_cast<OutputType>(I.bitmap[istart + 1].V - I.bitmap[istart].V);
Idiff[static_cast<size_t>(nbCols)] = static_cast<OutputType>(I.bitmap[start + 1].V - I.bitmap[start].V);

for (int iter = 1; iter < nbCols - 1; ++iter) {
const unsigned int nbColsM1 = nbCols - 1;
for (unsigned int iter = 1; iter < nbColsM1; ++iter) {
if (iam > 0) {
// Computing the difference and sign for row 0, which corresponds to the previous row of the image
OutputType distanceRow0 = static_cast<OutputType>(I.bitmap[istart - nbCols + iter + 1].V - I.bitmap[istart - nbCols + iter].V);
Idiff[static_cast<size_t>(iter)] = distanceRow0;
OutputType distanceRow0 = static_cast<OutputType>(I.bitmap[start - nbCols + iter + 1].V - I.bitmap[start - nbCols + iter].V);
Idiff[iter] = distanceRow0;
}

// Computing the difference and sign for row 1, which corresponds to the current row of the image
OutputType distanceRow1 = static_cast<OutputType>(I.bitmap[istart + iter + 1].V - I.bitmap[istart + iter].V);
Idiff[static_cast<size_t>(nbCols + iter)] = distanceRow1;
OutputType distanceRow1 = static_cast<OutputType>(I.bitmap[start + iter + 1].V - I.bitmap[start + iter].V);
Idiff[nbCols + iter] = distanceRow1;
}
}

Expand Down Expand Up @@ -2831,17 +2837,18 @@ class VISP_EXPORT vpImageFilter
const int &istart
)
{
const int nbCols = static_cast<int>(I.getCols());
const unsigned int nbCols = I.getCols();
// Computing the sign and distance for the first row, which corresponds to the row above the beginning of the gradient computation in the thread
int idDiff = 0;
for (int iter = istart - nbCols; iter < istart; ++iter) {
unsigned int idDiff = 0;
const unsigned int start = static_cast<unsigned int>(istart);
for (unsigned int iter = start - nbCols; iter < start; ++iter) {
OutputType distance = static_cast<OutputType>(I.bitmap[iter + nbCols].V - I.bitmap[iter].V);
Idiff[static_cast<size_t>(idDiff)] = distance;
Idiff[idDiff] = distance;
++idDiff;
}
// Computing the distance and sign for I[1][0]
OutputType distance = static_cast<OutputType>(I.bitmap[static_cast<size_t>(nbCols + nbCols)].V - I.bitmap[static_cast<size_t>(nbCols)].V);
Idiff[static_cast<size_t>(nbCols)] = distance;
OutputType distance = static_cast<OutputType>(I.bitmap[nbCols + nbCols].V - I.bitmap[nbCols].V);
Idiff[nbCols] = distance;
}

template <typename HSVType, bool useFullScale, typename OutputType>
Expand All @@ -2865,6 +2872,10 @@ class VISP_EXPORT vpImageFilter

int iam, nt, irows, rstart, istart, istop;

#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-overflow"
#endif
#pragma omp parallel default(shared) private(iam, nt, irows, rstart, istart, istop) num_threads(nbThread)
{
iam = omp_get_thread_num();
Expand Down Expand Up @@ -2899,7 +2910,6 @@ class VISP_EXPORT vpImageFilter
futureDiff = static_cast<OutputType>(I.bitmap[static_cast<size_t>(iter + nbCols +1)].V - I.bitmap[static_cast<size_t>(iter + offsetIdiff)].V);
Idiff[static_cast<size_t>(iter - istart + nbCols + offsetIdiff)] = futureDiff;
}

if (counter) {
if ((counter != resetCounter)) {
if (checkBooleanMask(p_mask, iter)) {
Expand Down Expand Up @@ -2927,6 +2937,9 @@ class VISP_EXPORT vpImageFilter
{
std::memcpy(GI.bitmap + istart, GItemp.data(), GItemp.size() * sizeof(OutputType));
}
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
}
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions modules/core/include/visp3/core/vpImageMorphology.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ void vpImageMorphology::imageOperation(vpImage<T> &I, vpPixelOperation<T> *opera
for (int r = 0; r < height_in; ++r) {
// Computing the rows we can explore without going outside the limits of the image
int r_iterator_start = -halfKernelSize, r_iterator_stop = halfKernelSize + 1;
if ((r - halfKernelSize) < 0) {
if (r < halfKernelSize) {
r_iterator_start = -r;
}
else if ((r + halfKernelSize) >= height_in) {
Expand All @@ -492,7 +492,7 @@ void vpImageMorphology::imageOperation(vpImage<T> &I, vpPixelOperation<T> *opera
T value = I[r][c];
// Computing the columns we can explore without going outside the limits of the image
int c_iterator_start = -halfKernelSize, c_iterator_stop = halfKernelSize + 1;
if ((c - halfKernelSize) < 0) {
if (c < halfKernelSize) {
c_iterator_start = -c;
}
else if ((c + halfKernelSize) >= width_in) {
Expand Down
14 changes: 6 additions & 8 deletions modules/core/include/visp3/core/vpImageTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -758,19 +758,17 @@ inline void vpImageTools::binarise(vpImage<Type> &I, Type threshold1, Type thres
std::cerr << "LUT not available for this type ! Will use the iteration method." << std::endl;
}

Type v;
Type *p = I.bitmap;
Type *pend = I.bitmap + (I.getWidth() * I.getHeight());
for (; p < pend; ++p) {
v = *p;
const size_t size = I.getWidth() * I.getHeight();
for (size_t i = 0; i < size; ++i) {
Type v = I.bitmap[i];
if (v < threshold1) {
*p = value1;
I.bitmap[i] = value1;
}
else if (v > threshold2) {
*p = value3;
I.bitmap[i] = value3;
}
else {
*p = value2;
I.bitmap[i] = value2;
}
}
}
Expand Down
Loading
Loading