Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CMakeLists.txt to account for forked M3T #5

Merged
merged 5 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,23 @@ cmake_minimum_required(VERSION 3.11)
project(pym3t LANGUAGES CXX)

option(USE_AZURE_KINECT "Use Azure Kinect" OFF)
option(USE_REALSENSE "Use RealSense D435" ON)
option(USE_REALSENSE "Use RealSense D435" OFF)
option(USE_GTEST "Use gtest" OFF)
option(USE_XFEATURES2D "Use OpenCV xfeatures2d" OFF)

cmake_policy(SET CMP0148 OLD) # required for current pybind11
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.27.0")
cmake_policy(SET CMP0148 OLD) # required for current pybind11
endif()

# set(CMAKE_BUILD_TYPE "RELEASE") set(CMAKE_BUILD_TYPE "DEBUG")
# Fix this error:
# /usr/bin/ld: libm3t_ext.a(dummy_camera.cpp.o): relocation R_X86_64_PC32 against symbol
# `_ZSt4cerr@@GLIBCXX_3.4' can not be used when making a shared object; recompile with -fPIC
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

IF(USE_REALSENSE)
ADD_DEFINITIONS(-DPYM3T_WITH_REALSENSE)
LIST(APPEND CFLAGS_DEPENDENCIES "-DPYM3T_WITH_REALSENSE")
ENDIF(USE_REALSENSE)

include(FetchContent)
FetchContent_Declare(
Expand All @@ -16,10 +27,10 @@ FetchContent_Declare(
GIT_TAG "v2.11.1")
FetchContent_Declare(
m3t
GIT_REPOSITORY "https://github.com/DLR-RM/3DObjectTracking.git"
GIT_REPOSITORY "https://github.com/agimus-project/3DObjectTracking"
GIT_TAG "master"
SOURCE_SUBDIR "M3T" CMAKE_ARGS "-DUSE_AZURE_KINECT=${USE_AZURE_KINECT}"
"-DUSE_REALSENSE=${USE_REALSENSE}" "-DUSE_GTEST=${USE_GTEST}")
"-DUSE_REALSENSE=${USE_REALSENSE}" "-DUSE_GTEST=${USE_GTEST}" "-DUSE_XFEATURES2D=${USE_XFEATURES2D}")
FetchContent_MakeAvailable(pybind11 m3t)

# Create library for the extensions to m3t
Expand Down
21 changes: 14 additions & 7 deletions src/pym3t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@
// M3T
#include <m3t/common.h>
#include <m3t/camera.h>

#ifdef PYM3T_WITH_REALSENSE
#include <m3t/realsense_camera.h>
#endif

#include <m3t/renderer_geometry.h>
#include <m3t/basic_depth_renderer.h>
#include <m3t/silhouette_renderer.h>
Expand All @@ -38,13 +42,6 @@ using namespace pybind11::literals; // to use "arg"_a shorthand
using namespace m3t;
using namespace Eigen;

/**
* TODO:
* - Read the flag USE_REALSENSE to decide whether or not to create bindings
* */



PYBIND11_MODULE(_pym3t_mod, m) {

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

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

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

// Constants
m.attr("WITH_REALSENSE") =
#ifdef PYM3T_WITH_REALSENSE
py::bool_(true);
#else
py::bool_(false);
#endif

}
11 changes: 8 additions & 3 deletions src/pym3t/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from ._pym3t_mod import Tracker
from ._pym3t_mod import RendererGeometry
from ._pym3t_mod import RealSenseColorCamera, RealSenseDepthCamera
from ._pym3t_mod import Intrinsics, IDType
from ._pym3t_mod import DummyColorCamera, DummyDepthCamera
from ._pym3t_mod import NormalColorViewer, NormalDepthViewer
Expand All @@ -10,10 +9,13 @@
from ._pym3t_mod import RegionModel, DepthModel
from ._pym3t_mod import RegionModality, DepthModality, TextureModality
from ._pym3t_mod import Optimizer
from ._pym3t_mod import WITH_REALSENSE

if WITH_REALSENSE:
from ._pym3t_mod import RealSenseColorCamera, RealSenseDepthCamera

__all__ = ['Tracker',
'RendererGeometry',
'RealSenseColorCamera', 'RealSenseDepthCamera',
'RendererGeometry',
'Intrinsics', 'IDType',
'DummyColorCamera', 'DummyDepthCamera',
'NormalColorViewer', 'NormalDepthViewer',
Expand All @@ -23,3 +25,6 @@
'RegionModel', 'DepthModel',
'RegionModality', 'DepthModality', 'TextureModality'
'Optimizer',]

if WITH_REALSENSE:
__all__.append(['RealSenseColorCamera', 'RealSenseDepthCamera'])
Loading