【CV学习6】OpenCV-Python: SURT Demo one
# -*-coding:utf-8-*- #author: lyp time: 2018/8/3 import cv2 import numpy as np img = cv2.imread('lyp.jpg') grayImg = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) surf = cv2.xfeatures2d.SURF_create(300, upright=True) kp, des = surf.detectAndCompute(grayImg, None) img2 = cv2.drawKeypoints(img, kp, None, (0, 255, 0), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS) cv2.imshow('SURF Image', img2) cv2.waitKey() cv2.destroyAllWindows()
0.函数讲解
retval=cv2.xfeatures2d.SURF_create([, hessianThreshold[, nOctaves[, nOctaveLayers[, extended[, upright]]]]])
hessianThreshold: H矩阵阀值,默认值是100, 大于该阀值的关键点将会被显示出来,推荐范围为300-500
extended: 是否扩展SURF描述维度,默认值是False,扩展时将计算128维度的扩展描述,否则默认计算64维度的描述(速度快)
upright:是否计算SURF描述的方向,默认值是False, 不计算则运行较快
keypoints=cv2.Feature2D.detect(image[, mask]) 关键点
keypoints, descriptors=cv2.Feature2D.compute(image, keypoints[, descriptors]) 特征描述向量
1.参考来自
小林的CV视觉工坊