get all possible corner using shi thomas cv2 code example

Example: get all possible corner using shi thomas cv2

import cv2 as cv
import numpy as np

img = cv.imread('qiqiao.jpg')
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)

# Shi-Tomasi corner detection
corners = cv.goodFeaturesToTrack(gray, 12, 0.01, 10)
corners = np.int0(corners)  # 12 corner coordinates

for i in corners:
    # Compressed to one dimension: [[62,64]]->[62,64]
    x, y = i.ravel()
    cv.circle(img, (x, y), 4, (0, 0, 255), -1)

cv.imshow('dst', img)
cv.waitKey(0)
1234567891011121314151617

Tags:

Misc Example