Skip to content

Commit b502765

Browse files
committed
progress porting mrpt_img
1 parent 7fddcb6 commit b502765

File tree

11 files changed

+150
-91
lines changed

11 files changed

+150
-91
lines changed

CMakeLists.txt.old

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ include(${MRPT_SOURCE_DIR}/cmakemodules/DeclareAppDependencies.cmake REQUIRED)
8383
include(${MRPT_SOURCE_DIR}/cmakemodules/script_detect_unix_arch.cmake REQUIRED) # Detect machine architecture, on UNIX
8484
# --------------------------
8585

86-
# Put these deps here for global visibility:
87-
include(${MRPT_SOURCE_DIR}/cmakemodules/script_opencv.cmake REQUIRED) # Check for the OpenCV libraries (via pkg-config, CMake, with different options)
8886

8987

9088
# Avoid the need for DLL export/import macros in Windows:
@@ -127,11 +125,6 @@ include(FindPkgConfig OPTIONAL)
127125
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
128126
set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
129127

130-
#-----------------------------------
131-
# Build with MRPT-MEX compatibility?
132-
#-----------------------------------
133-
set(MRPT_WITH_MATLAB_WRAPPER OFF CACHE BOOL "Build with compatibility options for MEX wrapper?.")
134-
135128
# GCC only:
136129
# ===================================================
137130
if(CMAKE_COMPILER_IS_GNUCXX)
@@ -185,7 +178,6 @@ include(${MRPT_SOURCE_DIR}/cmakemodules/script_SIMD.cmake REQUIRED) # SSE
185178
include(${MRPT_SOURCE_DIR}/cmakemodules/script_gcc_clang_id.cmake REQUIRED) # Helper variables
186179
include(${MRPT_SOURCE_DIR}/cmakemodules/script_gtest.cmake REQUIRED) # Unit testing lib
187180

188-
include(${MRPT_SOURCE_DIR}/cmakemodules/script_matlab.cmake REQUIRED) # Support for Matlab MEX functions generation
189181
include(${MRPT_SOURCE_DIR}/cmakemodules/script_python_bindings.cmake REQUIRED) # Support for python
190182

191183
include(${MRPT_SOURCE_DIR}/cmakemodules/process_emscripten_embedded_files.cmake REQUIRED)
@@ -195,8 +187,6 @@ include(${MRPT_SOURCE_DIR}/cmakemodules/process_emscripten_embedded_files.cmake
195187
# OPTIONS
196188
#The options for the user when using "cmakesetup" or "ccmake":
197189
# ---------------------------------------------------------------------------
198-
# Include Asian fonts in CMRPTCanvas ?
199-
set( MRPT_HAS_ASIAN_FONTS ON CACHE BOOL "Enable Asian fonts in CMRPTCanvas (increases library size).")
200190

201191
include(${MRPT_SOURCE_DIR}/cmakemodules/script_declare_defines.cmake REQUIRED) # Transform the variables MRPT_XXX="ON/OFF" to CMAKE_MRPT_XXX="1/0"
202192

@@ -482,9 +472,6 @@ if(MRPT_BUILD_APPLICATIONS)
482472
add_subdirectory(apps) # The applications:
483473
endif()
484474

485-
if(MRPT_WITH_MATLAB_WRAPPER)
486-
add_subdirectory(mex/apps)# The MEX applications
487-
endif()
488475

489476
# Generate .h to locate MRPT sources:
490477
configure_file(

cmakemodules/script_gcc_clang_id.cmake

Lines changed: 0 additions & 15 deletions
This file was deleted.

modules/mrpt_common/cmake/mrpt_cmake_functions.cmake

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -415,17 +415,39 @@ macro(keep_matching_files_from_list match_expr lst_files)
415415
set(${lst_files} ${lst_files_aux})
416416
endmacro()
417417

418+
# Rely on CMake to detect target system architecture:
419+
# ---------------------------------------------------------
420+
SET(CMAKE_MRPT_ARCH ${CMAKE_SYSTEM_PROCESSOR})
421+
if(UNIX)
422+
execute_process(COMMAND uname -s
423+
OUTPUT_VARIABLE CMAKE_MRPT_KERNEL
424+
OUTPUT_STRIP_TRAILING_WHITESPACE)
425+
if ($ENV{VERBOSE})
426+
message(STATUS "Kernel name (uname -s): ${CMAKE_MRPT_KERNEL}")
427+
endif()
428+
endif()
429+
430+
# Detect if we are in i386 / amd64:
431+
# Intel arch names in Linux & Windows.
432+
if (("${CMAKE_MRPT_ARCH}" MATCHES "^(x86_64|i686|AMD64|IA64|x86)$") AND (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Emscripten"))
433+
set(MRPT_ARCH_INTEL_COMPATIBLE 1)
434+
else()
435+
set(MRPT_ARCH_INTEL_COMPATIBLE 0)
436+
endif()
437+
438+
418439
# handle_special_simd_flags(): Add custom flags to a set of source files
419440
# Only for Intel-compatible archs
420441
#-----------------------------------------------------------------------
421442
function(handle_special_simd_flags lst_files FILE_PATTERN FLAGS_TO_ADD)
422-
if (MRPT_COMPILER_IS_GCC_OR_CLANG AND MRPT_ARCH_INTEL_COMPATIBLE)
423-
set(_lst ${lst_files})
424-
KEEP_MATCHING_FILES_FROM_LIST(${FILE_PATTERN} _lst)
425-
if(NOT "${_lst}" STREQUAL "")
426-
set_source_files_properties(${_lst} PROPERTIES COMPILE_FLAGS "${FLAGS_TO_ADD}")
427-
endif()
428-
endif()
443+
if (MRPT_COMPILER_IS_GCC_OR_CLANG AND MRPT_ARCH_INTEL_COMPATIBLE)
444+
set(_lst ${lst_files})
445+
keep_matching_files_from_list(${FILE_PATTERN} _lst)
446+
if(NOT "${_lst}" STREQUAL "")
447+
message(STATUS "Adding special flags ${FLAGS_TO_ADD} to ${_lst}")
448+
set_source_files_properties(${_lst} PROPERTIES COMPILE_FLAGS "${FLAGS_TO_ADD}")
449+
endif()
450+
endif()
429451
endfunction()
430452

431453

modules/mrpt_core/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ find_package(Threads REQUIRED)
1919

2020
include(./cmake/bfd.cmake REQUIRED)
2121
include(./cmake/detect_functions_headers.cmake REQUIRED)
22-
include(./cmake/detect_unix_arch.cmake REQUIRED)
2322
include(./cmake/detect_word_size.cmake REQUIRED)
2423
include(./cmake/exceptions_and_backtraces.cmake REQUIRED)
2524
include(./cmake/max_alignment.cmake REQUIRED)
@@ -28,6 +27,12 @@ include(./cmake/tbb.cmake REQUIRED)
2827

2928
include(./cmake/script_create_version_h.cmake REQUIRED)
3029

30+
set(MRPT_WITH_MATLAB_WRAPPER OFF CACHE BOOL "Build with compatibility options for MEX wrapper?.")
31+
include(./cmake/script_matlab.cmake REQUIRED) # Support for Matlab MEX functions generation
32+
#if(MRPT_WITH_MATLAB_WRAPPER)
33+
# add_subdirectory(mex/apps)# The MEX applications
34+
#endif()
35+
3136

3237
# define lib:
3338
set(LIB_SRCS

modules/mrpt_core/cmake/detect_unix_arch.cmake

Lines changed: 0 additions & 20 deletions
This file was deleted.

modules/mrpt_img/CMakeLists.txt

Lines changed: 84 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,86 @@
1-
# TODO: Consider using just opencv writers?
2-
include(${MRPT_SOURCE_DIR}/cmakemodules/script_jpeg.cmake REQUIRED) # Check for jpeg
3-
4-
5-
define_mrpt_lib(
6-
img # Lib name
7-
# Dependencies:
8-
mrpt-io
9-
mrpt-math
10-
mrpt-config
11-
)
12-
13-
if(BUILD_mrpt-img)
14-
# Ignore precompiled headers in some sources:
15-
if(MRPT_ENABLE_PRECOMPILED_HDRS)
16-
if (MSVC)
17-
set_source_files_properties(
18-
${img/jpeglib_FILES}
19-
PROPERTIES COMPILE_FLAGS "/Y-"
20-
)
21-
endif ()
22-
endif()
23-
24-
if(CMAKE_MRPT_HAS_OPENCV)
25-
target_link_libraries(img PRIVATE opencv_core )#imp_opencv)
26-
endif()
27-
if(CMAKE_MRPT_HAS_JPEG)
28-
if(NOT CMAKE_MRPT_HAS_JPEG_SYSTEM)
29-
add_dependencies(img JPEG)
30-
endif()
31-
target_link_libraries(img PRIVATE ${JPEG_LIBRARIES})
32-
endif()
1+
# ------------------------------------------------------------------------------
2+
# Mobile Robot Programming Toolkit (MRPT)
3+
#
4+
# Copyright (c) 2005-2025, Jose Luis Blanco-Claraco, contributors (see Git history)
5+
# All rights reserved.
6+
# Released under BSD-3 license. See LICENSE file
7+
# ------------------------------------------------------------------------------
338

9+
cmake_minimum_required(VERSION 3.16)
10+
11+
# Tell CMake we'll use C++ for use in its tests/flags
12+
project(mrpt_img LANGUAGES C CXX)
13+
14+
# MRPT CMake scripts: "mrpt_xxx()"
15+
find_package(mrpt_common REQUIRED)
16+
find_package(mrpt_io REQUIRED)
17+
find_package(mrpt_config REQUIRED)
18+
find_package(mrpt_math REQUIRED)
19+
20+
include(./cmake/script_jpeg.cmake REQUIRED) # Check for jpeg
21+
include(./cmake/script_opencv.cmake REQUIRED) # Check for the OpenCV libraries (via pkg-config, CMake, with different options)
22+
23+
24+
# Include Asian fonts in CMRPTCanvas ?
25+
set(MRPT_HAS_ASIAN_FONTS ON CACHE BOOL "Enable Asian fonts in CMRPTCanvas (increases library size).")
26+
27+
# define lib:
28+
set(LIB_SRCS
29+
src/CCanvas.cpp
30+
src/CEnhancedMetaFile.cpp
31+
src/CImage.cpp
32+
src/CImage_JPEG_streams.cpp
33+
src/CImage_loadXPM.cpp
34+
src/CImage.SSE2.cpp
35+
src/CImage.SSSE3.cpp
36+
src/CImage_unittest.cpp
37+
src/CMappedImage.cpp
38+
src/color_maps.cpp
39+
src/color_maps_unittest.cpp
40+
src/img-precomp.cpp
41+
src/registerAllClasses.cpp
42+
src/TCamera.cpp
43+
src/TCamera_unittest.cpp
44+
src/TColor.cpp
45+
src/TColorManager.cpp
46+
src/TStereoCamera.cpp
47+
)
48+
49+
set(LIB_PUBLIC_HDRS
50+
include/mrpt/3rdparty/do_opencv_includes.h
51+
include/mrpt/img/CCanvas.h
52+
include/mrpt/img/CImage.h
53+
include/mrpt/img/CEnhancedMetaFile.h
54+
include/mrpt/img/DistortionModel.h
55+
include/mrpt/img/registerAllClasses.h
56+
include/mrpt/img/TStereoCamera.h
57+
include/mrpt/img/TColor.h
58+
include/mrpt/img/CMappedImage.h
59+
include/mrpt/img/TColorManager.h
60+
include/mrpt/img/TCamera.h
61+
include/mrpt/img/color_maps.h
62+
include/mrpt/img/TPixelCoord.h
63+
)
64+
65+
mrpt_add_library(
66+
TARGET ${PROJECT_NAME}
67+
SOURCES ${LIB_SRCS} ${LIB_PUBLIC_HDRS}
68+
PUBLIC_LINK_LIBRARIES
69+
mrpt::mrpt_config
70+
mrpt::mrpt_io
71+
mrpt::mrpt_math
72+
PRIVATE_LINK_LIBRARIES
73+
imp_opencv
74+
${JPEG_LIBRARIES}
75+
CMAKE_DEPENDENCIES
76+
mrpt_config
77+
mrpt_io
78+
mrpt_math
79+
# Other imported targets:
80+
)
81+
82+
if(CMAKE_MRPT_HAS_JPEG)
83+
if(NOT CMAKE_MRPT_HAS_JPEG_SYSTEM)
84+
add_dependencies(${PROJECT_NAME} JPEG)
85+
endif()
3486
endif()

cmakemodules/script_opencv.cmake renamed to modules/mrpt_img/cmake/script_opencv.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ if(NOT CMAKE_MRPT_HAS_OPENCV)
2323
if(OpenCV_FOUND)
2424
set(MRPT_OPENCV_VERSION ${OpenCV_VERSION})
2525
set(CMAKE_MRPT_HAS_OPENCV 1)
26-
2726
endif()
2827
endif()
2928

modules/mrpt_img/package.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<!-- This is a ROS package file, intended to allow this library to be built
4+
side-by-side to ROS packages in a catkin/ament environment.
5+
-->
6+
<package format="3">
7+
<name>mrpt_img</name>
8+
<version>2.20.0</version>
9+
<description>The MRPT C++ library mrpt_img</description>
10+
11+
<maintainer email="joseluisblancoc@gmail.com">Jose-Luis Blanco-Claraco</maintainer>
12+
<license file="LICENSE">BSD</license>
13+
14+
<url type="website">https://github.com/MRPT/</url>
15+
16+
<!-- BUILD TOOLS -->
17+
<buildtool_depend>cmake</buildtool_depend>
18+
19+
<depend>mrpt_common</depend>
20+
<depend>mrpt_io</depend>
21+
<depend>mrpt_config</depend>
22+
<depend>mrpt_math</depend>
23+
24+
<export>
25+
<build_type>cmake</build_type>
26+
</export>
27+
28+
</package>

modules/mrpt_img/src/CImage.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "img-precomp.h" // Precompiled headers
1111
//
12+
#include <mrpt/core/config.h> // MRPT_HAS_MATLAB
1213
#include <mrpt/core/cpu.h>
1314
#include <mrpt/core/get_env.h>
1415
#include <mrpt/core/round.h> // for round()
@@ -958,7 +959,7 @@ bool my_img_to_grayscale(const cv::Mat& src, cv::Mat& dest)
958959
if (dest.size() != src.size() || dest.type() != src.type())
959960
dest = cv::Mat(src.rows, src.cols, CV_8UC1);
960961

961-
// If possible, use SSE optimized version:
962+
// If possible, use SSE optimized version:
962963
#if MRPT_ARCH_INTEL_COMPATIBLE
963964
if ((src.step[0] & 0x0f) == 0 && (dest.step[0] & 0x0f) == 0 &&
964965
mrpt::cpu::supports(mrpt::cpu::feature::SSSE3))
@@ -1081,7 +1082,7 @@ void CImage::loadFromMemoryBuffer(
10811082
*(dest++) = *(srcG++);
10821083
*(dest++) = *(srcR++);
10831084
} // end of x
1084-
} // end of y
1085+
} // end of y
10851086

10861087
MRPT_END
10871088
#endif

0 commit comments

Comments
 (0)