本文整理汇总了Python中cv2.ORB_create方法的典型用法代码示例。如果您正苦于以下问题:Python cv2.ORB_create方法的具体用法?Python cv2.ORB_create怎么用?Python cv2.ORB_create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cv2
的用法示例。
在下文中一共展示了cv2.ORB_create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import ORB_create [as 别名]
def __init__(self, fe_conf: feature_extractor_conf.Default_feature_extractor_conf):
# STD attributes
self.fe_conf: feature_extractor_conf.Default_feature_extractor_conf = fe_conf
self.logger = logging.getLogger(__name__)
self.logger.info("Creation of a Picture BoW Orber")
self.algo = cv2.ORB_create(nfeatures=fe_conf.ORB_KEYPOINTS_NB)
# TODO : Dictionnary path / Vocabulary
self.bow_descriptor = cv2.BOWImgDescriptorExtractor(self.algo, cv2.BFMatcher(cv2.NORM_HAMMING))
self.vocab_loaded = False
try :
vocab = BoWOrb_Vocabulary_Creator.load_vocab_from_file(fe_conf.BOW_VOCAB_PATH)
self.bow_descriptor.setVocabulary(vocab)
self.vocab_loaded = True
except Exception as e :
self.logger.error(f"No vocabulary file provided. Not possible to use Bow-ORB : {e}")
示例2: test_pickle_import_export_ORB
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import ORB_create [as 别名]
def test_pickle_import_export_ORB(self):
algo = cv2.ORB_create(nfeatures=10)
img = cv2.imread(str(self.test_file_path / "original.bmp"), 0)
# compute the descriptors with ORB
kp, des = algo.detectAndCompute(img, None)
self.logger.debug(f"Keypoints : {kp}")
self.logger.debug(f"Example of Keypoint")
pickler = pickle_import_export.Pickler()
self.logger.debug("Save to pickle ... ")
pc = pickler.get_pickle_from_object(kp)
self.logger.debug("Load from pickle ... ")
kp2 = pickler.get_object_from_pickle(pc)
for i, k in enumerate(kp):
self.assertEqual(kp[i].response, kp2[i].response)
self.assertEqual(kp[i].angle, kp2[i].angle)
self.assertEqual(kp[i].class_id, kp2[i].class_id)
self.assertEqual(kp[i].octave, kp2[i].octave)
self.assertEqual(kp[i].pt, kp2[i].pt)
self.assertEqual(kp[i].size, kp2[i].size)
示例3: compute_orb_keypoints
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import ORB_create [as 别名]
def compute_orb_keypoints(filename):
"""
Reads image from filename and computes ORB keypoints
Returns image, keypoints and descriptors.
"""
# load image
img = cv2.imread(filename)
# create orb object
orb = cv2.ORB_create()
# set parameters
orb.setScoreType(cv2.FAST_FEATURE_DETECTOR_TYPE_9_16)
orb.setWTA_K(3)
# detect keypoints
kp = orb.detect(img,None)
# for detected keypoints compute descriptors.
kp, des = orb.compute(img, kp)
return img,kp, des
示例4: compute_orb_keypoints
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import ORB_create [as 别名]
def compute_orb_keypoints(filename):
"""
Takes in filename to read and computes ORB keypoints
Returns image, keypoints and descriptors
"""
img = cv2.imread(filename)
# create orb object
orb = cv2.ORB_create()
# set parameters
orb.setScoreType(cv2.FAST_FEATURE_DETECTOR_TYPE_9_16)
orb.setWTA_K(3)
kp = orb.detect(img,None)
kp, des = orb.compute(img, kp)
return img,kp, des
示例5: compute_orb_keypoints
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import ORB_create [as 别名]
def compute_orb_keypoints(filename):
"""
Takes in filename to read and computes ORB keypoints
Returns image, keypoints and descriptors
"""
img = cv2.imread(filename)
img = cv2.pyrDown(img)
img = cv2.pyrDown(img)
# img = cv2.pyrDown(img)
# img = cv2.pyrDown(img)
# create orb object
orb = cv2.ORB_create()
# set parameters
orb.setScoreType(cv2.FAST_FEATURE_DETECTOR_TYPE_9_16)
orb.setWTA_K(3)
kp = orb.detect(img,None)
kp, des = orb.compute(img, kp)
return img,kp, des
示例6: compute_orb_keypoints
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import ORB_create [as 别名]
def compute_orb_keypoints(filename):
"""
Reads image from filename and computes ORB keypoints
Returns image, keypoints and descriptors.
"""
# load image
img = cv2.imread(filename)
# create orb object
orb = cv2.ORB_create()
# set parameters
orb.setScoreType(cv2.FAST_FEATURE_DETECTOR_TYPE_9_16)
orb.setWTA_K(3)
# detect keypoints
kp = orb.detect(img,None)
# for detected keypoints compute descriptors.
kp, des = orb.compute(img, kp)
return img,kp, des
示例7: make_detector
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import ORB_create [as 别名]
def make_detector(self):
global detector
detector_node = getNode('/config/detector', True)
if detector_node.getString('detector') == 'SIFT':
max_features = detector_node.getInt('sift_max_features')
#detector = cv2.xfeatures2d.SIFT_create(nfeatures=max_features)
detector = cv2.xfeatures2d.SIFT_create()
elif detector_node.getString('detector') == 'SURF':
threshold = detector_node.getFloat('surf_hessian_threshold')
nOctaves = detector_node.getInt('surf_noctaves')
detector = cv2.xfeatures2d.SURF_create(hessianThreshold=threshold, nOctaves=nOctaves)
elif detector_node.getString('detector') == 'ORB':
max_features = detector_node.getInt('orb_max_features')
detector = cv2.ORB_create(max_features)
elif detector_node.getString('detector') == 'Star':
maxSize = detector_node.getInt('star_max_size')
responseThreshold = detector_node.getInt('star_response_threshold')
lineThresholdProjected = detector_node.getInt('star_line_threshold_projected')
lineThresholdBinarized = detector_node.getInt('star_line_threshold_binarized')
suppressNonmaxSize = detector_node.getInt('star_suppress_nonmax_size')
detector = cv2.xfeatures2d.StarDetector_create(maxSize, responseThreshold, lineThresholdProjected, lineThresholdBinarized, suppressNonmaxSize)
示例8: extractFeatures
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import ORB_create [as 别名]
def extractFeatures(img):
orb = cv2.ORB_create()
# detection
pts = cv2.goodFeaturesToTrack(np.mean(img, axis=2).astype(np.uint8), 3000, qualityLevel=0.01, minDistance=7)
# extraction
kps = [cv2.KeyPoint(x=f[0][0], y=f[0][1], _size=20) for f in pts]
kps, des = orb.compute(img, kps)
# return pts and des
return np.array([(kp.pt[0], kp.pt[1]) for kp in kps]), des
示例9: __init__
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import ORB_create [as 别名]
def __init__(self):
self.detector = cv2.ORB_create( nfeatures = 1000 )
self.matcher = cv2.FlannBasedMatcher(flann_params, {}) # bug : need to pass empty dict (#1329)
self.targets = []
self.frame_points = []
示例10: init_feature
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import ORB_create [as 别名]
def init_feature(name):
chunks = name.split('-')
if chunks[0] == 'sift':
detector = cv2.xfeatures2d.SIFT_create()
norm = cv2.NORM_L2
elif chunks[0] == 'surf':
detector = cv2.xfeatures2d.SURF_create(800)
norm = cv2.NORM_L2
elif chunks[0] == 'orb':
detector = cv2.ORB_create(400)
norm = cv2.NORM_HAMMING
elif chunks[0] == 'akaze':
detector = cv2.AKAZE_create()
norm = cv2.NORM_HAMMING
elif chunks[0] == 'brisk':
detector = cv2.BRISK_create()
norm = cv2.NORM_HAMMING
else:
return None, None
if 'flann' in chunks:
if norm == cv2.NORM_L2:
flann_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5)
else:
flann_params= dict(algorithm = FLANN_INDEX_LSH,
table_number = 6, # 12
key_size = 12, # 20
multi_probe_level = 1) #2
matcher = cv2.FlannBasedMatcher(flann_params, {}) # bug : need to pass empty dict (#1329)
else:
matcher = cv2.BFMatcher(norm)
return detector, matcher
示例11: __init__
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import ORB_create [as 别名]
def __init__(self, *_, **__):
super().__init__(*_, **__)
self._orb = cv2.ORB_create()
示例12: find_key_points
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import ORB_create [as 别名]
def find_key_points(image,
edgeThreshold=34,
nFeatures=100000,
nLevels=7,
patchSize=34,
**kwargs):
''' Initiate detector and find key points on an image
Parameters
----------
image : 2D UInt8 Numpy array - image
edgeThreshold : int - parameter for OpenCV detector
nFeatures : int - parameter for OpenCV detector
nLevels : int - parameter for OpenCV detector
patchSize : int - parameter for OpenCV detector
Returns
-------
keyPoints : list - coordinates of keypoint on image
descriptors : list - binary descriptos of kepoints
'''
if cv2.__version__.startswith('3.') or cv2.__version__.startswith('4.'):
detector = cv2.ORB_create()
detector.setEdgeThreshold(edgeThreshold)
detector.setMaxFeatures(nFeatures)
detector.setNLevels(nLevels)
detector.setPatchSize(patchSize)
else:
detector = cv2.ORB()
detector.setInt('edgeThreshold', edgeThreshold)
detector.setInt('nFeatures', nFeatures)
detector.setInt('nLevels', nLevels)
detector.setInt('patchSize', patchSize)
print('ORB detector initiated')
keyPoints, descriptors = detector.detectAndCompute(image, None)
print('Key points found: %d' % len(keyPoints))
return keyPoints, descriptors
示例13: init_detector
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import ORB_create [as 别名]
def init_detector(self):
"""Init keypoint detector object."""
self.detector = cv2.ORB_create()
# create BFMatcher object:
self.matcher = cv2.BFMatcher(cv2.NORM_HAMMING) # cv2.NORM_L1 cv2.NORM_L2 cv2.NORM_HAMMING(not useable)
示例14: get_interest_point_list
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import ORB_create [as 别名]
def get_interest_point_list(self, *args, **kwargs) -> typing.List[cv2.KeyPoint]:
""" find key points with ORB engine """
p = self.screen_shot_to_object()
orb = cv2.ORB_create(*args, **kwargs)
return orb.detect(p, None)
示例15: get_descriptors
# 需要导入模块: import cv2 [as 别名]
# 或者: from cv2 import ORB_create [as 别名]
def get_descriptors(self, filename="original.bmp"):
self.algo = cv2.ORB_create(nfeatures=10)
orb_pic = cv2.imread(str(self.test_file_path / filename), 0)
key_points, descriptors = self.algo.detectAndCompute(orb_pic, None)
return key_points, descriptors