コード例 #1
0
def process_images(args):
    left_img = cv2.imread(args.left)
    right_img = cv2.imread(args.right)
    stitcher = core.BB_FeatureBasedStitcher()
    stitcher.load_data(args.data)
    result = stitcher.overlay_images(left_img, right_img)
    cv2.imwrite('pano.jpg', result)
コード例 #2
0
def process_images(args):
    # checks if filenames are valid
    assert helpers.check_filename(args.left) and helpers.check_filename(
        args.right)

    start_time_l = helpers.get_start_datetime(args.left)
    start_time_r = helpers.get_start_datetime(args.right)
    out_basename = ''.join(
        [str(args.transform), '_', start_time_l, '_ST_', start_time_r])

    if os.path.isdir(args.data):
        data_basename = ''.join([out_basename, '.npz'])
        data_path = os.path.join(args.data, data_basename)
    else:
        data_path = args.data

    camIdx_l = helpers.get_CamIdx(args.left)
    camIdx_r = helpers.get_CamIdx(args.right)
    assert camIdx_l in [0, 1, 2, 3] and camIdx_r in [0, 1, 2, 3]

    img_l = cv2.imread(args.left, 0)
    img_r = cv2.imread(args.right, 0)

    bb_stitcher_fb = core.BB_FeatureBasedStitcher(
        Transformation(args.transform))
    result = bb_stitcher_fb((img_l, img_r), (camIdx_l, camIdx_r),
                            (args.left_angle, args.right_angle))
    if result is None:
        print("No homography found.")
    else:
        bb_stitcher_fb.save_data(data_path)
        print('Saved stitching params to: {} '.format(data_path))

        if args.pano is not None:
            if os.path.isdir(args.pano[0]):
                pano_basename = ''.join([out_basename, '.jpg'])
                pano_path = os.path.join(args.pano[0], pano_basename)
            else:
                pano_path = args.pano[0]
            result = bb_stitcher_fb.overlay_images()
            cv2.imwrite(pano_path, result)
コード例 #3
0
def process_videos(args):
    left_cap = cv2.VideoCapture(args.left)
    right_cap = cv2.VideoCapture(args.right)
    stitcher = core.BB_FeatureBasedStitcher()
    stitcher.load_data(args.data)
    result_writer = cv2.VideoWriter('result2.avi', cv2.VideoWriter_fourcc(*'XVID'), 3, (600, 400))

    try:
        while 1:
            left_ret, left_frame = left_cap.read()
            right_ret, right_frame = right_cap.read()
            result = stitcher.overlay_images(left_frame, right_frame)
            ret = result_writer.write(result)
            print(ret)
            cv2.namedWindow('img', cv2.WINDOW_NORMAL)
            cv2.resizeWindow('img', 800, 600)
            cv2.imshow('img', result)
            k = cv2.waitKey(1) & 0xff
            if k == 27:
                break

    except KeyboardInterrupt:
        pass
コード例 #4
0
import fb_stitcher.core as core
import numpy as np

camIdx = 0

pts_left_org = np.array([[[1000, 3000], [353, 400],
                          [369, 2703]]]).astype(np.float64)

stitcher = core.BB_FeatureBasedStitcher()
stitcher.load_data('data/test_map_coordinates_2/Input/out.npz')
pts_mapped = stitcher.map_cam_coordinates(camIdx, pts_left_org)

print(pts_mapped)
コード例 #5
0
import fb_stitcher.core as core
import fb_stitcher.helpers as helpers
import logging.config

logging.config.fileConfig('logging_config.ini')

img_l = cv2.imread(
    'data/core/Input/Cam_0_2016-07-19T12:41:22.353295Z--2016-07-19T12:47:02.199607Z.jpg',
    -1)
img_r = cv2.imread(
    'data/core/Input/Cam_1_2016-07-19T12:41:22.685374Z--2016-07-19T12:47:02.533678Z.jpg',
    -1)

helpers.display(img_l, 'left image', time=50)
helpers.display(img_r, 'right image', time=50)
bb_stitcher_fb = core.BB_FeatureBasedStitcher()
bb_stitcher_fb((img_l, img_r), (0, 1))
result = bb_stitcher_fb.overlay_images()
helpers.display(result, 'left restult')

img_l_alpha = cv2.cvtColor(img_l, cv2.COLOR_BGR2BGRA)
left = bb_stitcher_fb.transform_left_image(img_l_alpha)
cv2.imwrite('data/core/Output/left.png', left)

img_r_alpha = cv2.cvtColor(img_r, cv2.COLOR_BGR2BGRA)
right = bb_stitcher_fb.transform_right_image(img_r_alpha)
cv2.imwrite('data/core/Output/right.png', right)

cv2.imwrite('data/core/Output/result.jpg', result)
bb_stitcher_fb.save_data('data/core/Output/out')