4
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PythonとOpen CV 4でパノラマ写真を作る

Last updated at Posted at 2019-05-15

投稿日2019/05/15

#やること
Open CVのStitcherクラスを使ってパノラマ写真を作ります。

#実行例

👇オリジナル画像
hakodate.jpg

👇分割した画像
hakodate-1.jpg
hakodate-2.jpg

👇プログラムで生成した画像
result.jpg

生成した画像の解像度はオリジナル画像より少し小さくなってしまっています。

👇ステッチが上手くいくとこんな感じにもなります。
result.jpg

#実行環境
Python 3.7.2
Open CV 4.1.0

#プログラム

join_picures.py
import cv2

print(cv2.__version__)#openCV 4.1.0で動作確認

if __name__ == "__main__":
    images = ['hakodate/hakodate-1.jpg', 'hakodate/hakodate-2.jpg']

    one = cv2.imread(images[0])
    two = cv2.imread(images[1])
    stitcher = cv2.Stitcher.create(False)
    result = stitcher.stitch((one,two))
    cv2.imwrite('hakodate/result.jpg', result[1])
    if result[0]==0:
        print("success")
    elif result[0]==1:
        print("failure")

#おまけ
旅行で行った函館、良いところでした。ラッキーピエロおいしかったです。

#参考
How to use OpenCV Stitcher class with Python?

4
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?