Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7057efc

Browse files
committed
update ch31
1 parent 1a22758 commit 7057efc

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed
Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,33 @@
1-
#-*-coding:utf8-*-#
1+
#-*-coding:utf8-*-#
22
__author__ = 'play4fun'
33
"""
44
create time:15-10-29 上午7:52
5-
"""
65
6+
使用 Shi-Tomasi 方法获取图像中 N 个最好的角点
7+
8+
常情况下 入的应 是灰度图像。然后确定你想 检测到的 点数目。再 置 点的 水平 0 到 1 之 。它代 了 点的最低 低于 个数的所有 点 会 忽略。最 后在 置两个角点之间的最短欧式距离。
9+
10+
所有低于 水平的 点 会 忽略。然后再把合格 点按 点 序排列。
11+
函数会 用 点 最 的 个 点 排序后的第一个 然后将它 最小 离之内 的 点 删掉。
12+
按着 样的方式最后 回 N 个最佳 点。
13+
14+
以后会发现这个函数很适合在目标跟踪中使用
15+
"""
716

817
import numpy as np
918
import cv2
1019
from matplotlib import pyplot as plt
1120

12-
1321
filename = '../data/corner-detection.jpg'
1422
img = cv2.imread(filename)
15-
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
23+
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
24+
25+
corners = cv2.goodFeaturesToTrack(gray, maxCorners=25, qualityLevel=0.01, minDistance=10)
1626

17-
corners = cv2.goodFeaturesToTrack(gray,25,0.01,10)
18-
#返回的结果是 [[ 311., 250.]] 两层括号的数组。
27+
# 返回的结果是 [[ 311., 250.]] 两层括号的数组。
1928
corners = np.int0(corners)
2029
for i in corners:
21-
x,y = i.ravel()
22-
cv2.circle(img,(x,y),3,255,-1)
23-
plt.imshow(img),plt.show()
30+
x, y = i.ravel()
31+
cv2.circle(img, (x, y), 3, 255, -1)
32+
33+
plt.imshow(img), plt.show()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /