コード例 #1
0
ファイル: panograph.py プロジェクト: tnq177/cvaaa
    def __init__(self, images_directory_path, resize_height=320, bnnRatio=0.8, contrastThreshold=0.04, ransacThreshold=10.0, min_samples=6, max_trials=1000):
        self.bnnRatio = bnnRatio
        self.contrastThreshold = contrastThreshold
        self.ransacThreshold = ransacThreshold
        self.min_samples = min_samples
        self.max_trials = max_trials
        self.resize_height = resize_height

        image_paths = get_images_paths(images_directory_path)
        self.images = [Image(image_path, index, resize_height=self.resize_height, contrastThreshold=self.contrastThreshold)
                       for index, image_path in enumerate(image_paths)]
コード例 #2
0
                image.original,
                image.M,
                (final_cols, final_rows),
                borderMode=cv2.BORDER_TRANSPARENT)
            mask = transformed_img[:, :, 3] / 255 == 1
            numpy.copyto(
                result, transformed_img[:, :, :3], 
                where=numpy.dstack((mask,) * 3))
            numpy.copyto(global_mask, mask, where=mask)

        result[~global_mask] = [255, 255, 255]
        return result

if __name__ == '__main__':
    images_dir = './data/Panorama/campus'
    images_paths = natsorted(get_images_paths(images_dir))

    # Read/Estimate focal length
    f = k1 = k2 = None
    if path.exists(path.join(images_dir, 'info.txt')):
        with open(path.join(images_dir, 'info.txt')) as f:
            for line in f:
                key, val = line.split()
                if key == 'f':
                    f = float(val)
                elif key == 'k1':
                    k1 = float(val)
                elif key == 'k2':
                    k2 = float(val)
    else:
        images = [cv2.imread(image_path) for image_path in images_paths]