Skip to content

Commit 18267ee

Browse files
authored
Merge pull request #5 from Kotochleb/bugfix/change-m3t-upstream
Update CMakeLists.txt to account for forked M3T
2 parents c170be6 + 956913e commit 18267ee

File tree

3 files changed

+38
-15
lines changed

3 files changed

+38
-15
lines changed

CMakeLists.txt

+16-5
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,23 @@ cmake_minimum_required(VERSION 3.11)
22
project(pym3t LANGUAGES CXX)
33

44
option(USE_AZURE_KINECT "Use Azure Kinect" OFF)
5-
option(USE_REALSENSE "Use RealSense D435" ON)
5+
option(USE_REALSENSE "Use RealSense D435" OFF)
66
option(USE_GTEST "Use gtest" OFF)
7+
option(USE_XFEATURES2D "Use OpenCV xfeatures2d" OFF)
78

8-
cmake_policy(SET CMP0148 OLD) # required for current pybind11
9+
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.27.0")
10+
cmake_policy(SET CMP0148 OLD) # required for current pybind11
11+
endif()
912

10-
# set(CMAKE_BUILD_TYPE "RELEASE") set(CMAKE_BUILD_TYPE "DEBUG")
13+
# Fix this error:
14+
# /usr/bin/ld: libm3t_ext.a(dummy_camera.cpp.o): relocation R_X86_64_PC32 against symbol
15+
# `_ZSt4cerr@@GLIBCXX_3.4' can not be used when making a shared object; recompile with -fPIC
16+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
17+
18+
IF(USE_REALSENSE)
19+
ADD_DEFINITIONS(-DPYM3T_WITH_REALSENSE)
20+
LIST(APPEND CFLAGS_DEPENDENCIES "-DPYM3T_WITH_REALSENSE")
21+
ENDIF(USE_REALSENSE)
1122

1223
include(FetchContent)
1324
FetchContent_Declare(
@@ -16,10 +27,10 @@ FetchContent_Declare(
1627
GIT_TAG "v2.11.1")
1728
FetchContent_Declare(
1829
m3t
19-
GIT_REPOSITORY "https://github.com/DLR-RM/3DObjectTracking.git"
30+
GIT_REPOSITORY "https://github.com/agimus-project/3DObjectTracking"
2031
GIT_TAG "master"
2132
SOURCE_SUBDIR "M3T" CMAKE_ARGS "-DUSE_AZURE_KINECT=${USE_AZURE_KINECT}"
22-
"-DUSE_REALSENSE=${USE_REALSENSE}" "-DUSE_GTEST=${USE_GTEST}")
33+
"-DUSE_REALSENSE=${USE_REALSENSE}" "-DUSE_GTEST=${USE_GTEST}" "-DUSE_XFEATURES2D=${USE_XFEATURES2D}")
2334
FetchContent_MakeAvailable(pybind11 m3t)
2435

2536
# Create library for the extensions to m3t

src/pym3t.cpp

+14-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
// M3T
1515
#include <m3t/common.h>
1616
#include <m3t/camera.h>
17+
18+
#ifdef PYM3T_WITH_REALSENSE
1719
#include <m3t/realsense_camera.h>
20+
#endif
21+
1822
#include <m3t/renderer_geometry.h>
1923
#include <m3t/basic_depth_renderer.h>
2024
#include <m3t/silhouette_renderer.h>
@@ -38,13 +42,6 @@ using namespace pybind11::literals; // to use "arg"_a shorthand
3842
using namespace m3t;
3943
using namespace Eigen;
4044

41-
/**
42-
* TODO:
43-
* - Read the flag USE_REALSENSE to decide whether or not to create bindings
44-
* */
45-
46-
47-
4845
PYBIND11_MODULE(_pym3t_mod, m) {
4946

5047
// Tracker: main interface with m3t
@@ -119,6 +116,7 @@ PYBIND11_MODULE(_pym3t_mod, m) {
119116
// DepthCamera -> not constructible, just to enable automatic downcasting and binding of child classes
120117
py::class_<DepthCamera, Camera, std::shared_ptr<DepthCamera>>(m, "DepthCamera");
121118

119+
#ifdef PYM3T_WITH_REALSENSE
122120
// RealSenseColorCamera
123121
py::class_<RealSenseColorCamera, ColorCamera, std::shared_ptr<RealSenseColorCamera>>(m, "RealSenseColorCamera")
124122
.def(py::init<const std::string &, bool>(), "name"_a, "use_depth_as_world_frame"_a=false)
@@ -128,6 +126,7 @@ PYBIND11_MODULE(_pym3t_mod, m) {
128126
py::class_<RealSenseDepthCamera, DepthCamera, std::shared_ptr<RealSenseDepthCamera>>(m, "RealSenseDepthCamera")
129127
.def(py::init<const std::string &, bool>(), "name"_a, "use_color_as_world_frame"_a=true)
130128
;
129+
#endif
131130

132131
// DummyColorCamera
133132
py::class_<DummyColorCamera, ColorCamera, std::shared_ptr<DummyColorCamera>>(m, "DummyColorCamera")
@@ -444,4 +443,12 @@ PYBIND11_MODULE(_pym3t_mod, m) {
444443
.def_property("tikhonov_parameter_translation", &Optimizer::tikhonov_parameter_translation, &Optimizer::set_tikhonov_parameter_translation)
445444
;
446445

446+
// Constants
447+
m.attr("WITH_REALSENSE") =
448+
#ifdef PYM3T_WITH_REALSENSE
449+
py::bool_(true);
450+
#else
451+
py::bool_(false);
452+
#endif
453+
447454
}

src/pym3t/__init__.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from ._pym3t_mod import Tracker
22
from ._pym3t_mod import RendererGeometry
3-
from ._pym3t_mod import RealSenseColorCamera, RealSenseDepthCamera
43
from ._pym3t_mod import Intrinsics, IDType
54
from ._pym3t_mod import DummyColorCamera, DummyDepthCamera
65
from ._pym3t_mod import NormalColorViewer, NormalDepthViewer
@@ -10,10 +9,13 @@
109
from ._pym3t_mod import RegionModel, DepthModel
1110
from ._pym3t_mod import RegionModality, DepthModality, TextureModality
1211
from ._pym3t_mod import Optimizer
12+
from ._pym3t_mod import WITH_REALSENSE
13+
14+
if WITH_REALSENSE:
15+
from ._pym3t_mod import RealSenseColorCamera, RealSenseDepthCamera
1316

1417
__all__ = ['Tracker',
15-
'RendererGeometry',
16-
'RealSenseColorCamera', 'RealSenseDepthCamera',
18+
'RendererGeometry',
1719
'Intrinsics', 'IDType',
1820
'DummyColorCamera', 'DummyDepthCamera',
1921
'NormalColorViewer', 'NormalDepthViewer',
@@ -23,3 +25,6 @@
2325
'RegionModel', 'DepthModel',
2426
'RegionModality', 'DepthModality', 'TextureModality'
2527
'Optimizer',]
28+
29+
if WITH_REALSENSE:
30+
__all__.append(['RealSenseColorCamera', 'RealSenseDepthCamera'])

0 commit comments

Comments
 (0)