回答編集履歴
3
a
answer
CHANGED
@@ -29,9 +29,12 @@
|
|
29
29
|
approx_contour = cv2.approxPolyDP(contour, epsilon=0.005 * arclen, closed=True)
|
30
30
|
assert len(approx_contour) == 4, "以下の処理は抽出された輪郭は4点で構成されていることが前提"
|
31
31
|
|
32
|
+
cv2.circle(img, tuple(approx_contour[1][0]), 3, (255, 0, 0), -1)
|
33
|
+
cv2.imwrite("img.png", img)
|
34
|
+
|
32
|
-
|
35
|
+
w, h = 500, 690 # 長方形の大きさ
|
33
36
|
points1 = approx_contour.astype(np.float32)
|
34
|
-
points2 = np.float32([[
|
37
|
+
points2 = np.float32([[0, h], [0, 0], [w, 0], [w, h]])
|
35
38
|
|
36
39
|
# points1 から points2 へ写す射影変換行列を計算する。
|
37
40
|
H = cv2.getPerspectiveTransform(points1, points2)
|
@@ -43,4 +46,4 @@
|
|
43
46
|
cv2.imwrite("result.png", dst)
|
44
47
|
```
|
45
48
|
|
46
|
-

|
2
d
answer
CHANGED
File without changes
|
1
d
answer
CHANGED
@@ -41,4 +41,6 @@
|
|
41
41
|
|
42
42
|
# 結果を保存する。
|
43
43
|
cv2.imwrite("result.png", dst)
|
44
|
-
```
|
44
|
+
```
|
45
|
+
|
46
|
+

|