【opencv】角点检测

from email.mime import image
import imghdr
from turtle import title
import cv2
import matplotlib.pyplot as plt
import numpy as np

def cv_show(img,name):
    cv2.imshow(name,img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()

maxCorners = 100
qualityLevel = 0.01
minDistance = 10

img = cv2.imread('lena.jpg')
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
corners = cv2.goodFeaturesToTrack(gray, maxCorners, qualityLevel, minDistance)

corners = np.int0(corners)
for i in corners:
    x,y = i.ravel()
    cv2.circle(img,(x,y),2,(0,0,255),-1)

cv_show(img,'new_lena.jpg')
cv2.imwrite('new_lena.jpg', img)

【opencv】角点检测_第1张图片

【opencv】角点检测_第2张图片 

 

你可能感兴趣的:(opencv,opencv,计算机视觉,python)