As a follow-up to the closed question ' How to update a part of a panorama ' I have come up with an approach but OpenCV doesn't behave the way I want it to. To be more exact:
- I have a panorama of which I do not have the original images
- I have a new additional, smaller image that fits well into the panorama (except for warping, size adjustments etc) but has some more items in it that I want to be present in the adjusted panorama
The approach I am now on is to cut the panorama into several overlapping images and use those images together with the new image to stitch a new panorama. However, the new image is never part of the new panorama. Here is the code:
import cv2
from empatches import EMPatches
pano_img = cv2.imread('pano.jpg')
pano_height = pano_img.shape[0]
new_img = cv2.imread('new.jpg')
# Use the EMPatches lib to extract overlapping images. This works perfectly fine.
# img_patches is a list of np.array, usable in OpenCV
emp = EMPatches()
img_patches, _ = emp.extract_patches(pano_img, pano_height, overlap=0.4)
img_patches.append(new_img)
stitcher = cv2.Stitcher_create()
status, output = stitcher.stitch(img_patches)
# Returns status 0 and output is the original panorama perfectly stitched.
# The new image was ignored.
I do not know where in the original panorama the new image would go, so I can't set up an order in the img_patches list if that's the issue. How can I tweak OpenCV to create the panorama containing the new image?
OpenCV is version 4.7.0.72 and installed using pip install opencv-python.

