Skip to content

Commit

Permalink
Merge branch 'develop' into fix-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
jlblancoc authored Sep 12, 2023
2 parents d67230d + 8a16010 commit 9ba4481
Show file tree
Hide file tree
Showing 19 changed files with 67 additions and 101 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# For compiling instructions for all compilers and platforms, see
# https://docs.mrpt.org/reference/latest/compiling.html
#
# 2007-2021, Jose Luis Blanco <jlblanco@ual.es>
# 2007-2023, Jose Luis Blanco <jlblanco@ual.es>
# ----------------------------------------------------------------------------

# -------------------------
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ and [much more](https://docs.mrpt.org/reference/latest/applications.html).

## 2. Resources
* Download the latest unstable code with: `git clone https://github.com/MRPT/mrpt.git --recursive`
* Ask questions at: [this Google group](https://www.mrpt.org/forum/) or at [stackoverflow](https://stackoverflow.com/search?q=mrpt) (please, use the tag `mrpt`!)
* Ask questions at [stackoverflow](https://stackoverflow.com/search?q=mrpt) (use the tag `mrpt`)
* [Main project website](https://www.mrpt.org/), including [sources and Windows installer downloads](https://www.mrpt.org/download-mrpt/)
* [C++ API reference](https://docs.mrpt.org/reference/)
* [ROS packages](https://docs.mrpt.org/reference/latest/wrappers.html#mrpt-ros-packages)
Expand Down Expand Up @@ -92,6 +92,13 @@ sudo apt install ros-$ROS_DISTRO-mrpt2
## 4. License
MRPT is released under the [new BSD license](http://www.mrpt.org/License/).


**Contributors**

<a href="https://github.com/MRPT/mrpt/graphs/contributors">
<img src="https://contrib.rocks/image?repo=MRPT/mrpt" />
</a>

## 5. Versions in repositories

![Repology](https://repology.org/badge/vertical-allrepos/mrpt.svg)
6 changes: 3 additions & 3 deletions apps/benchmarking-image-features/src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void MainWindow::on_button_generate_clicked()
xData.at<double>(i) = i;
yData.at<double>(i) = distances(i, 0);
}
#if MRPT_OPENCV_VERSION_NUM >= 0x330
#if MRPT_OPENCV_VERSION_NUM >= 0x030300
plot = plot::Plot2d::create(xData, yData);
#else
plot = plot::createPlot2d(xData, yData);
Expand Down Expand Up @@ -384,7 +384,7 @@ void MainWindow::on_button_generate_clicked()
min_y = -1;
}

#if MRPT_OPENCV_VERSION_NUM >= 0x330
#if MRPT_OPENCV_VERSION_NUM >= 0x030300
plot = plot::Plot2d::create(xData, yData);
#else
plot = plot::createPlot2d(xData, yData);
Expand Down Expand Up @@ -439,7 +439,7 @@ void MainWindow::on_button_generate_clicked()
else
yData.at<double>(i) = v2_surf.at(i);
}
#if MRPT_OPENCV_VERSION_NUM >= 0x330
#if MRPT_OPENCV_VERSION_NUM >= 0x030300
plot = plot::Plot2d::create(xData, yData);
#else
plot = plot::createPlot2d(xData, yData);
Expand Down
6 changes: 3 additions & 3 deletions apps/mrpt-performance/perf-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,9 @@ int main(int argc, char** argv)

const string fil_name = PERF_DATA_DIR +
mrpt::format("/perf-results-%i.%i.%i%s-%s-%ibit.dat",
int((MRPT_VERSION >> 8) & 0x0F),
int((MRPT_VERSION >> 4) & 0x0F),
int((MRPT_VERSION >> 0) & 0x0F), version_postfix,
int((MRPT_VERSION >> 16) & 0xFF),
int((MRPT_VERSION >> 8) & 0xFF),
int((MRPT_VERSION >> 0) & 0xFF), version_postfix,
compiler_name, int(MRPT_WORD_SIZE));
cout << "Saving perf-data to: " << fil_name << endl;
CFileOutputStream f(fil_name);
Expand Down
49 changes: 14 additions & 35 deletions cmakemodules/UtilsMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,42 +57,21 @@ macro(pkgconfig_parse _FLAGS _OUT_PREFIX)
endforeach(str)
endmacro(pkgconfig_parse )

# Convert a decimal value [0,15] to hexadecimal
# From: http://stackoverflow.com/questions/26182289/convert-from-decimal-to-hexadecimal-in-cmake
macro(DECCHAR2HEX VAR VAL)
if (${VAL} LESS 10)
set(${VAR} ${VAL})
elseif(${VAL} EQUAL 10)
set(${VAR} "A")
elseif(${VAL} EQUAL 11)
set(${VAR} "B")
elseif(${VAL} EQUAL 12)
set(${VAR} "C")
elseif(${VAL} EQUAL 13)
set(${VAR} "D")
elseif(${VAL} EQUAL 14)
set(${VAR} "E")
elseif(${VAL} EQUAL 15)
set(${VAR} "F")
else(${VAL} LESS 10)
message(FATAL_ERROR "Invalid format for hexidecimal character")
endif(${VAL} LESS 10)
endmacro(DECCHAR2HEX)

# Converts a version like "1.2.3" into a string "0x123"
# Converts a version like "1.2.3" into a string "0x10203",
# or "3.4.19" into "0x30413".
# Usage: VERSION_TO_HEXADECIMAL(TARGET_VAR "1.2.3")
macro(VERSION_TO_HEXADECIMAL OUT_VAR IN_VERSION)
string(REGEX MATCHALL "[0-9]+" VERSION_PARTS "${IN_VERSION}")
list(GET VERSION_PARTS 0 VERSION_NUMBER_MAJOR)
list(GET VERSION_PARTS 1 VERSION_NUMBER_MINOR)
list(GET VERSION_PARTS 2 VERSION_NUMBER_PATCH)
# Convert each part to hex:
DECCHAR2HEX(VERSION_NUMBER_MAJOR_HEX ${VERSION_NUMBER_MAJOR})
DECCHAR2HEX(VERSION_NUMBER_MINOR_HEX ${VERSION_NUMBER_MINOR})
DECCHAR2HEX(VERSION_NUMBER_PATCH_HEX ${VERSION_NUMBER_PATCH})
# Concat version string:
set(${OUT_VAR} "0x${VERSION_NUMBER_MAJOR_HEX}${VERSION_NUMBER_MINOR_HEX}${VERSION_NUMBER_PATCH_HEX}")
endmacro(VERSION_TO_HEXADECIMAL)
macro(VERSION_TO_HEXADECIMAL OUT_VAR IN_VERSION)
string(REGEX MATCHALL "[0-9]+" VERSION_PARTS "${IN_VERSION}")
list(GET VERSION_PARTS 0 VERSION_NUMBER_MAJOR)
list(GET VERSION_PARTS 1 VERSION_NUMBER_MINOR)
list(GET VERSION_PARTS 2 VERSION_NUMBER_PATCH)

# Convert each part to hex:
math(EXPR ${OUT_VAR}
"(${VERSION_NUMBER_MAJOR} << 16) + \
(${VERSION_NUMBER_MINOR} << 8) + \
(${VERSION_NUMBER_PATCH})" OUTPUT_FORMAT HEXADECIMAL )
endmacro()


# GOOD & BAD are single strings, INPUT is a list wrapped in string
Expand Down
31 changes: 4 additions & 27 deletions cmakemodules/script_create_version_h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,8 @@
# ----------------------------------------------------------------------------
set(CMAKE_MRPT_COMPLETE_NAME "MRPT ${CMAKE_MRPT_VERSION_NUMBER_MAJOR}.${CMAKE_MRPT_VERSION_NUMBER_MINOR}.${CMAKE_MRPT_VERSION_NUMBER_PATCH}")

# There is no built-in support for dec to hex in cmake, sigh...
function(digit_to_hex DIGIT RET)
if (NOT ${DIGIT} GREATER 9)
set(${RET} ${DIGIT} PARENT_SCOPE)
elseif (${DIGIT} MATCHES "10")
set(${RET} "A" PARENT_SCOPE)
elseif (${DIGIT} MATCHES "11")
set(${RET} "B" PARENT_SCOPE)
elseif (${DIGIT} MATCHES "12")
set(${RET} "C" PARENT_SCOPE)
elseif (${DIGIT} MATCHES "13")
set(${RET} "D" PARENT_SCOPE)
elseif (${DIGIT} MATCHES "14")
set(${RET} "E" PARENT_SCOPE)
elseif (${DIGIT} MATCHES "15")
set(${RET} "F" PARENT_SCOPE)
endif()
endfunction()

digit_to_hex(${CMAKE_MRPT_VERSION_NUMBER_MAJOR} CMAKE_MRPT_VERSION_NUMBER_MAJOR_HEX)
digit_to_hex(${CMAKE_MRPT_VERSION_NUMBER_MINOR} CMAKE_MRPT_VERSION_NUMBER_MINOR_HEX)
digit_to_hex(${CMAKE_MRPT_VERSION_NUMBER_PATCH} CMAKE_MRPT_VERSION_NUMBER_PATCH_HEX)

# Build a three digits version code, eg. 0.5.1 -> 051, 1.2.0 -> 120
set(CMAKE_MRPT_VERSION_CODE "0x${CMAKE_MRPT_VERSION_NUMBER_MAJOR_HEX}${CMAKE_MRPT_VERSION_NUMBER_MINOR_HEX}${CMAKE_MRPT_VERSION_NUMBER_PATCH_HEX}")
# Build a six digits hex version code, eg. 1.2.0 -> 0x010200
VERSION_TO_HEXADECIMAL(CMAKE_MRPT_VERSION_CODE ${CMAKE_MRPT_COMPLETE_NAME})

# SOURCE_DATE_EPOCH: See Specs in https://reproducible-builds.org/specs/source-date-epoch/
# Take its value from:
Expand Down Expand Up @@ -80,6 +57,6 @@ if (WIN32)
${MRPT_BINARY_DIR}/version.rc
@ONLY)
set(MRPT_VERSION_RC_FILE "${MRPT_BINARY_DIR}/version.rc")
else(WIN32)
else()
set(MRPT_VERSION_RC_FILE "")
endif (WIN32)
endif()
2 changes: 2 additions & 0 deletions doc/source/doxygen-docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
\page changelog Change Log

# Version 2.10.2: UNRELEASED
- Build system:
- MRPT and OpenCV versions were until now exposed as macros with 3 hexadecimal digits (e.g. `2.4.0`->`0x240`), with a clear limitation of versions greater than 15. Now, both symbols `MRPT_VERSION` and `MRPT_OPENCV_VERSION_NUM` use TWO hexadecimal digits per version part, like: `2.10.2` -> `0x010A02`, which is much more general and safe for the future. For backwards compatibility, just make sure your user code only uses `MRPT_VERSION>=xxx` or `MRPT_VERSION>xxx` comparisons, instead of less-than comparisons (Fixes [issue #1285](https://github.com/MRPT/mrpt/issues/1285)).
- Changes in apps:
- rawlog-edit: Add `--select-label` optional filter to command `--remap-timestamps`.
- Changes in libraries:
Expand Down
10 changes: 5 additions & 5 deletions libs/detectors/src/CCascadeClassifierDetection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using namespace mrpt::obs;
using namespace mrpt::img;
using namespace std;

#if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM >= 0x200
#if MRPT_HAS_OPENCV
using namespace cv;
#endif

Expand All @@ -38,7 +38,7 @@ using namespace cv;
CCascadeClassifierDetection::CCascadeClassifierDetection()
{
// Check if MRPT is using OpenCV
#if !MRPT_HAS_OPENCV || MRPT_OPENCV_VERSION_NUM < 0x200
#if !MRPT_HAS_OPENCV
THROW_EXCEPTION(
"CCascadeClassifierDetection class requires MRPT built against OpenCV "
">=2.0");
Expand All @@ -51,7 +51,7 @@ CCascadeClassifierDetection::CCascadeClassifierDetection()

CCascadeClassifierDetection::~CCascadeClassifierDetection()
{
#if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM >= 0x200
#if MRPT_HAS_OPENCV
delete CASCADE;
#endif
}
Expand All @@ -63,7 +63,7 @@ CCascadeClassifierDetection::~CCascadeClassifierDetection()
void CCascadeClassifierDetection::init(
const mrpt::config::CConfigFileBase& config)
{
#if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM >= 0x200
#if MRPT_HAS_OPENCV
// load configuration values
m_options.cascadeFileName =
config.read_string("CascadeClassifier", "cascadeFilename", "");
Expand Down Expand Up @@ -91,7 +91,7 @@ void CCascadeClassifierDetection::init(
void CCascadeClassifierDetection::detectObjects_Impl(
const CObservation& obs, vector_detectable_object& detected)
{
#if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM >= 0x200
#if MRPT_HAS_OPENCV
// Obtain image from generic observation
const mrpt::img::CImage* img = nullptr;

Expand Down
6 changes: 3 additions & 3 deletions libs/img/include/mrpt/3rdparty/do_opencv_includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
// OPENCV HEADERS
#define CV_NO_CVV_IMAGE // Avoid CImage name crash

#if MRPT_OPENCV_VERSION_NUM < 0x240
#if MRPT_OPENCV_VERSION_NUM < 0x020400
#error "MRPT requires OpenCV 2.4.0 or newer"
#endif

#include <opencv2/opencv_modules.hpp>

// C++ API:
#if MRPT_OPENCV_VERSION_NUM >= 0x300
#if MRPT_OPENCV_VERSION_NUM >= 0x030000
// C++ API - opencv >=3
#include <opencv2/calib3d.hpp>
#include <opencv2/core.hpp>
Expand Down Expand Up @@ -72,7 +72,7 @@
#endif

// Backwards compatible macro:
#if MRPT_OPENCV_VERSION_NUM < 0x344
#if MRPT_OPENCV_VERSION_NUM < 0x030404
#define cvIplImage(X) (X)
#endif

Expand Down
2 changes: 1 addition & 1 deletion libs/img/src/CImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2223,7 +2223,7 @@ void CImage::getAsIplImage(IplImage* dest) const
#if MRPT_HAS_OPENCV
makeSureImageIsLoaded();

#if MRPT_OPENCV_VERSION_NUM < 0x300
#if MRPT_OPENCV_VERSION_NUM < 0x030000
ASSERT_(dest != nullptr);
*dest = cvIplImage(m_impl->img);
#else
Expand Down
8 changes: 4 additions & 4 deletions libs/vision/src/CFeatureExtraction_AKAZE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void CFeatureExtraction::extractFeaturesAKAZE(
mrpt::system::CTimeLoggerEntry tle(profiler, "extractFeaturesAKAZE");

#if MRPT_HAS_OPENCV
#if MRPT_OPENCV_VERSION_NUM < 0x300
#if MRPT_OPENCV_VERSION_NUM < 0x030000
THROW_EXCEPTION("This function requires OpenCV > 3.0.0");
#else

Expand All @@ -46,11 +46,11 @@ void CFeatureExtraction::extractFeaturesAKAZE(
// Make sure we operate on a gray-scale version of the image:
const CImage inImg_gray(inImg, FAST_REF_OR_CONVERT_TO_GRAY);

#if MRPT_OPENCV_VERSION_NUM >= 0x300
#if MRPT_OPENCV_VERSION_NUM >= 0x030000

Mat theImg = inImg_gray.asCvMat<Mat>(SHALLOW_COPY);
Ptr<AKAZE> akaze = AKAZE::create(
#if MRPT_OPENCV_VERSION_NUM >= 0x400
#if MRPT_OPENCV_VERSION_NUM >= 0x040000
static_cast<cv::AKAZE::DescriptorType>(
options.AKAZEOptions.descriptor_type),
#else
Expand All @@ -60,7 +60,7 @@ void CFeatureExtraction::extractFeaturesAKAZE(
options.AKAZEOptions.descriptor_channels,
options.AKAZEOptions.threshold, options.AKAZEOptions.nOctaves,
options.AKAZEOptions.nOctaveLayers,
#if MRPT_OPENCV_VERSION_NUM >= 0x400
#if MRPT_OPENCV_VERSION_NUM >= 0x040000
static_cast<cv::KAZE::DiffusivityType>(options.AKAZEOptions.diffusivity)
#else
options.AKAZEOptions.diffusivity
Expand Down
2 changes: 1 addition & 1 deletion libs/vision/src/CFeatureExtraction_FAST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void CFeatureExtraction::extractFeaturesFAST(
const CImage inImg_gray(inImg, FAST_REF_OR_CONVERT_TO_GRAY);
const Mat theImg = inImg_gray.asCvMat<cv::Mat>(SHALLOW_COPY);

#if MRPT_OPENCV_VERSION_NUM < 0x300
#if MRPT_OPENCV_VERSION_NUM < 0x030000
FastFeatureDetector fastDetector(
options.FASTOptions.threshold, options.FASTOptions.nonmax_suppression);
fastDetector.detect(theImg, cv_feats);
Expand Down
4 changes: 2 additions & 2 deletions libs/vision/src/CFeatureExtraction_ORB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void CFeatureExtraction::extractFeaturesORB(
// The detector and descriptor
profiler.enter("extractFeaturesORB.openCV_detectAndCompute");

#if MRPT_OPENCV_VERSION_NUM < 0x300
#if MRPT_OPENCV_VERSION_NUM < 0x030000
Ptr<Feature2D> orb = Algorithm::create<Feature2D>("Feature2D.ORB");
orb->operator()(cvImg, Mat(), cv_feats, cv_descs, use_precomputed_feats);
#else
Expand Down Expand Up @@ -250,7 +250,7 @@ void CFeatureExtraction::internal_computeORBDescriptors(
const Mat& cvImg = inImg_gray.asCvMatRef();
Mat cv_descs;

#if MRPT_OPENCV_VERSION_NUM < 0x300
#if MRPT_OPENCV_VERSION_NUM < 0x030000
Ptr<Feature2D> orb = Algorithm::create<Feature2D>("Feature2D.ORB");
orb->operator()(
cvImg, cv::noArray(), cv_feats, cv_descs,
Expand Down
12 changes: 6 additions & 6 deletions libs/vision/src/CFeatureExtraction_SIFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <opencv2/nonfree/nonfree.hpp>
#endif
#ifdef HAVE_OPENCV_FEATURES2D
#if MRPT_OPENCV_VERSION_NUM >= 0x300
#if MRPT_OPENCV_VERSION_NUM >= 0x030000
#include <opencv2/features2d.hpp>
#else
#include <opencv2/features2d/features2d.hpp>
Expand Down Expand Up @@ -71,9 +71,9 @@ void CFeatureExtraction::extractFeaturesSIFT(

// in opencv 4.4 SIFT got into the main repo
#if defined(HAVE_OPENCV_NONFREE) || defined(HAVE_OPENCV_XFEATURES2D) || \
(MRPT_OPENCV_VERSION_NUM >= 0x440)
(MRPT_OPENCV_VERSION_NUM >= 0x040400)

#if MRPT_OPENCV_VERSION_NUM < 0x300
#if MRPT_OPENCV_VERSION_NUM < 0x030000
SiftFeatureDetector SIFTDetector(
options.SIFTOptions.threshold, options.SIFTOptions.edgeThreshold);

Expand All @@ -84,11 +84,11 @@ void CFeatureExtraction::extractFeaturesSIFT(
Mat desc;
SIFTDescriptor.compute(theImg, cv_feats, desc);
#else
// MRPT_OPENCV_VERSION_NUM >= 0x300
// MRPT_OPENCV_VERSION_NUM >= 0x030000
using namespace cv;
vector<KeyPoint> cv_feats;

#if MRPT_OPENCV_VERSION_NUM >= 0x440
#if MRPT_OPENCV_VERSION_NUM >= 0x040400
using sift_t = cv::SIFT;
#else
using sift_t = cv::xfeatures2d::SIFT;
Expand Down Expand Up @@ -180,7 +180,7 @@ void CFeatureExtraction::internal_computeSiftDescriptors(
ASSERT_(options.SIFTOptions.implementation == OpenCV);

// in opencv 4.4 SIFT got into the main repo
#if MRPT_OPENCV_VERSION_NUM >= 0x440
#if MRPT_OPENCV_VERSION_NUM >= 0x040400
using namespace cv;
vector<KeyPoint> cv_feats;

Expand Down
7 changes: 4 additions & 3 deletions libs/vision/src/CFeatureExtraction_SURF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ using namespace std;

// Was: MRPT_HAS_OPENCV_NONFREE
#if defined(HAVE_OPENCV_XFEATURES2D) || \
(MRPT_OPENCV_VERSION_NUM < 0x300 && MRPT_OPENCV_VERSION_NUM >= 0x240)
(MRPT_OPENCV_VERSION_NUM < 0x030000 && \
MRPT_OPENCV_VERSION_NUM >= 0x020400)
#define HAVE_OPENCV_WITH_SURF 1
#else
#define HAVE_OPENCV_WITH_SURF 0
Expand All @@ -56,7 +57,7 @@ void CFeatureExtraction::extractFeaturesSURF(

// gb redesign start -make sure that the Algorithm::create is used only for
// older openCV versions
#if MRPT_OPENCV_VERSION_NUM < 0x300 && MRPT_OPENCV_VERSION_NUM >= 0x240
#if MRPT_OPENCV_VERSION_NUM < 0x030000 && MRPT_OPENCV_VERSION_NUM >= 0x020400

Ptr<Feature2D> surf = Algorithm::create<Feature2D>("Feature2D.SURF");
if (surf.empty())
Expand Down Expand Up @@ -181,7 +182,7 @@ void CFeatureExtraction::internal_computeSurfDescriptors(

// Only computes the descriptors:
// gb redesign
#if MRPT_OPENCV_VERSION_NUM < 0x300 && MRPT_OPENCV_VERSION_NUM >= 0x240
#if MRPT_OPENCV_VERSION_NUM < 0x030000 && MRPT_OPENCV_VERSION_NUM >= 0x020400

Ptr<Feature2D> surf = Algorithm::create<Feature2D>("Feature2D.SURF");
if (surf.empty())
Expand Down
Loading

0 comments on commit 9ba4481

Please sign in to comment.