fanfuhan OpenCV 教學094 ~ opencv-094-ORB之FAST特徵關鍵點檢測
fanfuhan OpenCV 教學094 ~ opencv-094-ORB之FAST特徵關鍵點檢測
資料來源: https://fanfuhan.github.io/
https://fanfuhan.github.io/2019/05/09/opencv-094/
GITHUB:https://github.com/jash-git/fanfuhan_ML_OpenCV
ORB-(定向快速且簡短的摘要)算法是基於FAST特徵檢測與BRIEF特徵描述子匹配實現,將BRIEF算法中的隨機方式獲取而值點對,ORB通過FAST方法,FAST方式查找特徵點方式假設灰度圖像預期點A周圍的預期存在連續大於或小於A的灰度值,選擇任意一個點P,假設尺寸為3,周圍16個表示表示。
C++
#include <opencv2/opencv.hpp> #include <iostream> using namespace cv; using namespace std; int main(int argc, char** argv) { Mat src = imread("D:/images/grad.png"); auto orb_detector = ORB::create(1000); vector<KeyPoint> kpts; orb_detector->detect(src, kpts); Mat result = src.clone(); drawKeypoints(src, kpts, result, Scalar::all(-1), DrawMatchesFlags::DEFAULT); imshow("ORB-detector", result); imwrite("D:/result.png", result); waitKey(0); return 0; }
Python
""" ORB之FAST特征关键点检测 """ import cv2 as cv src = cv.imread("images/test4.jpg") cv.imshow("input", src) orb = cv.ORB().create() kps = orb.detect(src) # opencv4 python版中好像没有 cv.drawKeypoints() # result = cv.drawKeypoints(src, kps, None, (0, 255, 0), cv.DrawMatchesFlags_DEFAULT) result = src.copy() for marker in kps: result = cv.drawMarker(src, tuple(int(i) for i in marker.pt), color=(0, 255, 0)) cv.imshow("result", result) cv.waitKey(0) cv.destroyAllWindows()