Opencv之Shi-tomas拐角检测器和益于跟踪的特征

文章目录

  • 1 理论
  • 2 测试图像
  • 3 代码

1 理论

  与哈夫角检测的不同在于计分公式:
R = m i n ( λ 1 , λ 2 ) R = min(\lambda_1, \lambda_2) R=min(λ1,λ2)

2 测试图像

Opencv之Shi-tomas拐角检测器和益于跟踪的特征_第1张图片

3 代码

# coding: utf-8
import cv2 as cv
import numpy as np


def test(file_name):
    """"""
    img = cv.imread(file_name)
    gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
    gray = np.float32(gray)
    corners = cv.goodFeaturesToTrack(gray, 1000, 0.01, 1)
    corners = np.int0(corners)
    for i in corners:
        x, y = i.ravel()
        cv.circle(img, (x, y), 3, 255, -1)
    cv.imshow("", img)
    cv.waitKey()


if __name__ == '__main__':
    file_name = "jimu.png"
    test(file_name)

  输出如下:
Opencv之Shi-tomas拐角检测器和益于跟踪的特征_第2张图片

你可能感兴趣的:(Python,Opencv,拐角检测,因吉)