DualFisheyeStitcher is a Python class designed to perform fast panoramic stitching from two circular fisheye camera inputs (e.g., Ricoh Theta Z1). It includes fisheye correction (dewarping) using precomputed lookup tables and stitching based on overlapping regions.
This class handles:
- Precomputing dewarping LUTs (lookup tables)
 - Applying fast equirectangular projection
 - Merging both corrected fisheye frames into a panoramic frame
 
fov: Field of view of the fisheye camera in degrees (typically ~190°).frame_width: Width of the input fisheye images.frame_height: Height of the input fisheye images.
- Overlap percentage based on camera FOV.
 - Precomputed dewarping lookup tables (
map_x,map_y). - Output dimensions for undistorted frames.
 
Calculates the horizontal overlapping percentage between the two 180°-spaced fisheye cameras:
- Computes:
overlap_angle = 2 * FOV - 360 - Converts to a ratio over the full 2×FOV span.
 - Example: FOV = 190 → 20° overlap → ≈5.3%.
 
Generates remapping lookup tables (map_x, map_y) to convert circular fisheye images into an equirectangular format.
- Uses equidistant projection model.
 - Precomputes the transformation for performance.
 - Outputs remap matrices used by OpenCV’s 
cv2.remap(). 
Applies the precomputed LUTs to undistort a fisheye frame efficiently.
- Internally uses 
cv2.remap(...). - Very fast (real-time capable).
 - Returns the undistorted (equirectangular) image.
 
Performs the panoramic stitching of two undistorted images by:
- 
Splitting left and right frames into:
- Main region (non-overlapping)
 - Overlapping region
 
 - 
Blending the overlapping zones using a linear alpha mask.
 - 
Concatenating the resulting parts.
 
High-level method that:
- Applies fast dewarping to both inputs.
 - Stitches them using 
stitch_by_shift(...). - Returns the final panoramic output.
 
stitcher = DualFisheyeStitcher(fov=190, frame_width=960, frame_height=960)
panorama = stitcher.stitch_frames(left_img, right_img)- The camera's field of view (FOV) must be greater than 180° to ensure sufficient overlap between the two fisheye images.
 - Assumes cameras are aligned horizontally with minimal tilt.
 - Overlap zone blending is linear; can be extended to multiband blending if needed.
 - The code is optimized for real-time processing and achieves between 29–30 FPS under typical conditions using precomputed LUTs.
 
