opencv 增强现实(一):特征点检测

 

 1 import cv2 as cv
 2 import numpy as np
 3 
 4 
 5 def draw_keypoints(img, keypoints):
 6     for kp in keypoints:
 7         x, y = kp.pt
 8         cv.circle(img, (int(x), int(y)), 2, (0, 255, 0))
 9 
10 
11 img = cv.imread('D:/image/AR/moon.png')
12 gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
13 # 启动orb探测器
14 detector = cv.ORB_create()
15 
16 kp, des = detector.detectAndCompute(gray, None)
17 draw_keypoints(img=img, keypoints=kp)
18 cv.imshow('moon', img)
19 cv.waitKey(0)

之前用cv.drawKeypoints()报错,好像是版本问题,自定义一个函数来替换

https://github.com/skvark/opencv-python/issues/168

效果:

opencv 增强现实(一):特征点检测_第1张图片

 

你可能感兴趣的:(opencv 增强现实(一):特征点检测)