美文网首页
9.7 Star检测器

9.7 Star检测器

作者: MaskStar | 来源:发表于2018-11-09 20:05 被阅读0次
# -*- coding:utf8 -*-
import cv2
import numpy as np

#加载图像
input_file = 'image/2.jpg'
img = cv2.imread(input_file)

#将图像转化为灰度图像
img_gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

# 显示图像
cv2.imshow('img',img)
cv2.imshow('img_gray',img_gray)

#定义一个类处理star特征检测相关的函数
class StarFeatureDetector(object):
    def __init__(self):
        self.detector = cv2.xfeatures2d.StarDetector_create()
    def detect(self, img):
        return self.detector.detect(img)

keypoints = StarFeatureDetector().detect(img)

cv2.drawKeypoints(img,keypoints,img,flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)

cv2.imshow('Star detect',img)
cv2.waitKey()

原图

原图

灰度图

灰度图

Start detect

Start detect

相关文章

网友评论

      本文标题:9.7 Star检测器

      本文链接:https://www.haomeiwen.com/subject/nrxaxqtx.html