-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters