Repository navigation
Replies: 1 comment
|
Yes. from stitching import Stitcher
pano = Stitcher().stitch([left, center, right]) # file paths or numpy BGR imagesNeighbouring views need enough overlap with features in common. Roughly 20-30% is a safe target. If one view is dropped, you get a If you stitch the three cameras over and over (a video stream from a fixed rig), do not estimate the cameras for every frame. It is slower, and the panorama jitters because every frame gets slightly different camera parameters. Estimate them once and reuse them. This is the approach from #148, with two fixes ( from stitching import Stitcher
from stitching.images import Images
class RigStitcher(Stitcher):
def initialize_stitcher(self, **kwargs):
super().initialize_stitcher(**kwargs)
self.cameras = None
def stitch(self, images, feature_masks=[]):
self.images = Images.of(images, self.medium_megapix, self.low_megapix, self.final_megapix)
imgs = self.resize_medium_resolution()
if self.cameras is None: # only on the first frame set
features = self.find_features(imgs, feature_masks)
matches = self.match_features(features)
imgs, features, matches = self.subset(imgs, features, matches)
cameras = self.estimate_camera_parameters(features, matches)
cameras = self.refine_camera_parameters(features, matches, cameras)
cameras = self.perform_wave_correction(cameras)
self.estimate_scale(cameras)
self.cameras = cameras
imgs = self.resize_low_resolution(imgs)
imgs, masks, corners, sizes = self.warp_low_resolution(imgs, self.cameras)
self.prepare_cropper(imgs, masks, corners, sizes)
imgs, masks, corners, sizes = self.crop_low_resolution(imgs, masks, corners, sizes)
self.estimate_exposure_errors(corners, imgs, masks)
seam_masks = self.find_seam_masks(imgs, corners, masks)
imgs = self.resize_final_resolution()
imgs, masks, corners, sizes = self.warp_final_resolution(imgs, self.cameras)
imgs, masks, corners, sizes = self.crop_final_resolution(imgs, masks, corners, sizes)
self.set_masks(masks)
imgs = self.compensate_exposure_errors(corners, imgs)
seam_masks = self.resize_seam_masks(seam_masks)
self.initialize_composition(corners, sizes)
self.blend_images(imgs, seam_masks, corners)
return self.create_final_panorama()
stitcher = RigStitcher(crop=False) # crop=False keeps the output size constant
for left, center, right in frames: # synchronized triplets
pano = stitcher.stitch([left, center, right])Always pass the cameras in the same order. Calibrate on a frame set with good texture in the overlap areas. I tested this with stitching 0.7.0 on three synthetic overlapping views: the first call estimates the cameras, and later calls reuse them and give the same panorama size every time. Because the cameras are only "nearly" simultaneous, anything that moves fast will show seams or ghosting. Stitching cannot fix that. Only hardware sync can. |
Uh oh!
There was an error while loading. Please reload this page.
Hello, can this project stitch the data from three normal cameras (nearly simultaneously)?
All reactions