Stitching images with a mask and known transformation

I’m looking to do some image stitching with two caveats:

  • I already have a priori information regarding how the images align (x,y,theta pixel shift, affine transformation, etc)
  • My images have an associated mask

For more context - I’m stitching two fish-eye images that have been ‘undistorted’, so they have the typical hourglass shape and black semi-circles on all four sides. Obviously I do not want that to be included in the stitching so I can create a mask with the K,D matrices I’m using to undistort the original images.

Presently the closest I have gotten is simply overlaying the image using the second images mask and np.where(). Ideally, I would like the images to be properly ‘blended’ (not in the addWeighted() sense), meaning I’d like the the energy minimization/seam blending that reduces artifacts at the seams.

I am aware of OpenCV stitcher class and would like to leverage, but just using the ‘stitch’ function is much more than I want, has no provisions for supplying masks, and abstracts away things like image alignment/etc, which I want explicit control over. Really the feature finding and transformation/warping logic is counterproductive in my case and I just want the seam blending.

Is it possible to pick-out the subset of features I need in the stitcher class, or are there other modules I should be looking at? Language-wise I work with both C++ and pythonl. Thanks