Пример #1
0
def peri_test(colour_space):
    # This section runs before each test
    factory = VideoSourceFactory.get_instance()
    global source
    try:
        source = factory.get_device(Device.DeckLinkSDI4K, colour_space)
    except IOError as e:
        raise RuntimeError(
            'Could not connect to Blackmagic DeckLink SDI 4K,\n' +
            'The detailed error was:\n' + e.message)
    assert source is not None

    global frame, frame_with_colour_mismatch
    frame = VideoFrame(colour_space, False)
    if colour_space == ColourSpace.BGRA:
        mismatch_colour_space = ColourSpace.UYVY
    else:
        mismatch_colour_space = ColourSpace.BGRA
    frame_with_colour_mismatch = VideoFrame(mismatch_colour_space, False)

    global height, width
    assert source.get_frame(frame)
    width = frame.cols()
    height = frame.rows()

    global sub_x, sub_y, sub_width, sub_height
    sub_width = width // 3
    sub_height = height // 3
    sub_x = width // 2
    sub_y = height // 2
    # health checks
    assert sub_x + sub_width < width
    assert sub_y + sub_height < height

    global sub2_x, sub2_y, sub2_width, sub2_height
    sub2_width = width // 5
    sub2_height = height // 5
    sub2_x = width // 6
    sub2_y = height // 6
    # health checks
    assert sub2_x + sub2_width < width
    assert sub2_y + sub2_height < height

    # Run test
    yield
Пример #2
0
        filename, ext = 'dvi2pcie', '.mp4'

        # start acquirigin frames from an Epiphan DVI2PCIe Duo SDI port
        source = sfac.get_device(Device.DVI2PCIeDuo_SDI, ColourSpace.BGRA)
    else:
        filename = os.path.basename(video_input)
        filename, ext = os.path.splitext(filename)
        assert filename
        assert ext == '.mp4'

        # initialise reading of passed file
        source = sfac.create_file_reader(video_input, ColourSpace.BGRA)

    frame = VideoFrame(ColourSpace.BGRA, False)
    source.get_frame(frame)
    frame_shape = (frame.rows(), frame.cols(), 4)

    # prepare for creating encoders (writers)
    tfac = VideoTargetFactory.get_instance()
    frame_rate = source.get_frame_rate()

    # create a red and green Dyer
    red_dyer = Dyer(2, 128)
    green_dyer = Dyer(1, 64)

    # create the bufferer for the red and green Dyers
    np_buffer_red = np.zeros(frame_shape, np.uint8)
    bufferer_red = Bufferer(np_buffer_red)
    np_buffer_orig = np.zeros_like(np_buffer_red)
    bufferer_orig = Bufferer(np_buffer_orig)