diff --git a/modules/python/bindings/include/rbt.hpp b/modules/python/bindings/include/rbt.hpp index b918ec0826..293729d423 100644 --- a/modules/python/bindings/include/rbt.hpp +++ b/modules/python/bindings/include/rbt.hpp @@ -37,6 +37,9 @@ #include "rbt/feature_tracker.hpp" #include "rbt/vo.hpp" +#include "rbt/drift.hpp" +#include "rbt/mask.hpp" + diff --git a/modules/python/bindings/include/rbt/drift.hpp b/modules/python/bindings/include/rbt/drift.hpp new file mode 100644 index 0000000000..e478b3e5ff --- /dev/null +++ b/modules/python/bindings/include/rbt/drift.hpp @@ -0,0 +1,67 @@ + +#ifndef VISP_PYTHON_RBT_DRIFT_HPP +#define VISP_PYTHON_RBT_DRIFT_HPP + +#include +#include + + +class TrampolineRBDriftDetector : public vpRBDriftDetector +{ +public: + using vpRBDriftDetector::vpRBDriftDetector; + + TrampolineRBDriftDetector() : vpRBDriftDetector() { } + + virtual void update(const vpRBFeatureTrackerInput &previousFrame, const vpRBFeatureTrackerInput &frame, const vpHomogeneousMatrix &cTo, const vpHomogeneousMatrix &cprevTo) + { + pybind11::gil_scoped_acquire gil; // Acquire the GIL while in this scope. + // Try to look up the overridden method on the Python side. + pybind11::function override = pybind11::get_override(this, "update"); + if (override) { // method is found + // Pybind seems to copy the frames, so we pass the pointers + override(&previousFrame, &frame, &cTo, &cprevTo); + } + } + + virtual double getScore() const VP_OVERRIDE + { + PYBIND11_OVERRIDE_PURE( + double, /* Return type */ + vpRBDriftDetector, /* Parent class */ + getScore, /* Name of function in C++ (must match Python name) */ + ); + } + + virtual bool hasDiverged() const VP_OVERRIDE + { + PYBIND11_OVERRIDE_PURE( + double, /* Return type */ + vpRBDriftDetector, /* Parent class */ + hasDiverged, /* Name of function in C++ (must match Python name) */ + ); + } + + virtual void display(const vpImage &I) VP_OVERRIDE + { + PYBIND11_OVERRIDE_PURE( + void, /* Return type */ + vpRBDriftDetector, /* Parent class */ + display, /* Name of function in C++ (must match Python name) */ + I + ); + } + + +#if defined(VISP_HAVE_NLOHMANN_JSON) + virtual void loadJsonConfiguration(const nlohmann::json &) VP_OVERRIDE + { + + } +#endif + +}; + + + +#endif diff --git a/modules/python/bindings/include/rbt/mask.hpp b/modules/python/bindings/include/rbt/mask.hpp new file mode 100644 index 0000000000..0499c3b19c --- /dev/null +++ b/modules/python/bindings/include/rbt/mask.hpp @@ -0,0 +1,50 @@ + +#ifndef VISP_PYTHON_RBT_MASK_HPP +#define VISP_PYTHON_RBT_MASK_HPP + +#include +#include +#include + + +class TrampolineObjectMask : public vpObjectMask +{ +public: + using vpObjectMask::vpObjectMask; + + TrampolineObjectMask() : vpObjectMask() { } + + virtual void updateMask(const vpRBFeatureTrackerInput &frame, + const vpRBFeatureTrackerInput &previousFrame, + vpImage &mask) VP_OVERRIDE + { + pybind11::gil_scoped_acquire gil; // Acquire the GIL while in this scope. + // Try to look up the overridden method on the Python side. + pybind11::function override = pybind11::get_override(this, "updateMask"); + if (override) { // method is found + // Pybind seems to copy the frames, so we pass the pointers + override(&frame, &previousFrame, &mask); + } + } + + virtual void display(const vpImage &mask, vpImage &Imask) const VP_OVERRIDE + { + PYBIND11_OVERRIDE_PURE( + void, /* Return type */ + vpObjectMask, /* Parent class */ + display, /* Name of function in C++ (must match Python name) */ + mask, Imask + ); + } + +#if defined(VISP_HAVE_NLOHMANN_JSON) + virtual void loadJsonConfiguration(const nlohmann::json &) VP_OVERRIDE + { + + } +#endif +}; + + + +#endif diff --git a/modules/python/config/rbt.json b/modules/python/config/rbt.json index de5ff591aa..fb024e4adc 100644 --- a/modules/python/config/rbt.json +++ b/modules/python/config/rbt.json @@ -267,6 +267,12 @@ "vpRBVisualOdometry": { "trampoline": "TrampolineRBVisualOdometry" }, + "vpRBDriftDetector": { + "trampoline": "TrampolineRBDriftDetector" + }, + "vpObjectMask": { + "trampoline": "TrampolineObjectMask" + }, "vpObjectCentricRenderer": { "methods": [ {