teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

3

d

2019/02/25 02:40

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -1,16 +1,22 @@
1
1
  cv2.Stitcher_create() をお使いください (OpenCV 4)
2
2
 
3
+ ```bash
4
+ pip install --upgrade opencv-contrib-python
5
+ ```
3
6
 
4
7
  ```python
5
8
  import cv2
6
9
 
7
10
  # 画像を読み込む。
8
- img1 = cv2.imread('sample1.png')
11
+ img1 = cv2.imread('a.png')
9
- img2 = cv2.imread('sample2.png')
12
+ img2 = cv2.imread('b.png')
10
13
 
11
- # パノラマ合成
14
+ # パノラマ合成する。
12
15
  stitcher = cv2.Stitcher_create(True)
16
+ status, stitched = stitcher.stitch([img1, img2])
17
+
18
+ # 保存する。
13
- cv2.imwrite('output.png', stitcher)
19
+ cv2.imwrite('output.png', stitched)
14
20
  ```
15
21
 
16
22
  ![イメージ説明](1191859d58925cfd59ac80e77965a40a.png)

2

d

2019/02/25 02:40

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -7,8 +7,6 @@
7
7
  # 画像を読み込む。
8
8
  img1 = cv2.imread('sample1.png')
9
9
  img2 = cv2.imread('sample2.png')
10
- imshow(img1)
11
- imshow(img2)
12
10
 
13
11
  # パノラマ合成
14
12
  stitcher = cv2.Stitcher_create(True)

1

d

2019/02/24 14:01

投稿

tiitoi
tiitoi

スコア21960

answer CHANGED
@@ -3,12 +3,7 @@
3
3
 
4
4
  ```python
5
5
  import cv2
6
- from IPython.display import Image, display
7
6
 
8
- def imshow(img):
9
- ret, img = cv2.imencode('.png', img)
10
- display(Image(img))
11
-
12
7
  # 画像を読み込む。
13
8
  img1 = cv2.imread('sample1.png')
14
9
  img2 = cv2.imread('sample2.png')
@@ -17,8 +12,7 @@
17
12
 
18
13
  # パノラマ合成
19
14
  stitcher = cv2.Stitcher_create(True)
20
- status, stitched = stitcher.stitch([img1, img2])
15
+ cv2.imwrite('output.png', stitcher)
21
- imshow(stitched)
22
16
  ```
23
17
 
24
18
  ![イメージ説明](1191859d58925cfd59ac80e77965a40a.png)