%define ros_distro humble %define RosPkgName aruco-markers %define src_version 0.0.3-1 Name: ros-%{ros_distro}-%{RosPkgName} Version: 0.0.3 Release: 5%{?dist} Summary: A ros2 node for detecting aruco markers in camera images License: MIT URL: https://github.com/namo-robotics/aruco_markers/tree/humble Source0: %{RosPkgName}-%{src_version}.tar.gz %global debug_package %{nil} %global __os_install_post %(echo '%{__os_install_post}' | sed -e 's!/usr/lib[^[:space:]]*/brp-python-bytecompile[[:space:]].*$!!g') %global __provides_exclude_from ^/opt/ros/%{ros_distro}/.*$ %global __requires_exclude_from ^/opt/ros/%{ros_distro}/.*$ BuildRequires: cmake BuildRequires: gcc-c++ BuildRequires: ros-%{ros_distro}-ament-cmake BuildRequires: ros-%{ros_distro}-cv-bridge BuildRequires: ros-%{ros_distro}-geometry-msgs BuildRequires: ros-%{ros_distro}-image-transport BuildRequires: ros-%{ros_distro}-sensor-msgs BuildRequires: ros-%{ros_distro}-tf2-geometry-msgs BuildRequires: ros-%{ros_distro}-tf2-ros BuildRequires: ros-%{ros_distro}-aruco-markers-msgs BuildRequires: opencv Requires: ros-%{ros_distro}-ros-workspace Requires: ros-%{ros_distro}-ament-cmake Requires: ros-%{ros_distro}-cv-bridge Requires: ros-%{ros_distro}-geometry-msgs Requires: ros-%{ros_distro}-image-transport Requires: ros-%{ros_distro}-sensor-msgs Requires: ros-%{ros_distro}-tf2-geometry-msgs Requires: ros-%{ros_distro}-tf2-ros Requires: ros-%{ros_distro}-aruco-markers-msgs Requires: opencv Provides: %{name}-devel = %{version}-%{release} Provides: %{name}-doc = %{version}-%{release} Provides: %{name}-runtime = %{version}-%{release} %description A ros2 node for detecting aruco markers in camera images %prep %autosetup -n %{RosPkgName}-%{src_version} # openEuler opencv 4.5.2 lacks the aruco contrib module; bundle from opencv_contrib 4.5.2 # Remove aruco component (bundled) but add calib3d (was transitively pulled by aruco) sed -i 's/find_package(OpenCV REQUIRED COMPONENTS core imgproc aruco)/find_package(OpenCV REQUIRED COMPONENTS core imgproc calib3d)/' aruco_markers/CMakeLists.txt # Replace catch-all with specific includes to prevent # system OpenCV 4.8+ objdetect aruco headers (new API) from being pulled in # and conflicting with bundled 4.5.x aruco (old API). Code only uses core, # imgproc (line/putText/FONT_HERSHEY_SIMPLEX) and calib3d (Rodrigues/projectPoints). sed -i 's|#include |#include \n#include \n#include |' aruco_markers/include/aruco_markers/aruco_markers.hpp %build [ -f /opt/ros/%{ros_distro}/setup.sh ] && source /opt/ros/%{ros_distro}/setup.sh || true export PYTHONPATH=/opt/ros/%{ros_distro}/lib/python%{python3_version}/site-packages${PYTHONPATH:+:$PYTHONPATH} export PKG_CONFIG_PATH=/opt/ros/%{ros_distro}/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH} # Build bundled opencv_contrib aruco module as static library # openEuler opencv 4.8+ has aruco in mainline with new API that shadows bundled # old API 4.5.x headers; put bundled include path FIRST to avoid shadowing. # Skip charuco.cpp: project does not use CharucoBoard, and it uses old API # (CharucoBoard::create/ids/chessboardCorners/draw) incompatible with system core. ARUCO_DIR=%{_builddir}/%{RosPkgName}-%{src_version}/opencv_contrib_aruco ARUCO_BUILD=%{_builddir}/aruco_build ARUCO_INC=%{_builddir}/aruco_include mkdir -p "$ARUCO_BUILD" "$ARUCO_INC/opencv2/aruco" cd "$ARUCO_BUILD" g++ -c -O2 -g -fPIC -std=c++14 \ -I"$ARUCO_DIR/include" \ -I"$ARUCO_DIR/src" \ -I/usr/include/opencv4 \ "$ARUCO_DIR/src/aruco.cpp" \ "$ARUCO_DIR/src/dictionary.cpp" \ "$ARUCO_DIR/src/apriltag_quad_thresh.cpp" \ "$ARUCO_DIR/src/zmaxheap.cpp" ar rcs libaruco_contrib.a *.o rm -f *.o cp "$ARUCO_DIR/include/opencv2/aruco.hpp" "$ARUCO_INC/opencv2/" cp "$ARUCO_DIR/include/opencv2/aruco/"*.hpp "$ARUCO_INC/opencv2/aruco/" # Mask system OpenCV 4.8+ objdetect aruco headers (new API) to prevent # conflict with bundled 4.5.x aruco (old API). opencv2/opencv.hpp (included # transitively by cv_bridge etc.) pulls in objdetect/aruco_detector.hpp etc. # which define cv::aruco::* types with new API that clash with bundled old API. # Emptying them lets bundled aruco.hpp be the sole definition source. for f in /usr/include/opencv4/opencv2/objdetect/aruco_detector.hpp \ /usr/include/opencv4/opencv2/objdetect/aruco_dictionary.hpp \ /usr/include/opencv4/opencv2/objdetect/aruco_board.hpp \ /usr/include/opencv4/opencv2/objdetect/charuco_detector.hpp; do [ -f "$f" ] && cp "$f" "$f.bak" && echo "// masked: using bundled aruco 4.5.x" > "$f" || true done # Patch CMakeLists.txt to use bundled aruco headers and static library # BEFORE keyword ensures bundled include path takes precedence over system OpenCV export ARUCO_INC ARUCO_DIR ARUCO_BUILD cd %{_builddir}/%{RosPkgName}-%{src_version}/aruco_markers python3 << 'PYEOF' import os inc = os.environ["ARUCO_INC"] src_dir = os.environ["ARUCO_DIR"] + "/src" lib = os.environ["ARUCO_BUILD"] + "/libaruco_contrib.a" with open("CMakeLists.txt") as f: c = f.read() c = c.replace( "target_link_libraries(aruco_markers_lib ${OpenCV_LIBRARIES})", "target_link_libraries(aruco_markers_lib ${OpenCV_LIBRARIES} " + lib + ")\n" "target_include_directories(aruco_markers_lib BEFORE PUBLIC " + inc + " " + src_dir + ")" ) c = c.replace( "target_link_libraries(aruco_markers aruco_markers_lib ${OpenCV_LIBRARIES})", "target_link_libraries(aruco_markers aruco_markers_lib ${OpenCV_LIBRARIES} " + lib + ")\n" "target_include_directories(aruco_markers BEFORE PUBLIC " + inc + " " + src_dir + ")" ) with open("CMakeLists.txt", "w") as f: f.write(c) PYEOF mkdir -p .obj && cd .obj %cmake3 \ -DCMAKE_INSTALL_PREFIX="/opt/ros/%{ros_distro}" \ -DAMENT_PREFIX_PATH="/opt/ros/%{ros_distro}" \ -DCMAKE_PREFIX_PATH="/opt/ros/%{ros_distro}" \ -UINCLUDE_INSTALL_DIR -ULIB_INSTALL_DIR -USYSCONF_INSTALL_DIR -USHARE_INSTALL_PREFIX -ULIB_SUFFIX \ -DSETUPTOOLS_DEB_LAYOUT=OFF \ -DBUILD_TESTING=OFF -DTESTING=OFF -DCMAKE_SUPPRESS_REGENERATION=ON \ .. make %{?_smp_mflags} %install [ -f /opt/ros/%{ros_distro}/setup.sh ] && source /opt/ros/%{ros_distro}/setup.sh || true export PYTHONPATH=/opt/ros/%{ros_distro}/lib/python%{python3_version}/site-packages${PYTHONPATH:+:$PYTHONPATH} export PKG_CONFIG_PATH=/opt/ros/%{ros_distro}/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH} cd aruco_markers cd .obj make install DESTDIR=%{buildroot} %files /opt/ros/%{ros_distro} %changelog * Mon Oct 12 2026 ai-importer - 0.0.3-5 - Add calib3d to find_package(OpenCV COMPONENTS) to resolve linker errors (projectPoints/solvePnP/calibrateCamera/Rodrigues/drawFrameAxes/undistortPoints/findHomography) caused by removing aruco component which transitively pulled calib3d * Mon Oct 12 2026 ai-importer - 0.0.3-4 - Replace catch-all with specific includes (core/imgproc/calib3d) - Mask system objdetect/aruco_*.hpp headers to prevent new/old API conflict * Mon Oct 12 2026 ai-importer - 0.0.3-3 - Fix include path ordering: bundled aruco headers before system OpenCV - Skip charuco.cpp compilation (project does not use CharucoBoard) - Add BEFORE keyword to cmake target_include_directories * Mon Oct 12 2026 ai-importer - 0.0.3-2 - Bundle opencv_contrib 4.5.2 aruco module (openEuler opencv lacks it) * Mon Oct 12 2026 ai-importer - 0.0.3-1 - Initial import (ROS batch)