1import cv2 as cv
2import numpy as np
3
4img = cv.imread('qiqiao.jpg')
5gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
6
7# Shi-Tomasi corner detection
8corners = cv.goodFeaturesToTrack(gray, 12, 0.01, 10)
9corners = np.int0(corners) # 12 corner coordinates
10
11for i in corners:
12 # Compressed to one dimension: [[62,64]]->[62,64]
13 x, y = i.ravel()
14 cv.circle(img, (x, y), 4, (0, 0, 255), -1)
15
16cv.imshow('dst', img)
17cv.waitKey(0)
181234567891011121314151617