Skip to content

Commit

Permalink
Add missing trampolines
Browse files Browse the repository at this point in the history
  • Loading branch information
SamFlt committed Oct 15, 2024
1 parent dc306ad commit 656d4c9
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modules/python/bindings/include/rbt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@

#include "rbt/feature_tracker.hpp"
#include "rbt/vo.hpp"
#include "rbt/drift.hpp"
#include "rbt/mask.hpp"




Expand Down
67 changes: 67 additions & 0 deletions modules/python/bindings/include/rbt/drift.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@

#ifndef VISP_PYTHON_RBT_DRIFT_HPP
#define VISP_PYTHON_RBT_DRIFT_HPP

#include <visp3/rbt/vpRBDriftDetector.h>
#include <pybind11/pybind11.h>


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<vpRGBa> &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
50 changes: 50 additions & 0 deletions modules/python/bindings/include/rbt/mask.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

#ifndef VISP_PYTHON_RBT_MASK_HPP
#define VISP_PYTHON_RBT_MASK_HPP

#include <visp3/rbt/vpObjectMask.h>
#include <visp3/core/vpImage.h>
#include <pybind11/pybind11.h>


class TrampolineObjectMask : public vpObjectMask
{
public:
using vpObjectMask::vpObjectMask;

TrampolineObjectMask() : vpObjectMask() { }

virtual void updateMask(const vpRBFeatureTrackerInput &frame,
const vpRBFeatureTrackerInput &previousFrame,
vpImage<float> &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<float> &mask, vpImage<unsigned char> &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
6 changes: 6 additions & 0 deletions modules/python/config/rbt.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@
"vpRBVisualOdometry": {
"trampoline": "TrampolineRBVisualOdometry"
},
"vpRBDriftDetector": {
"trampoline": "TrampolineRBDriftDetector"
},
"vpObjectMask": {
"trampoline": "TrampolineObjectMask"
},
"vpObjectCentricRenderer": {
"methods": [
{
Expand Down

0 comments on commit 656d4c9

Please sign in to comment.