rtabmap_oanet.py
Go to the documentation of this file.
1 #! /usr/bin/env python3
2 #
3 # Drop this file in the "demo" folder of OANet git: https://github.com/zjhthu/OANet
4 # To use with rtabmap:
5 # --Vis/CorNNType 6 --PyMatcher/Path ~/OANet/demo/rtabmap_oanet.py --PyMatcher/Model ~/OANet/model/gl3d/sift-4000/model_best.pth
6 #
7 
8 import sys
9 import os
10 sys.path.append(os.path.dirname(os.path.realpath(__file__))+'/../core')
11 if not hasattr(sys, 'argv'):
12  sys.argv = ['']
13 
14 #print(os.sys.path)
15 #print(sys.version)
16 
17 import numpy as np
18 from learnedmatcher import LearnedMatcher
19 
20 lm = None
21 
22 def init(descriptorDim, matchThreshold, iterations, cuda, model_path):
23  print("OANet python init()")
24  global lm
25  lm = LearnedMatcher(model_path, inlier_threshold=1, use_ratio=0, use_mutual=0)
26 
27 
28 def match(kptsFrom, kptsTo, scoresFrom, scoresTo, descriptorsFrom, descriptorsTo, imageWidth, imageHeight):
29  #print("OANet python match()")
30 
31  kpt1 = np.asarray(kptsFrom)
32  kpt2 = np.asarray(kptsTo)
33  desc1 = np.asarray(descriptorsFrom)
34  desc2 = np.asarray(descriptorsTo)
35 
36  global lm
37  matches, _, _ = lm.infer([kpt1, kpt2], [desc1, desc2])
38  return matches
39 
40 
41 if __name__ == '__main__':
42  #test
43  init(128, 0.2, 20, False, True)
44  match([[1, 2], [1,3], [4,6]], [[1, 3], [1,2], [16,2]], [1, 3,6], [1,3,5], np.full((3, 128), 1), np.full((3, 128), 1), 640, 480)
def init(descriptorDim, matchThreshold, iterations, cuda, model_path)
def match(kptsFrom, kptsTo, scoresFrom, scoresTo, descriptorsFrom, descriptorsTo, imageWidth, imageHeight)


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Jan 23 2023 03:37:30