opencv 增強現實(一):特征點檢測
阿新 • • 發佈:2019-02-26
技術 blank awk reat issues point 一個 open points
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 增強現實(一):特征點檢測