fanfuhan OpenCV 教學108 ~ opencv-108-特徵提取之關鍵點檢測(GFTTDetector)
fanfuhan OpenCV 教學108 ~ opencv-108-特徵提取之關鍵點檢測(GFTTDetector)
資料來源: https://fanfuhan.github.io/
https://fanfuhan.github.io/2019/05/22/opencv-108/
GITHUB:https://github.com/jash-git/fanfuhan_ML_OpenCV
該方法是基於shi-tomas角點檢測變化而來的一種特徵提取方法
C++
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv) {
Mat src = imread("D:/images/test1.png");
auto keypoint_detector = GFTTDetector::create(1000, 0.01, 1.0, 3, false, 0.04);
vector<KeyPoint> kpts;
keypoint_detector->detect(src, kpts);
Mat result = src.clone();
drawKeypoints(src, kpts, result, Scalar::all(-1), DrawMatchesFlags::DEFAULT);
imshow("GFTT-Keypoint-Detect", result);
imwrite("D:/result.png", result);
waitKey(0);
return 0;
}
Python
"""
特征提取之关键点检测(GFTTDetector)
"""
import cv2 as cv
image = cv.imread("images/test4.jpg")
cv.imshow("input", image)
# 创建GFTT特征检测器
gftt = cv.GFTTDetector_create(100, 0.01, 1, 3, False, 0.04)
kp1 = gftt.detect(image, None)
for marker in kp1:
result = cv.drawMarker(image, tuple(int(i) for i in marker.pt), color=(0, 255, 0))
cv.imshow("GFTT-Keypoint-Detect", result)
cv.waitKey(0)
cv.destroyAllWindows()