Exemplo n.º 1
0
def peri_test(address, colour_space, init_delay):
    factory = VideoSourceFactory.get_instance()
    global source
    source = factory.connect_network_source(address, colour_space)
    sleep(init_delay)
    assert source is not None

    global frame, frame_with_colour_mismatch, tmp_frame
    frame = VideoFrame(colour_space, False)
    # TODO the loop is due to issue #135
    n_attempts = 0
    n_max_attempts = 10
    while not source.get_frame(frame):
        sleep(1)
        n_attempts += 1
        if n_attempts >= n_max_attempts:
            break
    assert source.get_frame(frame)
    tmp_frame = VideoFrame(colour_space, False)
    if colour_space == ColourSpace.BGRA:
        mismatch_colour_space = ColourSpace.I420
    else:
        mismatch_colour_space = ColourSpace.BGRA
    frame_with_colour_mismatch = VideoFrame(mismatch_colour_space, False)

    yield
Exemplo n.º 2
0
def peri_test(colour_space, filepath, frame_rate, frame_count, frame_width,
              frame_height):
    global factory
    factory = VideoSourceFactory.get_instance()
    global video_duration, quarter_video_duration
    video_duration = frame_count / frame_rate
    quarter_video_duration = video_duration / 4
    yield
Exemplo n.º 3
0
def test_file_to_imshow(filename):
    factory_source = VideoSourceFactory.get_instance()
    file_reader = factory_source.create_file_reader(filename, ColourSpace.BGRA)
    factory_target = VideoTargetFactory.get_instance()
    file_writer = factory_target.create_file_writer(Codec.Xvid,
                                                    'opencv_output_py.avi', 30)
    file_reader.attach(file_writer)
    time.sleep(20)
    file_reader.detach(file_writer)
Exemplo n.º 4
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
Exemplo n.º 5
0
            # the two calls below save the two stereo frames,
            # without the need for reshaping the data, as the
            # call to the data method already yields a
            # structured NumPy array
            cv2.imwrite('mono-frame.data-True.png', frame.data(True)[:, :, :3])
            cv2.imwrite('mono-frame.data-True-0.png',
                        frame.data(True, 0)[:, :, :3])

        elif self.current == 4:
            # the two calls below save the two stereo frames,
            # without the need for reshaping the data, as the
            # call to the data method already yields a
            # structured NumPy array
            cv2.imwrite('stereo-frame.data-True-0.png',
                        frame.data(True, 0)[:, :, :3])
            cv2.imwrite('stereo-frame.data-True-1.png',
                        frame.data(True, 1)[:, :, :3])


if __name__ == '__main__':
    sfac = VideoSourceFactory.get_instance()
    source = sfac.get_device(Device.DeckLink4KExtreme12G, ColourSpace.BGRA)

    saver = StereoFrameSaver()

    source.attach(saver)

    time.sleep(2)  # operate pipeline for 2 sec

    source.detach(saver)
Exemplo n.º 6
0
def peri_test():
    global factory
    factory = VideoSourceFactory.get_instance()
    yield