コード例 #1
0
ファイル: test_visuals.py プロジェクト: rlinus/sleap
def test_resize(small_robot_mp4_vid):
    imgs = small_robot_mp4_vid[:4]

    resized_imgs = resize_images(imgs, 0.25)

    assert resized_imgs.shape[0] == imgs.shape[0]
    assert resized_imgs.shape[1] == imgs.shape[1] // 4
    assert resized_imgs.shape[2] == imgs.shape[2] // 4
    assert resized_imgs.shape[3] == imgs.shape[3]
コード例 #2
0
ファイル: test_visuals.py プロジェクト: preeti98/sleap
def test_serial_pipeline(centered_pair_predictions, tmpdir):
    frames = [0, 1, 2]
    video_idx = 0
    scale = 0.25

    out_path = os.path.join(tmpdir, "clip.avi")

    video = centered_pair_predictions.videos[video_idx]
    frame_images = video.get_frames(frames)

    # Make sure we can resize
    small_images = resize_images(frame_images, scale=scale)

    _, height, width, _ = small_images.shape

    assert height == video.height // (1 / scale)
    assert width == video.width // (1 / scale)

    marker_thread = VideoMarkerThread(
        in_q=None,
        out_q=None,
        labels=centered_pair_predictions,
        video_idx=video_idx,
        scale=scale,
        color_manager=None,
    )

    # Make sure we can mark images
    marked_image_list = marker_thread._mark_images(
        frame_indices=frames,
        frame_images=small_images,
    )

    marked_point = (centered_pair_predictions.find(
        video, frames[0])[0].instances[0].points[0])

    # There's a point at 201, 186 (i.e. 50.25, 46.5), so make sure it got marked
    assert not np.allclose(marked_image_list[0][44:48, 48:52, 0],
                           small_images[0, 44:48, 48:52, 0])

    # Make sure no change where nothing marked
    assert np.allclose(marked_image_list[0][10:20, :10, 0],
                       small_images[0, 10:20, :10, 0])