Skip to content

Commit 4a97075

Browse files
committed
fix all
1 parent f5e6d58 commit 4a97075

File tree

30 files changed

+62
-45
lines changed

30 files changed

+62
-45
lines changed

ch04-图片/4.1_imread_imshow.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
# img = cv2.imread('messi5.jpg', cv2.IMREAD_GRAYSCALE)# Load an color image in grayscale 灰度
1111
img = cv2.imread('messi5.jpg',cv2.IMREAD_UNCHANGED)#包括图像的 alpha 通道
1212

13+
img = cv2.resize(img, (640, 480))
14+
1315
# img.I
1416
# AttributeError: 'numpy.ndarray' object has no attribute 'I'
1517

ch21-轮廓Contours/21.4.3-形状匹配.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
ret, thresh = cv2.threshold(img1, 127, 255, 0)
2121
ret, thresh2 = cv2.threshold(img2, 127, 255, 0)
2222

23-
contours, hierarchy = cv2.findContours(thresh, 2, 1)
23+
image,contours, hierarchy = cv2.findContours(thresh, 2, 1)
2424
cnt1 = contours[0]
25-
contours, hierarchy = cv2.findContours(thresh2, 2, 1)
25+
image,contours, hierarchy = cv2.findContours(thresh2, 2, 1)
2626
cnt2 = contours[0]
2727

2828
ret = cv2.matchShapes(cnt1, cnt2, 1, 0.0)

ch21-轮廓Contours/star.jpg

3.67 KB
Loading

ch21-轮廓Contours/star2.jpg

5.36 KB
Loading
File renamed without changes.
File renamed without changes.

ch30-Harris角点检测/30.1-OpenCV-Harris角点检测-cornerHarris.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
import cv2
1414
import numpy as np
1515

16-
filename = '../data/chessboard.jpeg'
16+
filename = '../data/chessboard.png'
1717
# filename = '../data/chessboard-3.png'
1818
# filename = '../data/corner-detection.jpg'
1919

2020
img = cv2.imread(filename)
21+
img = cv2.resize(img, (640, 480))
2122
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
2223
gray = np.float32(gray)
2324

@@ -28,7 +29,7 @@
2829
# Threshold for an optimal value, it may vary depending on the image.
2930
img[dst > 0.01 * dst.max()] = [0, 0, 255]
3031

32+
cv2.namedWindow('dst', cv2.WINDOW_NORMAL)
3133
cv2.imshow('dst', img)
32-
3334
cv2.waitKey(0)
3435
cv2.destroyAllWindows()

ch31-Shi-Tomasi角点检测-适合于跟踪的图像特征/goodFeaturesToTrack.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
import cv2
1919
from matplotlib import pyplot as plt
2020

21-
filename = '../data/corner-detection.jpg'
21+
# filename = '../data/corner-detection.jpg'
22+
filename = '../data/blox.jpg'
2223
img = cv2.imread(filename)
2324
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
2425

ch33-介绍SURF/surf.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import cv2
1414
import matplotlib.pyplot as plt
1515

16-
img = cv2.imread('fly.png', 0)
16+
img = cv2.imread('../data/butterfly.jpg', 0)
1717
# Create SURF object. You can specify params here or later. # Here I set Hessian Threshold to 400
1818
# surf = cv2.SURF(400)
1919
surf = cv2.xfeatures2d.SURF_create(400)
@@ -47,7 +47,8 @@
4747
print(surf.getExtended())
4848
# False
4949
# So we make it to True to get 128-dim descriptors.
50-
surf.extended = True
50+
# surf.extended = True
51+
surf.setExtended(True)
5152
kp, des = surf.detectAndCompute(img, None)
5253
print(surf.descriptorSize())
5354
# 128

ch34-角点检测的FAST算法/fast.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import cv2
1919
from matplotlib import pyplot as plt
2020

21-
img = cv2.imread('simple.jpg', 0)
21+
img = cv2.imread('../data/blox.jpg', 0)
2222

2323
# Initiate FAST object with default values
2424
fast = cv2.FastFeatureDetector_create()

0 commit comments

Comments
 (0)