opencv チュートリアルチャンレンジ 43 Shi-Tomasiのコーナー検出とGood Features to Track(追跡に向いた特徴)

Shi-Tomasiのコーナー検出とGood Features to Track(追跡に向いた特徴) — OpenCV-Python Tutorials 1 documentation

#!/usr/bin/env python
# -*- coding: utf-8 -*
import sys
import cv2
import numpy as np

img = cv2.imread('170523-170301.jpg')
#img = cv2.imread('170519-174830.jpg')
#img = cv2.imread('170519-144402.jpg')
#img = cv2.imread('chessboard.jpg')

gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

corners = cv2.goodFeaturesToTrack(gray, 25, 0.01, 10)
corners = np.int0(corners)

for i in corners:
    x,y = i.ravel()
    cv2.circle(img, (x,y), 3, [0,0,255], -1)

cv2.imshow('goodFeaturesToTrack',img)
cv2.imwrite('goodFeaturesToTrack.png',img)

cv2.waitKey(0)
cv2.destroyAllWindows()

f:id:pongsuke:20170524140823p:plain