0
1

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 1 year has passed since last update.

OpenCVでパノラマ合成

Posted at

参考
Python+OpenCVでstitching パノラマ画像生成をやってみた

  • csvインストールコマンド
python3 -m pip install opencv-python
python3 -m pip install opencv-contrib-python
  • Stitcher_create:openCVのバージョンアップで関数変更↓
import argparse
import cv2

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='Stitch given images.')
    parser.add_argument("inputs", metavar='input', type=str, nargs='+', help='input file')
    parser.add_argument("--output", type=str, default='a.png', help='output file (default=a.png)')
    args = parser.parse_args()

    input_images = []
    for i in args.inputs:
        image = cv2.imread(i)
        if image is None:
            print(f'Error: Unable to open file "{i}".')
            exit()
        input_images.append(image)

    if len(input_images) == 1:
        cv2.imwrite(args.output, input_images[0])
    else:
        stitcher = cv2.Stitcher_create(mode=1) #mode=0 カメラ画像 mode=1 スキャン画像
        stitched = stitcher.stitch(input_images)
        cv2.imwrite(args.output, stitched[1])
  • コマンド
    python3 main.py --output ./dst.jpg ./src1.jpg ./src2.jpg ./src3.jpg
0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?