Skip to content

Commit

Permalink
Merge pull request #1348 from fspindle/fix_various_warnings_ubuntu12.04
Browse files Browse the repository at this point in the history
Fix various warnings ubuntu12.04
  • Loading branch information
fspindle authored Mar 14, 2024
2 parents f38b75f + 0a7d3f3 commit ac958c9
Show file tree
Hide file tree
Showing 56 changed files with 515 additions and 823 deletions.
32 changes: 25 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,23 @@ if(USE_PCL)
vp_find_pcl(PCL_LIBRARIES PCL_DEPS_INCLUDE_DIRS PCL_DEPS_LIBRARIES)
endif()

# ----------------------------------------------------------------------------
# Handle OpenCV 2.4.8 as minimal version
# ----------------------------------------------------------------------------
if(USE_OPENCV)
if(OpenCV_VERSION)
if(OpenCV_VERSION VERSION_LESS "2.4.8")
message(WARNING "OpenCV 3rd party was detected but its version ${OpenCV_VERSION} is too old. Thus we disable OpenCV usage turning USE_OPENCV=OFF.")
unset(USE_OPENCV)
set(USE_OPENCV OFF CACHE BOOL "Include OpenCV support" FORCE)
endif()
else()
message(WARNING "OpenCV 3rd party was detected but its version cannot be found or is too old. Thus we disable OpenCV usage turning USE_OPENCV=OFF.")
unset(USE_OPENCV)
set(USE_OPENCV OFF CACHE BOOL "Include OpenCV support" FORCE)
endif()
endif()

# ----------------------------------------------------------------------------
# Handle cxx standard depending on specific 3rd parties. Should be before module parsing and VISP3rdParty.cmake include
# ----------------------------------------------------------------------------
Expand All @@ -642,7 +659,7 @@ endif()

if(VISP_CXX_STANDARD LESS VISP_CXX_STANDARD_14)
if(USE_FTIITSDK)
message(WARNING "IIT force-torque SDK 3rd party was detected and needs at least c++14 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable IIT force-torque usage turning USE_OPENCV=OFF.")
message(WARNING "IIT force-torque SDK 3rd party was detected and needs at least c++14 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable IIT force-torque usage turning USE_FTIITSDK=OFF.")
unset(USE_FTIITSDK)
set(USE_FTIITSDK OFF CACHE BOOL "Include IIT force-torque SDK support" FORCE)
endif()
Expand Down Expand Up @@ -694,13 +711,14 @@ if(VISP_CXX_STANDARD LESS VISP_CXX_STANDARD_11)
message(WARNING "std::thread was detected but needs at least c++11 standard compiler flag while you have set c++${USE_CXX_STANDARD}. Thus we disable std::thread usage turning USE_THREADS=OFF.")
unset(USE_THREADS)
set(USE_THREADS OFF CACHE BOOL "Include std::thread support" FORCE)
elseif(UNIX)
# Apriltag on unix needs pthread. On windows we are using pthread built-in
if(Threads_FOUND)
set(USE_PTHREAD ON) # for AprilTag only
endif()
endif()
endif()

if(UNIX AND Threads_FOUND)
# Apriltag on unix needs native pthread. On windows we are using pthread built-in
set(USE_PTHREAD ON) # for AprilTag only
endif()

# ----------------------------------------------------------------------------
# Build-in 3rd parties. Should be after c++ standard potential modification
# ----------------------------------------------------------------------------
Expand Down Expand Up @@ -1732,7 +1750,7 @@ status("")
status(" Optimization: ")
status(" Use OpenMP:" USE_OPENMP THEN "yes" ELSE "no")
status(" Use std::thread:" USE_THREADS THEN "yes" ELSE "no")
status(" Use pthread:" USE_PHREADS THEN "yes" ELSE "no")
status(" Use pthread:" USE_PTHREAD THEN "yes" ELSE "no")
status(" Use pthread (built-in):" WITH_PTHREAD THEN "yes (ver ${PTHREADS_VERSION})" ELSE "no")
status(" Use simdlib (built-in):" WITH_SIMDLIB THEN "yes" ELSE "no")
status("")
Expand Down
5 changes: 5 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ViSP 3.x.x (Version in development)
. End of supporting c++98 standard. As a consequence, ViSP is no more compatible with Ubuntu 12.04
. vpDisplay::displayCharString() is marked deprecated. Use vpDisplay::displayText() instead
- New features and improvements
. OpenCV 2.4.8 is the minimal supported version
. Introduce applications in apps folder, a collection of useful tools that
have a dependency to the install target
. Bump minimal c++ standard to c++11
Expand All @@ -30,6 +31,8 @@ ViSP 3.x.x (Version in development)
https://visp-doc.inria.fr/doxygen/visp-daily/tutorial-tracking-mb-generic-rgbd-Blender.html
. New tutorial: Installation from prebuilt Conda packages for Linux / OSX / Windows
https://visp-doc.inria.fr/doxygen/visp-daily/tutorial-install-conda-package.html
. New tutorial: Using Statistical Process Control to monitor your signal
https://visp-doc.inria.fr/doxygen/visp-daily/tutorial-spc.html
- Bug fixed
. [#1251] Bug in vpDisplay::displayFrame()
. [#1270] Build issue around std::clamp and optional header which are not found with cxx17
Expand All @@ -40,6 +43,8 @@ ViSP 3.x.x (Version in development)
. [#1279] Issue in vpPoseVector json serialization
. [#1296] Unable to parse camera parameters with vpXmlParserCamera::parse() when camera name is empty
. [#1307] Cannot set cxx standard when configuring for Visual Studio
. [#1320] Broken links in the documentation
. [#1341] SVD computation fails with Lapack when m < n
----------------------------------------------
ViSP 3.6.0 (released September 22, 2023)
- Contributors:
Expand Down
3 changes: 2 additions & 1 deletion cmake/AddExtraCompilationFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ if(USE_OPENMP)
add_extra_compiler_option("${OpenMP_CXX_FLAGS}")
endif()

if(USE_THREADS)
if(USE_THREADS OR USE_PTHREAD)
# Condider the case of Apriltags on Unix that needs pthread
if(THREADS_HAVE_PTHREAD_ARG)
add_extra_compiler_option("-pthread")
endif()
Expand Down
21 changes: 9 additions & 12 deletions doc/tutorial/tracking/tutorial-tracking-keypoint.dox
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ It can also be run with [--init-by-click] option. In that case, the user can sel
$ ./tutorial-klt-tracker --init-by-click
\endcode

Here is the line by line explanation of the source :
Here is the line by line explanation of the source :

\snippet tutorial-klt-tracker.cpp Include

Expand All @@ -60,19 +60,19 @@ This image \c I is then converted into \c cvI, an OpenCV image format that will

\snippet tutorial-klt-tracker.cpp Convert to OpenCV image

We also create a window associated to \c I, at position (0,0) in the screen, with "Klt tracking" as title, and display image \c I.
We also create a window associated to \c I, at position (0,0) in the screen, with "Klt tracking" as title, and display image \c I.

\snippet tutorial-klt-tracker.cpp Init display

From now we have to create an instance of the tracker and set the parameters of the Harris keypoint detector.

\snippet tutorial-klt-tracker.cpp Create tracker

The tracker is then initialized on \c cvI image.

\snippet tutorial-klt-tracker.cpp Init tracker

With the next line the user can know how many keypoints were detected automatically or selected by the user during initialization.
With the next line the user can know how many keypoints were detected automatically or selected by the user during initialization.

\snippet tutorial-klt-tracker.cpp How many features

Expand All @@ -92,7 +92,7 @@ We are waiting for a mouse click event on image \c I to end the program.

\section tracking_keypoint_klt_init KLT tracker with re-initialisation

Once initialized, the number of tracked features decreases over the time. Depending on a criteria, it may sense to detect and track new features online. A possible criteria is for example to compare the number of currently tracked features to the initial number of detected features. If less than a given percentage of features are tracked, you can start a new detection.
Once initialized, the number of tracked features decreases over the time. Depending on a criteria, it may sense to detect and track new features online. A possible criteria is for example to compare the number of currently tracked features to the initial number of detected features. If less than a given percentage of features are tracked, you can start a new detection.

To get the number of detected or tracked features just call:

Expand All @@ -107,10 +107,10 @@ The example tutorial-klt-tracker-with-reinit.cpp shows how to do that. In that e
\code
if (reader.getFrameIndex() == 25) {
std::cout << "Re initialize the tracker" << std::endl;
#if (VISP_HAVE_OPENCV_VERSION >= 0x020408)

// Save of previous features
std::vector<cv::Point2f> prev_features = tracker.getFeatures();

// Start a new feature detection
tracker.initTracking(cvI);
std::vector<cv::Point2f> new_features = tracker.getFeatures();
Expand All @@ -122,7 +122,7 @@ The example tutorial-klt-tracker-with-reinit.cpp shows how to do that. In that e
// Test if a previous feature is not redundant with one of the newly detected
is_redundant = false;
for (size_t j=0; j < new_features.size(); j++){
distance = sqrt(vpMath::sqr(new_features[j].x-prev_features[i].x)
distance = sqrt(vpMath::sqr(new_features[j].x-prev_features[i].x)
+ vpMath::sqr(new_features[j].y-prev_features[i].y));
if(distance < minDistance_){
is_redundant = true;
Expand All @@ -135,9 +135,6 @@ The example tutorial-klt-tracker-with-reinit.cpp shows how to do that. In that e
//std::cout << "Add previous feature with index " << i << std::endl;
tracker.addFeature(prev_features[i]);
}
#else
...
#endif
}
// Track the features
tracker.track(cvI);
Expand Down
2 changes: 1 addition & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ visp_add_subdirectory(direct-visual-servoing REQUIRED_DEPS visp_core visp_robo
visp_add_subdirectory(homography REQUIRED_DEPS visp_core visp_vision visp_io)
visp_add_subdirectory(image REQUIRED_DEPS visp_core visp_io)
visp_add_subdirectory(manual REQUIRED_DEPS visp_core visp_sensor visp_vs visp_robot visp_ar visp_vision visp_io visp_gui)
visp_add_subdirectory(math REQUIRED_DEPS visp_core visp_vision visp_io)
visp_add_subdirectory(math REQUIRED_DEPS visp_core visp_io)
visp_add_subdirectory(moments/image REQUIRED_DEPS visp_core visp_vs visp_robot visp_gui)
visp_add_subdirectory(moments/points REQUIRED_DEPS visp_core visp_vs visp_robot visp_gui)
visp_add_subdirectory(moments/polygon REQUIRED_DEPS visp_core visp_vs visp_robot visp_gui)
Expand Down
2 changes: 1 addition & 1 deletion example/math/quadprog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ int main(int argc, char **argv)
r = randV(o) * 5;
C = randM(p, n) * 5;

// make sure Cx <= d has a solution within Ax = b
// make sure Cx <= d has a solution within Ax = b
vpColVector x = A.solveBySVD(b);
d = C * x;
for (int i = 0; i < p; ++i)
Expand Down
1 change: 1 addition & 0 deletions example/math/quadprog_eq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ int main(int argc, char **argv)
C = randM(p, n) * 5;

// make sure Cx <= d has a solution within Ax = b

vpColVector x = A.solveBySVD(b);
d = C * x;
for (int i = 0; i < p; ++i)
Expand Down
42 changes: 33 additions & 9 deletions modules/core/include/visp3/core/vpArray2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,28 @@ template <class Type> class vpArray2D

// Reallocation of this->data array
this->dsize = nrows * ncols;
this->data = (Type *)realloc(this->data, this->dsize * sizeof(Type));
Type *tmp_data = reinterpret_cast<Type *>(realloc(this->data, this->dsize * sizeof(Type)));
if (tmp_data) {
this->data = tmp_data;
}
else {
this->data = nullptr;
}

if ((nullptr == this->data) && (0 != this->dsize)) {
if (copyTmp != nullptr) {
delete[] copyTmp;
}
throw(vpException(vpException::memoryAllocationError, "Memory allocation error when allocating 2D array data"));
}

this->rowPtrs = (Type **)realloc(this->rowPtrs, nrows * sizeof(Type *));
Type **tmp_rowPtrs = reinterpret_cast<Type **>(realloc(this->rowPtrs, nrows * sizeof(Type *)));
if (tmp_rowPtrs) {
this->rowPtrs = tmp_rowPtrs;
}
else {
this->rowPtrs = nullptr;
}
if ((nullptr == this->rowPtrs) && (0 != this->dsize)) {
if (copyTmp != nullptr) {
delete[] copyTmp;
Expand Down Expand Up @@ -389,11 +402,18 @@ template <class Type> class vpArray2D

rowNum = nrows;
colNum = ncols;
rowPtrs = reinterpret_cast<Type **>(realloc(rowPtrs, nrows * sizeof(Type *)));
// Update rowPtrs
Type **t_ = rowPtrs;
for (unsigned int i = 0; i < dsize; i += ncols) {
*t_++ = data + i;
if (rowPtrs) {
Type **tmp = reinterpret_cast<Type **>(realloc(rowPtrs, nrows * sizeof(Type *)));
if (tmp) {
this->rowPtrs = tmp;
}
}
if (rowPtrs) {
// Update rowPtrs
Type **t_ = rowPtrs;
for (unsigned int i = 0; i < dsize; i += ncols) {
*t_++ = data + i;
}
}
}

Expand Down Expand Up @@ -458,8 +478,12 @@ template <class Type> class vpArray2D
vpArray2D<Type> &operator=(vpArray2D<Type> &&other) noexcept
{
if (this != &other) {
free(data);
free(rowPtrs);
if (data) {
free(data);
}
if (rowPtrs) {
free(rowPtrs);
}

rowNum = other.rowNum;
colNum = other.colNum;
Expand Down
7 changes: 4 additions & 3 deletions modules/core/include/visp3/core/vpHinkley.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#if defined(VISP_BUILD_DEPRECATED_FUNCTIONS)
/*!
\class vpHinkley
\deprecated This class is deprecated. You should rather use vpStatisticalTestHinkley.
\ingroup group_core_math_tools
\brief This class implements the Hinkley's cumulative sum test.
Expand Down Expand Up @@ -89,7 +90,7 @@
N_{k^{'}} = 0 \f$.
*/
class vp_deprecated vpHinkley
class VISP_EXPORT vpHinkley
{
public:
/*! \enum vpHinkleyJumpType
Expand All @@ -103,9 +104,9 @@ class vp_deprecated vpHinkley
} vpHinkleyJumpType;

public:
vpHinkley();
vp_deprecated vpHinkley();
virtual ~vpHinkley();
vpHinkley(double alpha, double delta);
vp_deprecated vpHinkley(double alpha, double delta);

void init();
void init(double alpha, double delta);
Expand Down
4 changes: 3 additions & 1 deletion modules/core/include/visp3/core/vpImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,9 @@ vpImage<Type>::vpImage(const vpImage<Type> &I)
: bitmap(nullptr), display(nullptr), npixels(0), width(0), height(0), row(nullptr), hasOwnership(true)
{
resize(I.getHeight(), I.getWidth());
memcpy(static_cast<void *>(bitmap), static_cast<void *>(I.bitmap), I.npixels * sizeof(Type));
if (bitmap) {
memcpy(static_cast<void *>(bitmap), static_cast<void *>(I.bitmap), I.npixels * sizeof(Type));
}
}

#if ((__cplusplus >= 201103L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L))) // Check if cxx11 or higher
Expand Down
2 changes: 1 addition & 1 deletion modules/core/include/visp3/core/vpImageConvert.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
#include <visp3/core/vpRGBa.h>

#if defined(VISP_HAVE_OPENCV) && defined(HAVE_OPENCV_IMGPROC)
#include <opencv2/imgproc.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/imgproc/types_c.h>
#endif

Expand Down
8 changes: 4 additions & 4 deletions modules/core/include/visp3/core/vpImageFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class VISP_EXPORT vpImageFilter
}
else {
// Need to reset the image because some points will not be computed
I.resize(height, width, static_cast<ImageType>(0.));
I.resize(height, width, static_cast<ImageType>(0));
}
}

Expand Down Expand Up @@ -227,7 +227,7 @@ class VISP_EXPORT vpImageFilter
cv::Mat cv_I, cv_dIx, cv_dIy;
vpImageConvert::convert(I, cv_I);
computePartialDerivatives(cv_I, cv_dIx, cv_dIy, computeDx, computeDy, normalize, gaussianKernelSize,
gaussianStdev, apertureGradient, filteringType);
static_cast<float>(gaussianStdev), apertureGradient, filteringType);
if (computeDx) {
vpImageConvert::convert(cv_dIx, dIx);
}
Expand Down Expand Up @@ -796,9 +796,9 @@ class VISP_EXPORT vpImageFilter
FilterType result = static_cast<FilterType>(0.);

for (unsigned int i = 1; i <= stop; ++i) {
result += filter[i] * static_cast<double>(I[r][c + i] + I[r][c - i]);
result += filter[i] * static_cast<FilterType>(I[r][c + i] + I[r][c - i]);
}
return result + filter[0] * static_cast<double>(I[r][c]);
return result + filter[0] * static_cast<FilterType>(I[r][c]);
}

#ifndef DOXYGEN_SHOULD_SKIP_THIS
Expand Down
5 changes: 3 additions & 2 deletions modules/core/include/visp3/core/vpImageTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include <iostream>
#include <math.h>
#include <string.h>
#include <cmath>

#if defined(_OPENMP)
#include <omp.h>
Expand Down Expand Up @@ -1113,12 +1114,12 @@ void vpImageTools::resize(const vpImage<Type> &I, vpImage<Type> &Ires, const vpI
#endif
for (int i = 0; i < static_cast<int>(Ires.getHeight()); i++) {
const float v = (i + half) * scaleY - half;
const int v0 = static_cast<int>(v);
const float v0 = std::floor(v);
const float yFrac = v - v0;

for (unsigned int j = 0; j < Ires.getWidth(); j++) {
const float u = (j + half) * scaleX - half;
const int u0 = static_cast<int>(u);
const float u0 = std::floor(u);
const float xFrac = u - u0;

if (method == INTERPOLATION_NEAREST) {
Expand Down
4 changes: 2 additions & 2 deletions modules/core/include/visp3/core/vpMunkres.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ inline vpMunkres::STEP_T vpMunkres::stepSix(std::vector<std::vector<Type> > &cos
template <typename Type>
inline std::vector<std::pair<unsigned int, unsigned int> > vpMunkres::run(std::vector<std::vector<Type> > costs)
{
const auto original_row_size = costs.size();
const auto original_col_size = costs.front().size();
const auto original_row_size = static_cast<Type>(costs.size());
const auto original_col_size = static_cast<Type>(costs.front().size());
const auto sq_size = std::max<Type>(original_row_size, original_col_size);

auto mask = std::vector<std::vector<vpMunkres::ZERO_T> >(
Expand Down
Loading

0 comments on commit ac958c9

Please sign in to comment.