summaryrefslogtreecommitdiff
path: root/aruco-markers.spec
blob: 64e7b7acc2de3a3c566094891b7ffd5fdb2718dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
%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:        3%{?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:  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}
# OpenCV 4.5.x API 兼容性修复:
# 1. opencv2/aruco/dictionary.hpp 是 4.6+ 新路径,4.5.x 统一在 opencv2/aruco.hpp
sed -i 's|#include <opencv2/aruco/dictionary\.hpp>|#include <opencv2/aruco.hpp>|g' \
    aruco_markers/include/aruco_markers/utils.hpp
# 2. PREDEFINED_DICTIONARY_NAME 在 4.5.x 中是匿名枚举(底层 int),不能作为类型名
sed -i 's|cv::aruco::PREDEFINED_DICTIONARY_NAME|int|g' \
    aruco_markers/include/aruco_markers/utils.hpp \
    aruco_markers/include/aruco_markers/aruco_markers.hpp \
    aruco_markers/src/utils.cpp
# 3. DetectorParameters::create() 在 4.5.x 中不存在,使用 cv::makePtr 构造
sed -i 's|cv::aruco::DetectorParameters::create()|cv::makePtr<cv::aruco::DetectorParameters>()|g' \
    aruco_markers/src/aruco_markers.cpp
# 4. detectMarkers 4.5.x 签名无 camera_matrix/camera_distortion 参数(后两个可选参数已移除)
python3 -c "
import re, sys
src = open('aruco_markers/src/aruco_markers.cpp').read()
src = re.sub(
    r'cv::aruco::detectMarkers\(\s*image,\s*aruco_dict_,\s*marker_corners,\s*marker_ids,\s*aruco_parameters_,\s*rejected_candidates,\s*camera_matrix_,\s*camera_distortion_\);',
    'cv::aruco::detectMarkers(\n      image, aruco_dict_, marker_corners, marker_ids, aruco_parameters_,\n      rejected_candidates);',
    src)
open('aruco_markers/src/aruco_markers.cpp', 'w').write(src)
"
# 5. drawAxis 在 4.5.x 中已更名为 drawFrameAxes
python3 -c "
import re, sys
src = open('aruco_markers/src/aruco_markers.cpp').read()
src = re.sub(
    r'cv::aruco::drawAxis\(\s*image,\s*camera_matrix_,\s*camera_distortion_,\s*rvec,\s*tvec,\s*marker_size_\s*\*\s*0\.7f\);',
    'cv::aruco::drawFrameAxes(\n          image, camera_matrix_, camera_distortion_, rvec, tvec,\n          marker_size_ * 0.7f);',
    src)
open('aruco_markers/src/aruco_markers.cpp', 'w').write(src)
"

%build
source /opt/ros/%{ros_distro}/setup.sh 2>/dev/null || 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
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
source /opt/ros/%{ros_distro}/setup.sh 2>/dev/null || 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
* Fri Sep 19 2026 ai-importer <ai-importer@openeuler.org> - 0.0.3-3
- Fix full OpenCV 4.5.x API incompatibilities: replace PREDEFINED_DICTIONARY_NAME
  type usage with int, DetectorParameters::create() with cv::makePtr, remove
  extra detectMarkers args, replace drawAxis with drawFrameAxes

* Fri Sep 19 2026 ai-importer <ai-importer@openeuler.org> - 0.0.3-2
- Fix build failure: replace opencv2/aruco/dictionary.hpp with opencv2/aruco.hpp
  to be compatible with OpenCV 4.5.x available in openEuler 24.03 LTS SP3

* Fri Sep 19 2026 ai-importer <ai-importer@openeuler.org> - 0.0.3-1
- Initial import (ROS batch)