예제 #1
0
def test_is_screen_black_with_numpy_mask_and_region():
    frame = stbt.load_image("videotestsrc-full-frame.png")
    region = stbt.Region(x=160, y=180, right=320, bottom=240)
    mask = numpy.zeros((60, 160), dtype=numpy.uint8)
    mask[:, :80] = 255
    assert stbt.is_screen_black(frame, mask, 20, region)

    mask[:, :] = 255
    assert not stbt.is_screen_black(frame, mask, 20, region)
예제 #2
0
def test_is_screen_black_debug():
    # So that the output directory name doesn't depend on how many tests
    # were run before this one.
    ImageLogger._frame_number = itertools.count(1)  # pylint:disable=protected-access

    f = stbt.load_image("videotestsrc-full-frame.png")

    with scoped_curdir(), scoped_debug_level(2):

        stbt.is_screen_black(f)
        stbt.is_screen_black(f, mask="videotestsrc-mask-non-black.png")
        stbt.is_screen_black(f, mask="videotestsrc-mask-no-video.png")
        stbt.is_screen_black(f, region=stbt.Region(0, 0, 160, 120))

        files = subprocess.check_output("find stbt-debug | sort", shell=True) \
                          .decode("utf-8")
        assert files == dedent("""\
            stbt-debug
            stbt-debug/00001
            stbt-debug/00001/grey.png
            stbt-debug/00001/index.html
            stbt-debug/00001/non_black.png
            stbt-debug/00001/source.png
            stbt-debug/00002
            stbt-debug/00002/grey.png
            stbt-debug/00002/index.html
            stbt-debug/00002/mask.png
            stbt-debug/00002/non_black.png
            stbt-debug/00002/source.png
            stbt-debug/00003
            stbt-debug/00003/grey.png
            stbt-debug/00003/index.html
            stbt-debug/00003/mask.png
            stbt-debug/00003/non_black.png
            stbt-debug/00003/source.png
            stbt-debug/00004
            stbt-debug/00004/grey.png
            stbt-debug/00004/index.html
            stbt-debug/00004/non_black.png
            stbt-debug/00004/source.png
            """)

        assert_expected("stbt-debug-expected-output/is_screen_black")
예제 #3
0
def test_is_screen_black_with_numpy_mask():
    frame = stbt.load_image("videotestsrc-full-frame.png")
    mask = numpy.zeros((240, 320), dtype=numpy.uint8)
    mask[180:240, 160:213] = 255
    assert stbt.is_screen_black(frame, mask)
예제 #4
0
def test_is_screen_black_result():
    frame = stbt.load_image("almost-black.png")
    result = stbt.is_screen_black(frame)
    assert result
    assert numpy.all(result.frame == frame)
    assert result.black is True
예제 #5
0
def test_is_screen_black(frame, mask, threshold, region, expected):
    frame = stbt.load_image(frame)
    assert expected == bool(
        stbt.is_screen_black(frame, mask, threshold, region))