图像识别之特征点检测

'''
    特征点检测:
        常用特征点检测有:STAR特征点检测 / SIFT特征点检测
        特征点检测结合了边缘检测与角点检测从而识别出图形的特征点。
        STAR特征点检测相关API如下:
            import cv2 as cv
            # 创建STAR特征点检测器
            star = cv.xfeatures2d.StarDetector_create()
            # 检测出gray图像所有的特征点
            keypoints = star.detect(gray)
            # drawKeypoints方法可以把所有的特征点绘制在mixture图像中
            cv.drawKeypoints(original, keypoints, mixture,
                             flags=cv.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
            cv.imshow('Mixture', mixture)
'''
import cv2 as cv

original = cv.imread('./ml_data/table.jpg')
cv.imshow('Original', original)
gray = cv.cvtColor(original, cv.COLOR_BGR2GRAY)
cv.imshow('Gray', gray)
# 创建特征点检测器
star = cv.xfeatures2d.StarDetector_create()
keypoints = star.detect(gray)
mixture = original.copy()
cv.drawKeypoints(original, keypoints, mixture, flags=cv.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
cv.imshow('Mixture', mixture)

cv.waitKey()

 

'''
    特征点检测:
        常用特征点检测有:STAR特征点检测 / SIFT特征点检测
        特征点检测结合了边缘检测与角点检测从而识别出图形的特征点。
        STAR特征点检测相关API如下:
            import cv2 as cv
            # 创建STAR特征点检测器
            star = cv.xfeatures2d.StarDetector_create()
            # 检测出gray图像所有的特征点
            keypoints = star.detect(gray)
            # drawKeypoints方法可以把所有的特征点绘制在mixture图像中
            cv.drawKeypoints(original, keypoints, mixture,
                             flags=cv.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
            cv.imshow('Mixture', mixture)
'''
import cv2 as cv

original = cv.imread('./ml_data/table.jpg')
cv.imshow('Original', original)
gray = cv.cvtColor(original, cv.COLOR_BGR2GRAY)
cv.imshow('Gray', gray)
# 创建特征点检测器
sift = cv.xfeatures2d.SIFT_create()
keypoints = sift.detect(gray)
mixture = original.copy()
cv.drawKeypoints(original, keypoints, mixture, flags=cv.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
cv.imshow('Mixture', mixture)

cv.waitKey()

 

posted @ 2019-07-28 10:16  一如年少模样  阅读(2356)  评论(0编辑  收藏  举报