Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
PythonRBExtensions.py
1
2
from
pathlib
import
Path
3
import
json
4
5
from
visp.rbt
import
RBTracker
6
7
from
visp.python.rbt.xfeat
import
RBXFeatFeatureTracker, XFeatVisualOdometry, XFeatTrackingBackend
8
9
10
class
PythonRBExtensions
():
11
'''
12
This class is used to keep references to Python created types:
13
If we do not do so, Python loses track of Python types that override C++ types
14
and "slices" them back to pure cpp objects when calling eg. tracker.getOdometryMethod()
15
'''
16
def
__init__
(self):
17
self.
xfeat_backend
= XFeatTrackingBackend(4096, 0.8)
18
self.
extensions
= []
19
20
def
parse_python_extensions
(self, tracker: RBTracker, json_path: Path):
21
22
with
open(json_path,
'r'
)
as
json_file:
23
json_dict = json.load(json_file)
24
25
if
"python_ext"
not
in
json_dict:
26
print(
'No python extension found'
)
27
return
28
29
python_extensions = json_dict[
'python_ext'
]
30
# XFeat backend is a special case for a Python extension:
31
# Visual odometry and RBXfeatTracker.
32
# Since both depend on the same feature extraction,
33
# we use the same backend to run extraction only once.
34
if
'xfeat'
in
python_extensions:
35
self.
xfeat_backend
.load_settings(python_extensions[
'xfeat'
])
36
37
if
'odometry'
in
python_extensions:
38
vo = XFeatVisualOdometry(self.
xfeat_backend
)
39
vo.load_settings(python_extensions[
'odometry'
])
40
tracker.setOdometryMethod(vo)
41
self.
extensions
.append(vo)
42
43
if
'features'
in
python_extensions:
44
features_json = python_extensions[
'features'
]
45
assert
isinstance(features_json, list)
46
for
fj
in
features_json:
47
if
fj[
'type'
] ==
'xfeat'
:
48
xfeat = RBXFeatFeatureTracker(self.
xfeat_backend
)
49
xfeat.load_settings(fj)
50
self.
extensions
.append(xfeat)
51
tracker.addTracker(xfeat)
visp.python.rbt.PythonRBExtensions.PythonRBExtensions
Definition
PythonRBExtensions.py:10
visp.python.rbt.PythonRBExtensions.PythonRBExtensions.__init__
__init__(self)
Definition
PythonRBExtensions.py:16
visp.python.rbt.PythonRBExtensions.PythonRBExtensions.xfeat_backend
xfeat_backend
Definition
PythonRBExtensions.py:17
visp.python.rbt.PythonRBExtensions.PythonRBExtensions.extensions
list extensions
Definition
PythonRBExtensions.py:18
visp.python.rbt.PythonRBExtensions.PythonRBExtensions.parse_python_extensions
parse_python_extensions(self, RBTracker tracker, Path json_path)
Definition
PythonRBExtensions.py:20
visp.python.rbt.xfeat
Definition
__init__.py:1
modules
python
bindings
visp
python
rbt
PythonRBExtensions.py
Generated by
1.17.0