How to convert 6 photos to 360 panorama

331 Views Asked by At

I have script that convert 6 pictures (up, left, bottom, right, front, back) to one panorama.

import cv2
import numpy as np

up = cv2.imread('sides/up.jpg')
down = cv2.imread('sides/down.jpg')
left = cv2.imread('sides/left.jpg')
right = cv2.imread('sides/right.jpg')
front = cv2.imread('sides/front.jpg')
back = cv2.imread('sides/back.jpg')

height, width, _ = front.shape
if left.shape[0] != height or right.shape[0] != height or up.shape[1] != width or down.shape[1] != width or back.shape[1] != width:
    print("Размеры сторон не соответствуют")
    exit()

panorama_width = width * 4
panorama_height = height * 3
panorama = np.zeros((panorama_height, panorama_width, 3), dtype=np.uint8)

panorama[height:height*2, width:width*2] = front
panorama[height:height*2, width*3:width*4] = back
panorama[0:height, width:width*2] = up
panorama[height*2:height*3, width:width*2] = down
panorama[height:height*2, 0:width] = left
panorama[height:height*2, width*2:width*3] = right

cv2.imwrite('panorama123.jpg', panorama)

cv2.imshow('Panorama', panorama)
cv2.waitKey(0)
cv2.destroyAllWindows()

This script create file with black squares. Is it possible to make this panorama seamless so that there are no empty areas? Thank you in advance.enter image description here

Already used "stitcher" from cv2, but it can't find common points between pictures.

0

There are 0 best solutions below