コード例 #1
0
def test_that_match_all_obeys_region():
    matches = sorted(m.region for m in stbt.match_all(
        "button.png", frame=_imread("buttons.png"),
        region=stbt.Region(x=160, y=60, right=340, bottom=190)))
    print matches
    assert matches == [stbt.Region(x, y, width=135, height=44) for x, y in [
        (177, 75), (177, 119)]]
コード例 #2
0
ファイル: stbt_match.py プロジェクト: stb-tester/stb-tester
def main():
    parser = argparse.ArgumentParser()
    parser.prog = "stbt match"
    parser.description = """Run stbt's image-matching algorithm against a single
        frame (which you can capture using `stbt screenshot`)."""
    parser.add_argument(
        "-v", "--verbose", action="store_true",
        help="Dump image processing debug images to ./stbt-debug directory")
    parser.add_argument(
        "--all", action="store_true",
        help='Use "stbt.match_all" instead of "stbt.match"')
    parser.add_argument(
        "source_file", help="""The screenshot to compare against (you can
            capture it using 'stbt screenshot')""")
    parser.add_argument(
        "reference_file", help="The image to search for")
    parser.add_argument(
        "match_parameters", nargs="*",
        help="""Parameters for the image processing algorithm. See
            'MatchParameters' in the stbt API documentation. For example:
            'confirm_threshold=0.70')""")
    args = parser.parse_args(sys.argv[1:])

    mp = {}
    try:
        for p in args.match_parameters:
            name, value = p.split("=")
            if name == "match_method":
                mp["match_method"] = value
            elif name == "match_threshold":
                mp["match_threshold"] = float(value)
            elif name == "confirm_method":
                mp["confirm_method"] = value
            elif name == "confirm_threshold":
                mp["confirm_threshold"] = float(value)
            elif name == "erode_passes":
                mp["erode_passes"] = int(value)
            else:
                raise Exception("Unknown match_parameter argument '%s'" % p)
    except Exception:  # pylint:disable=broad-except
        error("Invalid argument '%s'" % p)

    source_image = cv2.imread(args.source_file)
    if source_image is None:
        error("Invalid image '%s'" % args.source_file)

    with (_stbt.logging.scoped_debug_level(2) if args.verbose
          else noop_contextmanager()):
        match_found = False
        for result in stbt.match_all(
                args.reference_file, frame=source_image,
                match_parameters=stbt.MatchParameters(**mp)):
            print "%s: %s" % (
                "Match found" if result else "No match found. Closest match",
                result)
            if result:
                match_found = True
            if not args.all:
                break
        sys.exit(0 if match_found else 1)
コード例 #3
0
ファイル: test_match.py プロジェクト: stb-tester/stb-tester
def test_that_match_all_obeys_region(match_method):
    matches = sorted(m.region for m in stbt.match_all(
        "button.png", frame=stbt.load_image("buttons.png"),
        match_parameters=mp(match_method=match_method),
        region=stbt.Region(x=160, y=60, right=340, bottom=190)))
    print matches
    assert matches == [stbt.Region(x, y, width=135, height=44) for x, y in [
        (177, 75), (177, 119)]]
コード例 #4
0
ファイル: test_match.py プロジェクト: stb-tester/stb-tester
def test_match_all_with_transparent_reference_image():
    frame = stbt.load_image("buttons-on-blue-background.png")
    matches = list(m.region for m in stbt.match_all(
        "button-transparent.png", frame=frame))
    print matches
    assert overlapped_button not in matches
    assert (sorted(plain_buttons + labelled_buttons + [overlapping_button]) ==
            sorted(matches))
コード例 #5
0
def test_that_match_all_finds_all_matches():
    plain_buttons = [stbt.Region(x, y, width=135, height=44) for x, y in [
        (28, 1), (163, 1), (177, 75), (177, 119), (177, 163), (298, 1)]]

    matches = list(m.region for m in stbt.match_all(
        'button.png', frame=_imread('buttons.png')))
    print matches
    assert plain_buttons == sorted(matches)
コード例 #6
0
ファイル: test_match.py プロジェクト: stb-tester/stb-tester
def test_that_match_all_can_find_labelled_matches(match_method):
    frame = stbt.load_image('buttons.png')
    matches = list(m.region for m in stbt.match_all(
        'button.png', frame=frame,
        match_parameters=mp(match_method=match_method,
                            confirm_method=stbt.ConfirmMethod.NONE)))
    print matches
    assert overlapped_button not in matches
    assert sorted(plain_buttons + labelled_buttons + [overlapping_button]) == \
        sorted(matches)
コード例 #7
0
def test_match_all_with_an_image_that_matches_everywhere():
    matches = sorted(m.region for m in stbt.match_all(
        "repeating-pattern.png",
        frame=_imread("repeating-pattern-full-frame.png")))

    expected_matches = sorted([stbt.Region(x, y, width=16, height=16)
                               for x in range(0, 320, 16)
                               for y in range(0, 240, 16)])

    print matches
    assert matches == expected_matches
コード例 #8
0
ファイル: test_match.py プロジェクト: stb-tester/stb-tester
def test_that_match_all_can_be_used_with_ocr_to_read_buttons():
    # Demonstrates how match_all can be used with ocr for UIs consisting of text
    # on buttons
    frame = stbt.load_image('buttons.png')

    text = [
        stbt.ocr(frame=stbt.crop(
            frame,
            m.region.extend(x=30, y=10, right=-30, bottom=-10)))
        for m in stbt.match_all('button-transparent.png', frame=frame)]
    text = sorted([t for t in text if t not in ['', '\\s']])
    print text
    assert text == [u'Button 1', u'Button 2', u'Buttons']
コード例 #9
0
def test_that_match_all_can_be_used_with_ocr_to_read_buttons():
    # Demonstrates how match_all can be used with ocr for UIs consisting of text
    # on buttons
    frame = _imread('buttons.png')
    button = _imread('button.png')

    text = [
        stbt.ocr(frame=cv2.absdiff(_crop(frame, m.region), button))
        for m in stbt.match_all(
            button, frame=frame, match_parameters=mp(confirm_method='none'))]
    text = sorted([t for t in text if t not in ['', '\\s']])
    print text
    assert text == [u'Button 1', u'Button 2', u'Buttons']
コード例 #10
0
def test_that_match_all_can_find_labelled_matches():
    plain_buttons = [stbt.Region(x, y, width=135, height=44) for x, y in [
        (28, 1), (163, 1), (177, 75), (177, 119), (177, 163), (298, 1)]]
    labelled_buttons = [stbt.Region(x, y, width=135, height=44) for x, y in [
        (1, 65), (6, 137), (123, 223)]]
    overlapped_button = stbt.Region(3, 223, width=135, height=44)

    frame = _imread('buttons.png')

    matches = list(m.region for m in stbt.match_all(
        'button.png', frame=frame, match_parameters=mp(confirm_method='none')))
    print matches
    assert overlapped_button not in matches
    assert sorted(plain_buttons + labelled_buttons) == sorted(matches)
コード例 #11
0
ファイル: test_match.py プロジェクト: LewisHaley/stb-tester
def test_that_results_dont_overlap():
    # This is a regression test for a bug seen in an earlier implementation of
    # `match_all`.
    frame = _imread("action-panel.png")
    all_matches = set()
    for m in stbt.match_all("action-panel-template.png", frame=frame):
        print m
        assert m.region not in all_matches, "Match %s already seen:\n    %s" % (
            m, "\n    ".join(str(x) for x in all_matches))
        assert all(stbt.Region.intersect(m.region, x) is None
                   for x in all_matches)
        all_matches.add(m.region)

    assert all_matches == set([
        stbt.Region(x=135, y=433, width=222, height=40),
        stbt.Region(x=135, y=477, width=222, height=40),
        stbt.Region(x=135, y=521, width=222, height=40),
        stbt.Region(x=135, y=565, width=222, height=40),
        stbt.Region(x=135, y=609, width=222, height=40)])
コード例 #12
0
def test_match_all_image_debug_when_first_pass_gives_no_matches():
    with scoped_curdir(), scoped_debug_level(2):
        matches = list(stbt.match_all(
            "videotestsrc-redblue-flipped.png",
            frame=_imread("videotestsrc-full-frame.png")))
        print matches
        assert len(matches) == 0
        _verify_stbt_debug_dir([
            'index.html',
            'level2-source.png',
            'level2-source_matchtemplate.png',
            'level2-source_with_match.png',
            'level2-source_with_rois.png',
            'level2-template.png',
            'match0-heatmap.png',
            'match0-source_with_match.png',
            'source.png',
            'template.png',
        ])
コード例 #13
0
def test_match_debug():
    expected = _find_file("stbt-debug-expected-output")

    # 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

    with scoped_curdir(), scoped_debug_level(2):
        # First pass gives no matches:
        matches = list(
            stbt.match_all("videotestsrc-redblue-flipped.png",
                           frame=_imread("videotestsrc-full-frame.png")))
        print matches
        assert len(matches) == 0

        # Multiple matches; first pass stops with a non-match:
        matches = list(
            stbt.match_all("button.png",
                           frame=_imread("buttons.png"),
                           match_parameters=mp(match_threshold=0.99)))
        print matches
        assert len(matches) == 6

        # Multiple matches; second pass stops with a non-match:
        matches = list(
            stbt.match_all("button.png", frame=_imread("buttons.png")))
        print matches
        assert len(matches) == 6

        # With absdiff:
        matches = list(
            stbt.match_all("button.png",
                           frame=_imread("buttons.png"),
                           match_parameters=mp(confirm_method="absdiff",
                                               confirm_threshold=0.16)))
        print matches
        assert len(matches) == 6

        files = subprocess.check_output("find stbt-debug | sort", shell=True)
        assert files == dedent("""\
            stbt-debug
            stbt-debug/match
            stbt-debug/match/00001
            stbt-debug/match/00001/index.html
            stbt-debug/match/00001/level2-source_matchtemplate.png
            stbt-debug/match/00001/level2-source.png
            stbt-debug/match/00001/level2-source_with_match.png
            stbt-debug/match/00001/level2-source_with_rois.png
            stbt-debug/match/00001/level2-template.png
            stbt-debug/match/00001/match0-heatmap.png
            stbt-debug/match/00001/match0-source_with_match.png
            stbt-debug/match/00001/source.png
            stbt-debug/match/00001/template.png
            stbt-debug/match/00002
            stbt-debug/match/00002/index.html
            stbt-debug/match/00002/level0-source_matchtemplate.png
            stbt-debug/match/00002/level0-source_matchtemplate_threshold.png
            stbt-debug/match/00002/level0-source.png
            stbt-debug/match/00002/level0-source_with_match.png
            stbt-debug/match/00002/level0-source_with_rois.png
            stbt-debug/match/00002/level0-template.png
            stbt-debug/match/00002/level1-source_matchtemplate.png
            stbt-debug/match/00002/level1-source_matchtemplate_threshold.png
            stbt-debug/match/00002/level1-source.png
            stbt-debug/match/00002/level1-source_with_match.png
            stbt-debug/match/00002/level1-source_with_rois.png
            stbt-debug/match/00002/level1-template.png
            stbt-debug/match/00002/level2-source_matchtemplate.png
            stbt-debug/match/00002/level2-source_matchtemplate_threshold.png
            stbt-debug/match/00002/level2-source.png
            stbt-debug/match/00002/level2-source_with_match.png
            stbt-debug/match/00002/level2-source_with_rois.png
            stbt-debug/match/00002/level2-template.png
            stbt-debug/match/00002/match0-confirm-absdiff.png
            stbt-debug/match/00002/match0-confirm-absdiff_threshold_erode.png
            stbt-debug/match/00002/match0-confirm-absdiff_threshold.png
            stbt-debug/match/00002/match0-confirm-source_roi_gray_normalized.png
            stbt-debug/match/00002/match0-confirm-source_roi_gray.png
            stbt-debug/match/00002/match0-confirm-source_roi.png
            stbt-debug/match/00002/match0-confirm-template_gray_normalized.png
            stbt-debug/match/00002/match0-confirm-template_gray.png
            stbt-debug/match/00002/match0-heatmap.png
            stbt-debug/match/00002/match0-source_with_match.png
            stbt-debug/match/00002/match1-confirm-absdiff.png
            stbt-debug/match/00002/match1-confirm-absdiff_threshold_erode.png
            stbt-debug/match/00002/match1-confirm-absdiff_threshold.png
            stbt-debug/match/00002/match1-confirm-source_roi_gray_normalized.png
            stbt-debug/match/00002/match1-confirm-source_roi_gray.png
            stbt-debug/match/00002/match1-confirm-source_roi.png
            stbt-debug/match/00002/match1-confirm-template_gray_normalized.png
            stbt-debug/match/00002/match1-confirm-template_gray.png
            stbt-debug/match/00002/match1-heatmap.png
            stbt-debug/match/00002/match1-source_with_match.png
            stbt-debug/match/00002/match2-confirm-absdiff.png
            stbt-debug/match/00002/match2-confirm-absdiff_threshold_erode.png
            stbt-debug/match/00002/match2-confirm-absdiff_threshold.png
            stbt-debug/match/00002/match2-confirm-source_roi_gray_normalized.png
            stbt-debug/match/00002/match2-confirm-source_roi_gray.png
            stbt-debug/match/00002/match2-confirm-source_roi.png
            stbt-debug/match/00002/match2-confirm-template_gray_normalized.png
            stbt-debug/match/00002/match2-confirm-template_gray.png
            stbt-debug/match/00002/match2-heatmap.png
            stbt-debug/match/00002/match2-source_with_match.png
            stbt-debug/match/00002/match3-confirm-absdiff.png
            stbt-debug/match/00002/match3-confirm-absdiff_threshold_erode.png
            stbt-debug/match/00002/match3-confirm-absdiff_threshold.png
            stbt-debug/match/00002/match3-confirm-source_roi_gray_normalized.png
            stbt-debug/match/00002/match3-confirm-source_roi_gray.png
            stbt-debug/match/00002/match3-confirm-source_roi.png
            stbt-debug/match/00002/match3-confirm-template_gray_normalized.png
            stbt-debug/match/00002/match3-confirm-template_gray.png
            stbt-debug/match/00002/match3-heatmap.png
            stbt-debug/match/00002/match3-source_with_match.png
            stbt-debug/match/00002/match4-confirm-absdiff.png
            stbt-debug/match/00002/match4-confirm-absdiff_threshold_erode.png
            stbt-debug/match/00002/match4-confirm-absdiff_threshold.png
            stbt-debug/match/00002/match4-confirm-source_roi_gray_normalized.png
            stbt-debug/match/00002/match4-confirm-source_roi_gray.png
            stbt-debug/match/00002/match4-confirm-source_roi.png
            stbt-debug/match/00002/match4-confirm-template_gray_normalized.png
            stbt-debug/match/00002/match4-confirm-template_gray.png
            stbt-debug/match/00002/match4-heatmap.png
            stbt-debug/match/00002/match4-source_with_match.png
            stbt-debug/match/00002/match5-confirm-absdiff.png
            stbt-debug/match/00002/match5-confirm-absdiff_threshold_erode.png
            stbt-debug/match/00002/match5-confirm-absdiff_threshold.png
            stbt-debug/match/00002/match5-confirm-source_roi_gray_normalized.png
            stbt-debug/match/00002/match5-confirm-source_roi_gray.png
            stbt-debug/match/00002/match5-confirm-source_roi.png
            stbt-debug/match/00002/match5-confirm-template_gray_normalized.png
            stbt-debug/match/00002/match5-confirm-template_gray.png
            stbt-debug/match/00002/match5-heatmap.png
            stbt-debug/match/00002/match5-source_with_match.png
            stbt-debug/match/00002/match6-heatmap.png
            stbt-debug/match/00002/match6-source_with_match.png
            stbt-debug/match/00002/source.png
            stbt-debug/match/00002/template.png
            stbt-debug/match/00003
            stbt-debug/match/00003/index.html
            stbt-debug/match/00003/level0-source_matchtemplate.png
            stbt-debug/match/00003/level0-source_matchtemplate_threshold.png
            stbt-debug/match/00003/level0-source.png
            stbt-debug/match/00003/level0-source_with_match.png
            stbt-debug/match/00003/level0-source_with_rois.png
            stbt-debug/match/00003/level0-template.png
            stbt-debug/match/00003/level1-source_matchtemplate.png
            stbt-debug/match/00003/level1-source_matchtemplate_threshold.png
            stbt-debug/match/00003/level1-source.png
            stbt-debug/match/00003/level1-source_with_match.png
            stbt-debug/match/00003/level1-source_with_rois.png
            stbt-debug/match/00003/level1-template.png
            stbt-debug/match/00003/level2-source_matchtemplate.png
            stbt-debug/match/00003/level2-source_matchtemplate_threshold.png
            stbt-debug/match/00003/level2-source.png
            stbt-debug/match/00003/level2-source_with_match.png
            stbt-debug/match/00003/level2-source_with_rois.png
            stbt-debug/match/00003/level2-template.png
            stbt-debug/match/00003/match0-confirm-absdiff.png
            stbt-debug/match/00003/match0-confirm-absdiff_threshold_erode.png
            stbt-debug/match/00003/match0-confirm-absdiff_threshold.png
            stbt-debug/match/00003/match0-confirm-source_roi_gray_normalized.png
            stbt-debug/match/00003/match0-confirm-source_roi_gray.png
            stbt-debug/match/00003/match0-confirm-source_roi.png
            stbt-debug/match/00003/match0-confirm-template_gray_normalized.png
            stbt-debug/match/00003/match0-confirm-template_gray.png
            stbt-debug/match/00003/match0-heatmap.png
            stbt-debug/match/00003/match0-source_with_match.png
            stbt-debug/match/00003/match1-confirm-absdiff.png
            stbt-debug/match/00003/match1-confirm-absdiff_threshold_erode.png
            stbt-debug/match/00003/match1-confirm-absdiff_threshold.png
            stbt-debug/match/00003/match1-confirm-source_roi_gray_normalized.png
            stbt-debug/match/00003/match1-confirm-source_roi_gray.png
            stbt-debug/match/00003/match1-confirm-source_roi.png
            stbt-debug/match/00003/match1-confirm-template_gray_normalized.png
            stbt-debug/match/00003/match1-confirm-template_gray.png
            stbt-debug/match/00003/match1-heatmap.png
            stbt-debug/match/00003/match1-source_with_match.png
            stbt-debug/match/00003/match2-confirm-absdiff.png
            stbt-debug/match/00003/match2-confirm-absdiff_threshold_erode.png
            stbt-debug/match/00003/match2-confirm-absdiff_threshold.png
            stbt-debug/match/00003/match2-confirm-source_roi_gray_normalized.png
            stbt-debug/match/00003/match2-confirm-source_roi_gray.png
            stbt-debug/match/00003/match2-confirm-source_roi.png
            stbt-debug/match/00003/match2-confirm-template_gray_normalized.png
            stbt-debug/match/00003/match2-confirm-template_gray.png
            stbt-debug/match/00003/match2-heatmap.png
            stbt-debug/match/00003/match2-source_with_match.png
            stbt-debug/match/00003/match3-confirm-absdiff.png
            stbt-debug/match/00003/match3-confirm-absdiff_threshold_erode.png
            stbt-debug/match/00003/match3-confirm-absdiff_threshold.png
            stbt-debug/match/00003/match3-confirm-source_roi_gray_normalized.png
            stbt-debug/match/00003/match3-confirm-source_roi_gray.png
            stbt-debug/match/00003/match3-confirm-source_roi.png
            stbt-debug/match/00003/match3-confirm-template_gray_normalized.png
            stbt-debug/match/00003/match3-confirm-template_gray.png
            stbt-debug/match/00003/match3-heatmap.png
            stbt-debug/match/00003/match3-source_with_match.png
            stbt-debug/match/00003/match4-confirm-absdiff.png
            stbt-debug/match/00003/match4-confirm-absdiff_threshold_erode.png
            stbt-debug/match/00003/match4-confirm-absdiff_threshold.png
            stbt-debug/match/00003/match4-confirm-source_roi_gray_normalized.png
            stbt-debug/match/00003/match4-confirm-source_roi_gray.png
            stbt-debug/match/00003/match4-confirm-source_roi.png
            stbt-debug/match/00003/match4-confirm-template_gray_normalized.png
            stbt-debug/match/00003/match4-confirm-template_gray.png
            stbt-debug/match/00003/match4-heatmap.png
            stbt-debug/match/00003/match4-source_with_match.png
            stbt-debug/match/00003/match5-confirm-absdiff.png
            stbt-debug/match/00003/match5-confirm-absdiff_threshold_erode.png
            stbt-debug/match/00003/match5-confirm-absdiff_threshold.png
            stbt-debug/match/00003/match5-confirm-source_roi_gray_normalized.png
            stbt-debug/match/00003/match5-confirm-source_roi_gray.png
            stbt-debug/match/00003/match5-confirm-source_roi.png
            stbt-debug/match/00003/match5-confirm-template_gray_normalized.png
            stbt-debug/match/00003/match5-confirm-template_gray.png
            stbt-debug/match/00003/match5-heatmap.png
            stbt-debug/match/00003/match5-source_with_match.png
            stbt-debug/match/00003/match6-confirm-absdiff.png
            stbt-debug/match/00003/match6-confirm-absdiff_threshold_erode.png
            stbt-debug/match/00003/match6-confirm-absdiff_threshold.png
            stbt-debug/match/00003/match6-confirm-source_roi_gray_normalized.png
            stbt-debug/match/00003/match6-confirm-source_roi_gray.png
            stbt-debug/match/00003/match6-confirm-source_roi.png
            stbt-debug/match/00003/match6-confirm-template_gray_normalized.png
            stbt-debug/match/00003/match6-confirm-template_gray.png
            stbt-debug/match/00003/match6-heatmap.png
            stbt-debug/match/00003/match6-source_with_match.png
            stbt-debug/match/00003/source.png
            stbt-debug/match/00003/template.png
            stbt-debug/match/00004
            stbt-debug/match/00004/index.html
            stbt-debug/match/00004/level0-source_matchtemplate.png
            stbt-debug/match/00004/level0-source_matchtemplate_threshold.png
            stbt-debug/match/00004/level0-source.png
            stbt-debug/match/00004/level0-source_with_match.png
            stbt-debug/match/00004/level0-source_with_rois.png
            stbt-debug/match/00004/level0-template.png
            stbt-debug/match/00004/level1-source_matchtemplate.png
            stbt-debug/match/00004/level1-source_matchtemplate_threshold.png
            stbt-debug/match/00004/level1-source.png
            stbt-debug/match/00004/level1-source_with_match.png
            stbt-debug/match/00004/level1-source_with_rois.png
            stbt-debug/match/00004/level1-template.png
            stbt-debug/match/00004/level2-source_matchtemplate.png
            stbt-debug/match/00004/level2-source_matchtemplate_threshold.png
            stbt-debug/match/00004/level2-source.png
            stbt-debug/match/00004/level2-source_with_match.png
            stbt-debug/match/00004/level2-source_with_rois.png
            stbt-debug/match/00004/level2-template.png
            stbt-debug/match/00004/match0-confirm-absdiff.png
            stbt-debug/match/00004/match0-confirm-absdiff_threshold_erode.png
            stbt-debug/match/00004/match0-confirm-absdiff_threshold.png
            stbt-debug/match/00004/match0-confirm-source_roi_gray.png
            stbt-debug/match/00004/match0-confirm-source_roi.png
            stbt-debug/match/00004/match0-confirm-template_gray.png
            stbt-debug/match/00004/match0-heatmap.png
            stbt-debug/match/00004/match0-source_with_match.png
            stbt-debug/match/00004/match1-confirm-absdiff.png
            stbt-debug/match/00004/match1-confirm-absdiff_threshold_erode.png
            stbt-debug/match/00004/match1-confirm-absdiff_threshold.png
            stbt-debug/match/00004/match1-confirm-source_roi_gray.png
            stbt-debug/match/00004/match1-confirm-source_roi.png
            stbt-debug/match/00004/match1-confirm-template_gray.png
            stbt-debug/match/00004/match1-heatmap.png
            stbt-debug/match/00004/match1-source_with_match.png
            stbt-debug/match/00004/match2-confirm-absdiff.png
            stbt-debug/match/00004/match2-confirm-absdiff_threshold_erode.png
            stbt-debug/match/00004/match2-confirm-absdiff_threshold.png
            stbt-debug/match/00004/match2-confirm-source_roi_gray.png
            stbt-debug/match/00004/match2-confirm-source_roi.png
            stbt-debug/match/00004/match2-confirm-template_gray.png
            stbt-debug/match/00004/match2-heatmap.png
            stbt-debug/match/00004/match2-source_with_match.png
            stbt-debug/match/00004/match3-confirm-absdiff.png
            stbt-debug/match/00004/match3-confirm-absdiff_threshold_erode.png
            stbt-debug/match/00004/match3-confirm-absdiff_threshold.png
            stbt-debug/match/00004/match3-confirm-source_roi_gray.png
            stbt-debug/match/00004/match3-confirm-source_roi.png
            stbt-debug/match/00004/match3-confirm-template_gray.png
            stbt-debug/match/00004/match3-heatmap.png
            stbt-debug/match/00004/match3-source_with_match.png
            stbt-debug/match/00004/match4-confirm-absdiff.png
            stbt-debug/match/00004/match4-confirm-absdiff_threshold_erode.png
            stbt-debug/match/00004/match4-confirm-absdiff_threshold.png
            stbt-debug/match/00004/match4-confirm-source_roi_gray.png
            stbt-debug/match/00004/match4-confirm-source_roi.png
            stbt-debug/match/00004/match4-confirm-template_gray.png
            stbt-debug/match/00004/match4-heatmap.png
            stbt-debug/match/00004/match4-source_with_match.png
            stbt-debug/match/00004/match5-confirm-absdiff.png
            stbt-debug/match/00004/match5-confirm-absdiff_threshold_erode.png
            stbt-debug/match/00004/match5-confirm-absdiff_threshold.png
            stbt-debug/match/00004/match5-confirm-source_roi_gray.png
            stbt-debug/match/00004/match5-confirm-source_roi.png
            stbt-debug/match/00004/match5-confirm-template_gray.png
            stbt-debug/match/00004/match5-heatmap.png
            stbt-debug/match/00004/match5-source_with_match.png
            stbt-debug/match/00004/match6-confirm-absdiff.png
            stbt-debug/match/00004/match6-confirm-absdiff_threshold_erode.png
            stbt-debug/match/00004/match6-confirm-absdiff_threshold.png
            stbt-debug/match/00004/match6-confirm-source_roi_gray.png
            stbt-debug/match/00004/match6-confirm-source_roi.png
            stbt-debug/match/00004/match6-confirm-template_gray.png
            stbt-debug/match/00004/match6-heatmap.png
            stbt-debug/match/00004/match6-source_with_match.png
            stbt-debug/match/00004/source.png
            stbt-debug/match/00004/template.png
            """)

        subprocess.check_call([
            "diff",
            "-u",
            "--exclude=*.png",
            # The exact output of cv2.matchtemplate isn't deterministic across
            # different versions of OpenCV:
            r"--ignore-matching-lines=0\.99",
            "--ignore-matching-lines=Region",
            expected,
            "stbt-debug"
        ])
コード例 #14
0
ファイル: test_match.py プロジェクト: stb-tester/stb-tester
def test_that_if_image_doesnt_match_match_all_returns_empty_array(match_method):
    assert [] == list(stbt.match_all(
        'button.png', frame=stbt.load_image('black-full-frame.png'),
        match_parameters=mp(match_method=match_method)))
コード例 #15
0
ファイル: test_match.py プロジェクト: stb-tester/stb-tester
def test_that_match_all_finds_all_matches(match_method):
    matches = list(m.region for m in stbt.match_all(
        'button.png', frame=stbt.load_image('buttons.png'),
        match_parameters=mp(match_method=match_method)))
    print matches
    assert plain_buttons == sorted(matches)
コード例 #16
0
def test_match_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

    with scoped_curdir(), scoped_debug_level(2):
        # First pass gives no matches:
        matches = list(
            stbt.match_all(
                "videotestsrc-redblue-flipped.png",
                frame=stbt.load_image("videotestsrc-full-frame.png")))
        print(matches)
        assert len(matches) == 0

        # Multiple matches; first pass stops with a non-match:
        matches = list(
            stbt.match_all("button.png",
                           frame=stbt.load_image("buttons.png"),
                           match_parameters=mp(match_threshold=0.995)))
        print(matches)
        assert len(matches) == 6

        # Multiple matches; second pass stops with a non-match:
        matches = list(
            stbt.match_all("button.png", frame=stbt.load_image("buttons.png")))
        print(matches)
        assert len(matches) == 6

        # With absdiff:
        matches = list(
            stbt.match_all("button.png",
                           frame=stbt.load_image("buttons.png"),
                           match_parameters=mp(confirm_method="absdiff",
                                               confirm_threshold=0.84)))
        print(matches)
        assert len(matches) == 6

        files = subprocess.check_output("find stbt-debug | sort", shell=True) \
                          .decode("utf-8")
        assert files == dedent("""\
            stbt-debug
            stbt-debug/00001
            stbt-debug/00001/index.html
            stbt-debug/00001/level2-source_matchtemplate.png
            stbt-debug/00001/level2-source.png
            stbt-debug/00001/level2-source_with_match.png
            stbt-debug/00001/level2-source_with_rois.png
            stbt-debug/00001/level2-template.png
            stbt-debug/00001/match0-heatmap.png
            stbt-debug/00001/match0-source_with_match.png
            stbt-debug/00001/source.png
            stbt-debug/00001/source_with_matches.png
            stbt-debug/00001/template.png
            stbt-debug/00002
            stbt-debug/00002/index.html
            stbt-debug/00002/level0-source_matchtemplate.png
            stbt-debug/00002/level0-source_matchtemplate_threshold.png
            stbt-debug/00002/level0-source.png
            stbt-debug/00002/level0-source_with_match.png
            stbt-debug/00002/level0-source_with_rois.png
            stbt-debug/00002/level0-template.png
            stbt-debug/00002/level1-source_matchtemplate.png
            stbt-debug/00002/level1-source_matchtemplate_threshold.png
            stbt-debug/00002/level1-source.png
            stbt-debug/00002/level1-source_with_match.png
            stbt-debug/00002/level1-source_with_rois.png
            stbt-debug/00002/level1-template.png
            stbt-debug/00002/level2-source_matchtemplate.png
            stbt-debug/00002/level2-source_matchtemplate_threshold.png
            stbt-debug/00002/level2-source.png
            stbt-debug/00002/level2-source_with_match.png
            stbt-debug/00002/level2-source_with_rois.png
            stbt-debug/00002/level2-template.png
            stbt-debug/00002/match0-confirm-absdiff.png
            stbt-debug/00002/match0-confirm-absdiff_threshold_erode.png
            stbt-debug/00002/match0-confirm-absdiff_threshold.png
            stbt-debug/00002/match0-confirm-source_roi_gray_normalized.png
            stbt-debug/00002/match0-confirm-source_roi_gray.png
            stbt-debug/00002/match0-confirm-source_roi.png
            stbt-debug/00002/match0-confirm-template_gray_normalized.png
            stbt-debug/00002/match0-confirm-template_gray.png
            stbt-debug/00002/match0-heatmap.png
            stbt-debug/00002/match0-source_with_match.png
            stbt-debug/00002/match1-confirm-absdiff.png
            stbt-debug/00002/match1-confirm-absdiff_threshold_erode.png
            stbt-debug/00002/match1-confirm-absdiff_threshold.png
            stbt-debug/00002/match1-confirm-source_roi_gray_normalized.png
            stbt-debug/00002/match1-confirm-source_roi_gray.png
            stbt-debug/00002/match1-confirm-source_roi.png
            stbt-debug/00002/match1-confirm-template_gray_normalized.png
            stbt-debug/00002/match1-confirm-template_gray.png
            stbt-debug/00002/match1-heatmap.png
            stbt-debug/00002/match1-source_with_match.png
            stbt-debug/00002/match2-confirm-absdiff.png
            stbt-debug/00002/match2-confirm-absdiff_threshold_erode.png
            stbt-debug/00002/match2-confirm-absdiff_threshold.png
            stbt-debug/00002/match2-confirm-source_roi_gray_normalized.png
            stbt-debug/00002/match2-confirm-source_roi_gray.png
            stbt-debug/00002/match2-confirm-source_roi.png
            stbt-debug/00002/match2-confirm-template_gray_normalized.png
            stbt-debug/00002/match2-confirm-template_gray.png
            stbt-debug/00002/match2-heatmap.png
            stbt-debug/00002/match2-source_with_match.png
            stbt-debug/00002/match3-confirm-absdiff.png
            stbt-debug/00002/match3-confirm-absdiff_threshold_erode.png
            stbt-debug/00002/match3-confirm-absdiff_threshold.png
            stbt-debug/00002/match3-confirm-source_roi_gray_normalized.png
            stbt-debug/00002/match3-confirm-source_roi_gray.png
            stbt-debug/00002/match3-confirm-source_roi.png
            stbt-debug/00002/match3-confirm-template_gray_normalized.png
            stbt-debug/00002/match3-confirm-template_gray.png
            stbt-debug/00002/match3-heatmap.png
            stbt-debug/00002/match3-source_with_match.png
            stbt-debug/00002/match4-confirm-absdiff.png
            stbt-debug/00002/match4-confirm-absdiff_threshold_erode.png
            stbt-debug/00002/match4-confirm-absdiff_threshold.png
            stbt-debug/00002/match4-confirm-source_roi_gray_normalized.png
            stbt-debug/00002/match4-confirm-source_roi_gray.png
            stbt-debug/00002/match4-confirm-source_roi.png
            stbt-debug/00002/match4-confirm-template_gray_normalized.png
            stbt-debug/00002/match4-confirm-template_gray.png
            stbt-debug/00002/match4-heatmap.png
            stbt-debug/00002/match4-source_with_match.png
            stbt-debug/00002/match5-confirm-absdiff.png
            stbt-debug/00002/match5-confirm-absdiff_threshold_erode.png
            stbt-debug/00002/match5-confirm-absdiff_threshold.png
            stbt-debug/00002/match5-confirm-source_roi_gray_normalized.png
            stbt-debug/00002/match5-confirm-source_roi_gray.png
            stbt-debug/00002/match5-confirm-source_roi.png
            stbt-debug/00002/match5-confirm-template_gray_normalized.png
            stbt-debug/00002/match5-confirm-template_gray.png
            stbt-debug/00002/match5-heatmap.png
            stbt-debug/00002/match5-source_with_match.png
            stbt-debug/00002/match6-heatmap.png
            stbt-debug/00002/match6-source_with_match.png
            stbt-debug/00002/source.png
            stbt-debug/00002/source_with_matches.png
            stbt-debug/00002/template.png
            stbt-debug/00003
            stbt-debug/00003/index.html
            stbt-debug/00003/level0-source_matchtemplate.png
            stbt-debug/00003/level0-source_matchtemplate_threshold.png
            stbt-debug/00003/level0-source.png
            stbt-debug/00003/level0-source_with_match.png
            stbt-debug/00003/level0-source_with_rois.png
            stbt-debug/00003/level0-template.png
            stbt-debug/00003/level1-source_matchtemplate.png
            stbt-debug/00003/level1-source_matchtemplate_threshold.png
            stbt-debug/00003/level1-source.png
            stbt-debug/00003/level1-source_with_match.png
            stbt-debug/00003/level1-source_with_rois.png
            stbt-debug/00003/level1-template.png
            stbt-debug/00003/level2-source_matchtemplate.png
            stbt-debug/00003/level2-source_matchtemplate_threshold.png
            stbt-debug/00003/level2-source.png
            stbt-debug/00003/level2-source_with_match.png
            stbt-debug/00003/level2-source_with_rois.png
            stbt-debug/00003/level2-template.png
            stbt-debug/00003/match0-confirm-absdiff.png
            stbt-debug/00003/match0-confirm-absdiff_threshold_erode.png
            stbt-debug/00003/match0-confirm-absdiff_threshold.png
            stbt-debug/00003/match0-confirm-source_roi_gray_normalized.png
            stbt-debug/00003/match0-confirm-source_roi_gray.png
            stbt-debug/00003/match0-confirm-source_roi.png
            stbt-debug/00003/match0-confirm-template_gray_normalized.png
            stbt-debug/00003/match0-confirm-template_gray.png
            stbt-debug/00003/match0-heatmap.png
            stbt-debug/00003/match0-source_with_match.png
            stbt-debug/00003/match1-confirm-absdiff.png
            stbt-debug/00003/match1-confirm-absdiff_threshold_erode.png
            stbt-debug/00003/match1-confirm-absdiff_threshold.png
            stbt-debug/00003/match1-confirm-source_roi_gray_normalized.png
            stbt-debug/00003/match1-confirm-source_roi_gray.png
            stbt-debug/00003/match1-confirm-source_roi.png
            stbt-debug/00003/match1-confirm-template_gray_normalized.png
            stbt-debug/00003/match1-confirm-template_gray.png
            stbt-debug/00003/match1-heatmap.png
            stbt-debug/00003/match1-source_with_match.png
            stbt-debug/00003/match2-confirm-absdiff.png
            stbt-debug/00003/match2-confirm-absdiff_threshold_erode.png
            stbt-debug/00003/match2-confirm-absdiff_threshold.png
            stbt-debug/00003/match2-confirm-source_roi_gray_normalized.png
            stbt-debug/00003/match2-confirm-source_roi_gray.png
            stbt-debug/00003/match2-confirm-source_roi.png
            stbt-debug/00003/match2-confirm-template_gray_normalized.png
            stbt-debug/00003/match2-confirm-template_gray.png
            stbt-debug/00003/match2-heatmap.png
            stbt-debug/00003/match2-source_with_match.png
            stbt-debug/00003/match3-confirm-absdiff.png
            stbt-debug/00003/match3-confirm-absdiff_threshold_erode.png
            stbt-debug/00003/match3-confirm-absdiff_threshold.png
            stbt-debug/00003/match3-confirm-source_roi_gray_normalized.png
            stbt-debug/00003/match3-confirm-source_roi_gray.png
            stbt-debug/00003/match3-confirm-source_roi.png
            stbt-debug/00003/match3-confirm-template_gray_normalized.png
            stbt-debug/00003/match3-confirm-template_gray.png
            stbt-debug/00003/match3-heatmap.png
            stbt-debug/00003/match3-source_with_match.png
            stbt-debug/00003/match4-confirm-absdiff.png
            stbt-debug/00003/match4-confirm-absdiff_threshold_erode.png
            stbt-debug/00003/match4-confirm-absdiff_threshold.png
            stbt-debug/00003/match4-confirm-source_roi_gray_normalized.png
            stbt-debug/00003/match4-confirm-source_roi_gray.png
            stbt-debug/00003/match4-confirm-source_roi.png
            stbt-debug/00003/match4-confirm-template_gray_normalized.png
            stbt-debug/00003/match4-confirm-template_gray.png
            stbt-debug/00003/match4-heatmap.png
            stbt-debug/00003/match4-source_with_match.png
            stbt-debug/00003/match5-confirm-absdiff.png
            stbt-debug/00003/match5-confirm-absdiff_threshold_erode.png
            stbt-debug/00003/match5-confirm-absdiff_threshold.png
            stbt-debug/00003/match5-confirm-source_roi_gray_normalized.png
            stbt-debug/00003/match5-confirm-source_roi_gray.png
            stbt-debug/00003/match5-confirm-source_roi.png
            stbt-debug/00003/match5-confirm-template_gray_normalized.png
            stbt-debug/00003/match5-confirm-template_gray.png
            stbt-debug/00003/match5-heatmap.png
            stbt-debug/00003/match5-source_with_match.png
            stbt-debug/00003/match6-confirm-absdiff.png
            stbt-debug/00003/match6-confirm-absdiff_threshold_erode.png
            stbt-debug/00003/match6-confirm-absdiff_threshold.png
            stbt-debug/00003/match6-confirm-source_roi_gray_normalized.png
            stbt-debug/00003/match6-confirm-source_roi_gray.png
            stbt-debug/00003/match6-confirm-source_roi.png
            stbt-debug/00003/match6-confirm-template_gray_normalized.png
            stbt-debug/00003/match6-confirm-template_gray.png
            stbt-debug/00003/match6-heatmap.png
            stbt-debug/00003/match6-source_with_match.png
            stbt-debug/00003/source.png
            stbt-debug/00003/source_with_matches.png
            stbt-debug/00003/template.png
            stbt-debug/00004
            stbt-debug/00004/index.html
            stbt-debug/00004/level0-source_matchtemplate.png
            stbt-debug/00004/level0-source_matchtemplate_threshold.png
            stbt-debug/00004/level0-source.png
            stbt-debug/00004/level0-source_with_match.png
            stbt-debug/00004/level0-source_with_rois.png
            stbt-debug/00004/level0-template.png
            stbt-debug/00004/level1-source_matchtemplate.png
            stbt-debug/00004/level1-source_matchtemplate_threshold.png
            stbt-debug/00004/level1-source.png
            stbt-debug/00004/level1-source_with_match.png
            stbt-debug/00004/level1-source_with_rois.png
            stbt-debug/00004/level1-template.png
            stbt-debug/00004/level2-source_matchtemplate.png
            stbt-debug/00004/level2-source_matchtemplate_threshold.png
            stbt-debug/00004/level2-source.png
            stbt-debug/00004/level2-source_with_match.png
            stbt-debug/00004/level2-source_with_rois.png
            stbt-debug/00004/level2-template.png
            stbt-debug/00004/match0-confirm-absdiff.png
            stbt-debug/00004/match0-confirm-absdiff_threshold_erode.png
            stbt-debug/00004/match0-confirm-absdiff_threshold.png
            stbt-debug/00004/match0-confirm-source_roi_gray.png
            stbt-debug/00004/match0-confirm-source_roi.png
            stbt-debug/00004/match0-confirm-template_gray.png
            stbt-debug/00004/match0-heatmap.png
            stbt-debug/00004/match0-source_with_match.png
            stbt-debug/00004/match1-confirm-absdiff.png
            stbt-debug/00004/match1-confirm-absdiff_threshold_erode.png
            stbt-debug/00004/match1-confirm-absdiff_threshold.png
            stbt-debug/00004/match1-confirm-source_roi_gray.png
            stbt-debug/00004/match1-confirm-source_roi.png
            stbt-debug/00004/match1-confirm-template_gray.png
            stbt-debug/00004/match1-heatmap.png
            stbt-debug/00004/match1-source_with_match.png
            stbt-debug/00004/match2-confirm-absdiff.png
            stbt-debug/00004/match2-confirm-absdiff_threshold_erode.png
            stbt-debug/00004/match2-confirm-absdiff_threshold.png
            stbt-debug/00004/match2-confirm-source_roi_gray.png
            stbt-debug/00004/match2-confirm-source_roi.png
            stbt-debug/00004/match2-confirm-template_gray.png
            stbt-debug/00004/match2-heatmap.png
            stbt-debug/00004/match2-source_with_match.png
            stbt-debug/00004/match3-confirm-absdiff.png
            stbt-debug/00004/match3-confirm-absdiff_threshold_erode.png
            stbt-debug/00004/match3-confirm-absdiff_threshold.png
            stbt-debug/00004/match3-confirm-source_roi_gray.png
            stbt-debug/00004/match3-confirm-source_roi.png
            stbt-debug/00004/match3-confirm-template_gray.png
            stbt-debug/00004/match3-heatmap.png
            stbt-debug/00004/match3-source_with_match.png
            stbt-debug/00004/match4-confirm-absdiff.png
            stbt-debug/00004/match4-confirm-absdiff_threshold_erode.png
            stbt-debug/00004/match4-confirm-absdiff_threshold.png
            stbt-debug/00004/match4-confirm-source_roi_gray.png
            stbt-debug/00004/match4-confirm-source_roi.png
            stbt-debug/00004/match4-confirm-template_gray.png
            stbt-debug/00004/match4-heatmap.png
            stbt-debug/00004/match4-source_with_match.png
            stbt-debug/00004/match5-confirm-absdiff.png
            stbt-debug/00004/match5-confirm-absdiff_threshold_erode.png
            stbt-debug/00004/match5-confirm-absdiff_threshold.png
            stbt-debug/00004/match5-confirm-source_roi_gray.png
            stbt-debug/00004/match5-confirm-source_roi.png
            stbt-debug/00004/match5-confirm-template_gray.png
            stbt-debug/00004/match5-heatmap.png
            stbt-debug/00004/match5-source_with_match.png
            stbt-debug/00004/match6-confirm-absdiff.png
            stbt-debug/00004/match6-confirm-absdiff_threshold_erode.png
            stbt-debug/00004/match6-confirm-absdiff_threshold.png
            stbt-debug/00004/match6-confirm-source_roi_gray.png
            stbt-debug/00004/match6-confirm-source_roi.png
            stbt-debug/00004/match6-confirm-template_gray.png
            stbt-debug/00004/match6-heatmap.png
            stbt-debug/00004/match6-source_with_match.png
            stbt-debug/00004/source.png
            stbt-debug/00004/source_with_matches.png
            stbt-debug/00004/template.png
            """)

        assert_expected("stbt-debug-expected-output/match")
コード例 #17
0
 def match_all():
     return list(stbt.match_all('tests/button.png', frame=frame))
コード例 #18
0
 def match_all():
     return list(stbt.match_all('tests/button.png', frame=frame))
コード例 #19
0
def test_that_if_image_doesnt_match_match_all_returns_empty_array():
    assert [] == list(stbt.match_all(
        'button.png', frame=_imread('black-full-frame.png')))
コード例 #20
0
def test_completely_transparent_reference_image():
    f = stbt.load_image("buttons-on-blue-background.png")
    assert len(list(stbt.match_all("completely-transparent.png",
                                   frame=f))) == 18
コード例 #21
0
def test_match_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

    with scoped_curdir(), scoped_debug_level(2):
        # First pass gives no matches:
        matches = list(stbt.match_all(
            "videotestsrc-redblue-flipped.png",
            frame=stbt.load_image("videotestsrc-full-frame.png")))
        print matches
        assert len(matches) == 0

        # Multiple matches; first pass stops with a non-match:
        matches = list(stbt.match_all(
            "button.png", frame=stbt.load_image("buttons.png"),
            match_parameters=mp(match_threshold=0.995)))
        print matches
        assert len(matches) == 6

        # Multiple matches; second pass stops with a non-match:
        matches = list(stbt.match_all(
            "button.png", frame=stbt.load_image("buttons.png")))
        print matches
        assert len(matches) == 6

        # With absdiff:
        matches = list(stbt.match_all(
            "button.png", frame=stbt.load_image("buttons.png"),
            match_parameters=mp(confirm_method="absdiff",
                                confirm_threshold=0.84)))
        print matches
        assert len(matches) == 6

        files = subprocess.check_output("find stbt-debug | sort", shell=True)
        assert files == dedent("""\
            stbt-debug
            stbt-debug/00001
            stbt-debug/00001/index.html
            stbt-debug/00001/level2-source_matchtemplate.png
            stbt-debug/00001/level2-source.png
            stbt-debug/00001/level2-source_with_match.png
            stbt-debug/00001/level2-source_with_rois.png
            stbt-debug/00001/level2-template.png
            stbt-debug/00001/match0-heatmap.png
            stbt-debug/00001/match0-source_with_match.png
            stbt-debug/00001/source.png
            stbt-debug/00001/source_with_matches.png
            stbt-debug/00001/template.png
            stbt-debug/00002
            stbt-debug/00002/index.html
            stbt-debug/00002/level0-source_matchtemplate.png
            stbt-debug/00002/level0-source_matchtemplate_threshold.png
            stbt-debug/00002/level0-source.png
            stbt-debug/00002/level0-source_with_match.png
            stbt-debug/00002/level0-source_with_rois.png
            stbt-debug/00002/level0-template.png
            stbt-debug/00002/level1-source_matchtemplate.png
            stbt-debug/00002/level1-source_matchtemplate_threshold.png
            stbt-debug/00002/level1-source.png
            stbt-debug/00002/level1-source_with_match.png
            stbt-debug/00002/level1-source_with_rois.png
            stbt-debug/00002/level1-template.png
            stbt-debug/00002/level2-source_matchtemplate.png
            stbt-debug/00002/level2-source_matchtemplate_threshold.png
            stbt-debug/00002/level2-source.png
            stbt-debug/00002/level2-source_with_match.png
            stbt-debug/00002/level2-source_with_rois.png
            stbt-debug/00002/level2-template.png
            stbt-debug/00002/match0-confirm-absdiff.png
            stbt-debug/00002/match0-confirm-absdiff_threshold_erode.png
            stbt-debug/00002/match0-confirm-absdiff_threshold.png
            stbt-debug/00002/match0-confirm-source_roi_gray_normalized.png
            stbt-debug/00002/match0-confirm-source_roi_gray.png
            stbt-debug/00002/match0-confirm-source_roi.png
            stbt-debug/00002/match0-confirm-template_gray_normalized.png
            stbt-debug/00002/match0-confirm-template_gray.png
            stbt-debug/00002/match0-heatmap.png
            stbt-debug/00002/match0-source_with_match.png
            stbt-debug/00002/match1-confirm-absdiff.png
            stbt-debug/00002/match1-confirm-absdiff_threshold_erode.png
            stbt-debug/00002/match1-confirm-absdiff_threshold.png
            stbt-debug/00002/match1-confirm-source_roi_gray_normalized.png
            stbt-debug/00002/match1-confirm-source_roi_gray.png
            stbt-debug/00002/match1-confirm-source_roi.png
            stbt-debug/00002/match1-confirm-template_gray_normalized.png
            stbt-debug/00002/match1-confirm-template_gray.png
            stbt-debug/00002/match1-heatmap.png
            stbt-debug/00002/match1-source_with_match.png
            stbt-debug/00002/match2-confirm-absdiff.png
            stbt-debug/00002/match2-confirm-absdiff_threshold_erode.png
            stbt-debug/00002/match2-confirm-absdiff_threshold.png
            stbt-debug/00002/match2-confirm-source_roi_gray_normalized.png
            stbt-debug/00002/match2-confirm-source_roi_gray.png
            stbt-debug/00002/match2-confirm-source_roi.png
            stbt-debug/00002/match2-confirm-template_gray_normalized.png
            stbt-debug/00002/match2-confirm-template_gray.png
            stbt-debug/00002/match2-heatmap.png
            stbt-debug/00002/match2-source_with_match.png
            stbt-debug/00002/match3-confirm-absdiff.png
            stbt-debug/00002/match3-confirm-absdiff_threshold_erode.png
            stbt-debug/00002/match3-confirm-absdiff_threshold.png
            stbt-debug/00002/match3-confirm-source_roi_gray_normalized.png
            stbt-debug/00002/match3-confirm-source_roi_gray.png
            stbt-debug/00002/match3-confirm-source_roi.png
            stbt-debug/00002/match3-confirm-template_gray_normalized.png
            stbt-debug/00002/match3-confirm-template_gray.png
            stbt-debug/00002/match3-heatmap.png
            stbt-debug/00002/match3-source_with_match.png
            stbt-debug/00002/match4-confirm-absdiff.png
            stbt-debug/00002/match4-confirm-absdiff_threshold_erode.png
            stbt-debug/00002/match4-confirm-absdiff_threshold.png
            stbt-debug/00002/match4-confirm-source_roi_gray_normalized.png
            stbt-debug/00002/match4-confirm-source_roi_gray.png
            stbt-debug/00002/match4-confirm-source_roi.png
            stbt-debug/00002/match4-confirm-template_gray_normalized.png
            stbt-debug/00002/match4-confirm-template_gray.png
            stbt-debug/00002/match4-heatmap.png
            stbt-debug/00002/match4-source_with_match.png
            stbt-debug/00002/match5-confirm-absdiff.png
            stbt-debug/00002/match5-confirm-absdiff_threshold_erode.png
            stbt-debug/00002/match5-confirm-absdiff_threshold.png
            stbt-debug/00002/match5-confirm-source_roi_gray_normalized.png
            stbt-debug/00002/match5-confirm-source_roi_gray.png
            stbt-debug/00002/match5-confirm-source_roi.png
            stbt-debug/00002/match5-confirm-template_gray_normalized.png
            stbt-debug/00002/match5-confirm-template_gray.png
            stbt-debug/00002/match5-heatmap.png
            stbt-debug/00002/match5-source_with_match.png
            stbt-debug/00002/match6-heatmap.png
            stbt-debug/00002/match6-source_with_match.png
            stbt-debug/00002/source.png
            stbt-debug/00002/source_with_matches.png
            stbt-debug/00002/template.png
            stbt-debug/00003
            stbt-debug/00003/index.html
            stbt-debug/00003/level0-source_matchtemplate.png
            stbt-debug/00003/level0-source_matchtemplate_threshold.png
            stbt-debug/00003/level0-source.png
            stbt-debug/00003/level0-source_with_match.png
            stbt-debug/00003/level0-source_with_rois.png
            stbt-debug/00003/level0-template.png
            stbt-debug/00003/level1-source_matchtemplate.png
            stbt-debug/00003/level1-source_matchtemplate_threshold.png
            stbt-debug/00003/level1-source.png
            stbt-debug/00003/level1-source_with_match.png
            stbt-debug/00003/level1-source_with_rois.png
            stbt-debug/00003/level1-template.png
            stbt-debug/00003/level2-source_matchtemplate.png
            stbt-debug/00003/level2-source_matchtemplate_threshold.png
            stbt-debug/00003/level2-source.png
            stbt-debug/00003/level2-source_with_match.png
            stbt-debug/00003/level2-source_with_rois.png
            stbt-debug/00003/level2-template.png
            stbt-debug/00003/match0-confirm-absdiff.png
            stbt-debug/00003/match0-confirm-absdiff_threshold_erode.png
            stbt-debug/00003/match0-confirm-absdiff_threshold.png
            stbt-debug/00003/match0-confirm-source_roi_gray_normalized.png
            stbt-debug/00003/match0-confirm-source_roi_gray.png
            stbt-debug/00003/match0-confirm-source_roi.png
            stbt-debug/00003/match0-confirm-template_gray_normalized.png
            stbt-debug/00003/match0-confirm-template_gray.png
            stbt-debug/00003/match0-heatmap.png
            stbt-debug/00003/match0-source_with_match.png
            stbt-debug/00003/match1-confirm-absdiff.png
            stbt-debug/00003/match1-confirm-absdiff_threshold_erode.png
            stbt-debug/00003/match1-confirm-absdiff_threshold.png
            stbt-debug/00003/match1-confirm-source_roi_gray_normalized.png
            stbt-debug/00003/match1-confirm-source_roi_gray.png
            stbt-debug/00003/match1-confirm-source_roi.png
            stbt-debug/00003/match1-confirm-template_gray_normalized.png
            stbt-debug/00003/match1-confirm-template_gray.png
            stbt-debug/00003/match1-heatmap.png
            stbt-debug/00003/match1-source_with_match.png
            stbt-debug/00003/match2-confirm-absdiff.png
            stbt-debug/00003/match2-confirm-absdiff_threshold_erode.png
            stbt-debug/00003/match2-confirm-absdiff_threshold.png
            stbt-debug/00003/match2-confirm-source_roi_gray_normalized.png
            stbt-debug/00003/match2-confirm-source_roi_gray.png
            stbt-debug/00003/match2-confirm-source_roi.png
            stbt-debug/00003/match2-confirm-template_gray_normalized.png
            stbt-debug/00003/match2-confirm-template_gray.png
            stbt-debug/00003/match2-heatmap.png
            stbt-debug/00003/match2-source_with_match.png
            stbt-debug/00003/match3-confirm-absdiff.png
            stbt-debug/00003/match3-confirm-absdiff_threshold_erode.png
            stbt-debug/00003/match3-confirm-absdiff_threshold.png
            stbt-debug/00003/match3-confirm-source_roi_gray_normalized.png
            stbt-debug/00003/match3-confirm-source_roi_gray.png
            stbt-debug/00003/match3-confirm-source_roi.png
            stbt-debug/00003/match3-confirm-template_gray_normalized.png
            stbt-debug/00003/match3-confirm-template_gray.png
            stbt-debug/00003/match3-heatmap.png
            stbt-debug/00003/match3-source_with_match.png
            stbt-debug/00003/match4-confirm-absdiff.png
            stbt-debug/00003/match4-confirm-absdiff_threshold_erode.png
            stbt-debug/00003/match4-confirm-absdiff_threshold.png
            stbt-debug/00003/match4-confirm-source_roi_gray_normalized.png
            stbt-debug/00003/match4-confirm-source_roi_gray.png
            stbt-debug/00003/match4-confirm-source_roi.png
            stbt-debug/00003/match4-confirm-template_gray_normalized.png
            stbt-debug/00003/match4-confirm-template_gray.png
            stbt-debug/00003/match4-heatmap.png
            stbt-debug/00003/match4-source_with_match.png
            stbt-debug/00003/match5-confirm-absdiff.png
            stbt-debug/00003/match5-confirm-absdiff_threshold_erode.png
            stbt-debug/00003/match5-confirm-absdiff_threshold.png
            stbt-debug/00003/match5-confirm-source_roi_gray_normalized.png
            stbt-debug/00003/match5-confirm-source_roi_gray.png
            stbt-debug/00003/match5-confirm-source_roi.png
            stbt-debug/00003/match5-confirm-template_gray_normalized.png
            stbt-debug/00003/match5-confirm-template_gray.png
            stbt-debug/00003/match5-heatmap.png
            stbt-debug/00003/match5-source_with_match.png
            stbt-debug/00003/match6-confirm-absdiff.png
            stbt-debug/00003/match6-confirm-absdiff_threshold_erode.png
            stbt-debug/00003/match6-confirm-absdiff_threshold.png
            stbt-debug/00003/match6-confirm-source_roi_gray_normalized.png
            stbt-debug/00003/match6-confirm-source_roi_gray.png
            stbt-debug/00003/match6-confirm-source_roi.png
            stbt-debug/00003/match6-confirm-template_gray_normalized.png
            stbt-debug/00003/match6-confirm-template_gray.png
            stbt-debug/00003/match6-heatmap.png
            stbt-debug/00003/match6-source_with_match.png
            stbt-debug/00003/source.png
            stbt-debug/00003/source_with_matches.png
            stbt-debug/00003/template.png
            stbt-debug/00004
            stbt-debug/00004/index.html
            stbt-debug/00004/level0-source_matchtemplate.png
            stbt-debug/00004/level0-source_matchtemplate_threshold.png
            stbt-debug/00004/level0-source.png
            stbt-debug/00004/level0-source_with_match.png
            stbt-debug/00004/level0-source_with_rois.png
            stbt-debug/00004/level0-template.png
            stbt-debug/00004/level1-source_matchtemplate.png
            stbt-debug/00004/level1-source_matchtemplate_threshold.png
            stbt-debug/00004/level1-source.png
            stbt-debug/00004/level1-source_with_match.png
            stbt-debug/00004/level1-source_with_rois.png
            stbt-debug/00004/level1-template.png
            stbt-debug/00004/level2-source_matchtemplate.png
            stbt-debug/00004/level2-source_matchtemplate_threshold.png
            stbt-debug/00004/level2-source.png
            stbt-debug/00004/level2-source_with_match.png
            stbt-debug/00004/level2-source_with_rois.png
            stbt-debug/00004/level2-template.png
            stbt-debug/00004/match0-confirm-absdiff.png
            stbt-debug/00004/match0-confirm-absdiff_threshold_erode.png
            stbt-debug/00004/match0-confirm-absdiff_threshold.png
            stbt-debug/00004/match0-confirm-source_roi_gray.png
            stbt-debug/00004/match0-confirm-source_roi.png
            stbt-debug/00004/match0-confirm-template_gray.png
            stbt-debug/00004/match0-heatmap.png
            stbt-debug/00004/match0-source_with_match.png
            stbt-debug/00004/match1-confirm-absdiff.png
            stbt-debug/00004/match1-confirm-absdiff_threshold_erode.png
            stbt-debug/00004/match1-confirm-absdiff_threshold.png
            stbt-debug/00004/match1-confirm-source_roi_gray.png
            stbt-debug/00004/match1-confirm-source_roi.png
            stbt-debug/00004/match1-confirm-template_gray.png
            stbt-debug/00004/match1-heatmap.png
            stbt-debug/00004/match1-source_with_match.png
            stbt-debug/00004/match2-confirm-absdiff.png
            stbt-debug/00004/match2-confirm-absdiff_threshold_erode.png
            stbt-debug/00004/match2-confirm-absdiff_threshold.png
            stbt-debug/00004/match2-confirm-source_roi_gray.png
            stbt-debug/00004/match2-confirm-source_roi.png
            stbt-debug/00004/match2-confirm-template_gray.png
            stbt-debug/00004/match2-heatmap.png
            stbt-debug/00004/match2-source_with_match.png
            stbt-debug/00004/match3-confirm-absdiff.png
            stbt-debug/00004/match3-confirm-absdiff_threshold_erode.png
            stbt-debug/00004/match3-confirm-absdiff_threshold.png
            stbt-debug/00004/match3-confirm-source_roi_gray.png
            stbt-debug/00004/match3-confirm-source_roi.png
            stbt-debug/00004/match3-confirm-template_gray.png
            stbt-debug/00004/match3-heatmap.png
            stbt-debug/00004/match3-source_with_match.png
            stbt-debug/00004/match4-confirm-absdiff.png
            stbt-debug/00004/match4-confirm-absdiff_threshold_erode.png
            stbt-debug/00004/match4-confirm-absdiff_threshold.png
            stbt-debug/00004/match4-confirm-source_roi_gray.png
            stbt-debug/00004/match4-confirm-source_roi.png
            stbt-debug/00004/match4-confirm-template_gray.png
            stbt-debug/00004/match4-heatmap.png
            stbt-debug/00004/match4-source_with_match.png
            stbt-debug/00004/match5-confirm-absdiff.png
            stbt-debug/00004/match5-confirm-absdiff_threshold_erode.png
            stbt-debug/00004/match5-confirm-absdiff_threshold.png
            stbt-debug/00004/match5-confirm-source_roi_gray.png
            stbt-debug/00004/match5-confirm-source_roi.png
            stbt-debug/00004/match5-confirm-template_gray.png
            stbt-debug/00004/match5-heatmap.png
            stbt-debug/00004/match5-source_with_match.png
            stbt-debug/00004/match6-confirm-absdiff.png
            stbt-debug/00004/match6-confirm-absdiff_threshold_erode.png
            stbt-debug/00004/match6-confirm-absdiff_threshold.png
            stbt-debug/00004/match6-confirm-source_roi_gray.png
            stbt-debug/00004/match6-confirm-source_roi.png
            stbt-debug/00004/match6-confirm-template_gray.png
            stbt-debug/00004/match6-heatmap.png
            stbt-debug/00004/match6-source_with_match.png
            stbt-debug/00004/source.png
            stbt-debug/00004/source_with_matches.png
            stbt-debug/00004/template.png
            """)

        assert_expected("stbt-debug-expected-output/match")
コード例 #22
0
def test_that_if_image_doesnt_match_match_all_returns_empty_array():
    assert [] == list(
        stbt.match_all('button.png', frame=_imread('black-full-frame.png')))
コード例 #23
0
ファイル: test_match.py プロジェクト: stb-tester/stb-tester
def test_completely_transparent_reference_image():
    f = stbt.load_image("buttons-on-blue-background.png")
    assert len(list(stbt.match_all(
        "completely-transparent.png", frame=f))) == 18
コード例 #24
0
def test_match_all_image_debug_with_normed_absdiff():
    with scoped_curdir(), scoped_debug_level(2):
        matches = list(stbt.match_all(
            "button.png", frame=_imread("buttons.png"),
            match_parameters=mp(confirm_method="normed-absdiff",
                                confirm_threshold=0.3)))
        print matches
        assert len(matches) == 6
        _verify_stbt_debug_dir([
            'index.html',
            'level0-source.png',
            'level0-source_matchtemplate.png',
            'level0-source_matchtemplate_threshold.png',
            'level0-source_with_match.png',
            'level0-source_with_rois.png',
            'level0-template.png',
            'level1-source.png',
            'level1-source_matchtemplate.png',
            'level1-source_matchtemplate_threshold.png',
            'level1-source_with_match.png',
            'level1-source_with_rois.png',
            'level1-template.png',
            'level2-source.png',
            'level2-source_matchtemplate.png',
            'level2-source_matchtemplate_threshold.png',
            'level2-source_with_match.png',
            'level2-source_with_rois.png',
            'level2-template.png',
            'match0-confirm-absdiff.png',
            'match0-confirm-absdiff_threshold.png',
            'match0-confirm-absdiff_threshold_erode.png',
            'match0-confirm-source_roi.png',
            'match0-confirm-source_roi_gray.png',
            'match0-confirm-source_roi_gray_normalized.png',
            'match0-confirm-template_gray.png',
            'match0-confirm-template_gray_normalized.png',
            'match0-heatmap.png',
            'match0-source_with_match.png',
            'match1-confirm-absdiff.png',
            'match1-confirm-absdiff_threshold.png',
            'match1-confirm-absdiff_threshold_erode.png',
            'match1-confirm-source_roi.png',
            'match1-confirm-source_roi_gray.png',
            'match1-confirm-source_roi_gray_normalized.png',
            'match1-confirm-template_gray.png',
            'match1-confirm-template_gray_normalized.png',
            'match1-heatmap.png',
            'match1-source_with_match.png',
            'match2-confirm-absdiff.png',
            'match2-confirm-absdiff_threshold.png',
            'match2-confirm-absdiff_threshold_erode.png',
            'match2-confirm-source_roi.png',
            'match2-confirm-source_roi_gray.png',
            'match2-confirm-source_roi_gray_normalized.png',
            'match2-confirm-template_gray.png',
            'match2-confirm-template_gray_normalized.png',
            'match2-heatmap.png',
            'match2-source_with_match.png',
            'match3-confirm-absdiff.png',
            'match3-confirm-absdiff_threshold.png',
            'match3-confirm-absdiff_threshold_erode.png',
            'match3-confirm-source_roi.png',
            'match3-confirm-source_roi_gray.png',
            'match3-confirm-source_roi_gray_normalized.png',
            'match3-confirm-template_gray.png',
            'match3-confirm-template_gray_normalized.png',
            'match3-heatmap.png',
            'match3-source_with_match.png',
            'match4-confirm-absdiff.png',
            'match4-confirm-absdiff_threshold.png',
            'match4-confirm-absdiff_threshold_erode.png',
            'match4-confirm-source_roi.png',
            'match4-confirm-source_roi_gray.png',
            'match4-confirm-source_roi_gray_normalized.png',
            'match4-confirm-template_gray.png',
            'match4-confirm-template_gray_normalized.png',
            'match4-heatmap.png',
            'match4-source_with_match.png',
            'match5-confirm-absdiff.png',
            'match5-confirm-absdiff_threshold.png',
            'match5-confirm-absdiff_threshold_erode.png',
            'match5-confirm-source_roi.png',
            'match5-confirm-source_roi_gray.png',
            'match5-confirm-source_roi_gray_normalized.png',
            'match5-confirm-template_gray.png',
            'match5-confirm-template_gray_normalized.png',
            'match5-heatmap.png',
            'match5-source_with_match.png',
            'match6-confirm-absdiff.png',
            'match6-confirm-absdiff_threshold.png',
            'match6-confirm-absdiff_threshold_erode.png',
            'match6-confirm-source_roi.png',
            'match6-confirm-source_roi_gray.png',
            'match6-confirm-source_roi_gray_normalized.png',
            'match6-confirm-template_gray.png',
            'match6-confirm-template_gray_normalized.png',
            'match6-heatmap.png',
            'match6-source_with_match.png',
            'source.png',
            'template.png'
        ])
コード例 #25
0
def test_match_all_image_debug_when_second_pass_stops_with_a_nonmatch():
    with scoped_curdir(), scoped_debug_level(2):
        matches = list(stbt.match_all(
            "button.png", frame=_imread("buttons.png")))
        print matches
        assert len(matches) == 6
        _verify_stbt_debug_dir([
            'index.html',
            'level0-source.png',
            'level0-source_matchtemplate.png',
            'level0-source_matchtemplate_threshold.png',
            'level0-source_with_match.png',
            'level0-source_with_rois.png',
            'level0-template.png',
            'level1-source.png',
            'level1-source_matchtemplate.png',
            'level1-source_matchtemplate_threshold.png',
            'level1-source_with_match.png',
            'level1-source_with_rois.png',
            'level1-template.png',
            'level2-source.png',
            'level2-source_matchtemplate.png',
            'level2-source_matchtemplate_threshold.png',
            'level2-source_with_match.png',
            'level2-source_with_rois.png',
            'level2-template.png',
            'match0-confirm-absdiff.png',
            'match0-confirm-absdiff_threshold.png',
            'match0-confirm-absdiff_threshold_erode.png',
            'match0-confirm-source_roi.png',
            'match0-confirm-source_roi_gray.png',
            'match0-confirm-template_gray.png',
            'match0-heatmap.png',
            'match0-source_with_match.png',
            'match1-confirm-absdiff.png',
            'match1-confirm-absdiff_threshold.png',
            'match1-confirm-absdiff_threshold_erode.png',
            'match1-confirm-source_roi.png',
            'match1-confirm-source_roi_gray.png',
            'match1-confirm-template_gray.png',
            'match1-heatmap.png',
            'match1-source_with_match.png',
            'match2-confirm-absdiff.png',
            'match2-confirm-absdiff_threshold.png',
            'match2-confirm-absdiff_threshold_erode.png',
            'match2-confirm-source_roi.png',
            'match2-confirm-source_roi_gray.png',
            'match2-confirm-template_gray.png',
            'match2-heatmap.png',
            'match2-source_with_match.png',
            'match3-confirm-absdiff.png',
            'match3-confirm-absdiff_threshold.png',
            'match3-confirm-absdiff_threshold_erode.png',
            'match3-confirm-source_roi.png',
            'match3-confirm-source_roi_gray.png',
            'match3-confirm-template_gray.png',
            'match3-heatmap.png',
            'match3-source_with_match.png',
            'match4-confirm-absdiff.png',
            'match4-confirm-absdiff_threshold.png',
            'match4-confirm-absdiff_threshold_erode.png',
            'match4-confirm-source_roi.png',
            'match4-confirm-source_roi_gray.png',
            'match4-confirm-template_gray.png',
            'match4-heatmap.png',
            'match4-source_with_match.png',
            'match5-confirm-absdiff.png',
            'match5-confirm-absdiff_threshold.png',
            'match5-confirm-absdiff_threshold_erode.png',
            'match5-confirm-source_roi.png',
            'match5-confirm-source_roi_gray.png',
            'match5-confirm-template_gray.png',
            'match5-heatmap.png',
            'match5-source_with_match.png',
            'match6-confirm-absdiff.png',
            'match6-confirm-absdiff_threshold.png',
            'match6-confirm-absdiff_threshold_erode.png',
            'match6-confirm-source_roi.png',
            'match6-confirm-source_roi_gray.png',
            'match6-confirm-template_gray.png',
            'match6-heatmap.png',
            'match6-source_with_match.png',
            'source.png',
            'template.png',
        ])
コード例 #26
0
def test_that_if_image_doesnt_match_match_all_returns_empty_array(
        match_method):
    assert [] == list(
        stbt.match_all('button.png',
                       frame=stbt.load_image('black-full-frame.png'),
                       match_parameters=mp(match_method=match_method)))