• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python stbt.match_text函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中stbt.match_text函数的典型用法代码示例。如果您正苦于以下问题:Python match_text函数的具体用法?Python match_text怎么用?Python match_text使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了match_text函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_that_ligatures_and_ambiguous_punctuation_are_normalised

def test_that_ligatures_and_ambiguous_punctuation_are_normalised():
    frame = cv2.imread('tests/ocr/ambig.png')
    text = stbt.ocr(frame)
    text = text.replace("horizonta|", "horizontal")  # for tesseract < 3.03
    assert ligature_text == text
    assert stbt.match_text("em-dash,", frame)
    assert stbt.match_text(u"em\u2014dash,", frame)
开发者ID:rinaldomerlo,项目名称:stb-tester,代码行数:7,代码来源:test_ocr.py


示例2: test_ocr_text_color

def test_ocr_text_color(image, color, expected, region):
    frame = load_image(image)
    mode = stbt.OcrMode.SINGLE_LINE

    assert expected not in stbt.ocr(frame, region, mode)
    assert expected == stbt.ocr(frame, region, mode, text_color=color)

    assert not stbt.match_text(expected, frame, region, mode)
    assert stbt.match_text(expected, frame, region, mode, text_color=color)
开发者ID:stb-tester,项目名称:stb-tester,代码行数:9,代码来源:test_ocr.py


示例3: test_that_ligatures_and_ambiguous_punctuation_are_normalised

def test_that_ligatures_and_ambiguous_punctuation_are_normalised():
    frame = load_image('ocr/ambig.png')
    text = stbt.ocr(frame)
    for bad, good in [
            # tesseract 3.02
            ("horizonta|", "horizontal"),
            # tesseract 4.00 with tessdata 590567f
            ("siIIyness", "sillyness"),
            ("Iigatures", "ligatures"),
    ]:
        text = text.replace(bad, good)
    assert ligature_text == text
    assert stbt.match_text("em-dash,", frame)
    assert stbt.match_text(u"em\u2014dash,", frame)
开发者ID:stb-tester,项目名称:stb-tester,代码行数:14,代码来源:test_ocr.py


示例4: test_that_match_text_gives_tesseract_a_hint

def test_that_match_text_gives_tesseract_a_hint():
    frame = cv2.imread("tests/ocr/itv-player.png")
    if "ITV Player" in stbt.ocr(frame=frame):
        raise SkipTest("Tesseract doesn't need a hint")
    if "ITV Player" not in stbt.ocr(frame=frame, tesseract_user_words=["ITV"]):
        raise SkipTest("Giving tesseract a hint doesn't help")
    assert stbt.match_text("ITV Player", frame=frame)
开发者ID:rinaldomerlo,项目名称:stb-tester,代码行数:7,代码来源:test_ocr.py


示例5: test_match_text_stringify_result

def test_match_text_stringify_result():
    frame = cv2.imread("tests/ocr/menu.png")
    result = stbt.match_text(u"Onion Bhaji", frame=frame)

    assert re.match(
        r"TextMatchResult\(timestamp=None, match=True, region=Region\(.*\), "
        r"frame=1280x720x3, text=u'Onion Bhaji'\)", str(result))
开发者ID:Winnetou,项目名称:stb-tester,代码行数:7,代码来源:test_ocr.py


示例6: test_that_match_text_still_returns_if_region_doesnt_intersect_with_frame

def test_that_match_text_still_returns_if_region_doesnt_intersect_with_frame(
        region):
    frame = load_image("ocr/menu.png")
    result = stbt.match_text("Onion Bhaji", frame=frame, region=region)
    assert result.match is False
    assert result.region is None
    assert result.text == "Onion Bhaji"
开发者ID:stb-tester,项目名称:stb-tester,代码行数:7,代码来源:test_ocr.py


示例7: test_that_match_text_still_returns_if_region_doesnt_intersect_with_frame

def test_that_match_text_still_returns_if_region_doesnt_intersect_with_frame():
    frame = cv2.imread("tests/ocr/menu.png")
    result = stbt.match_text("Onion Bhaji", frame=frame,
                             region=stbt.Region(1280, 0, 1280, 720))
    assert result.match is False
    assert result.region is None
    assert result.text == "Onion Bhaji"
开发者ID:Winnetou,项目名称:stb-tester,代码行数:7,代码来源:test_ocr.py


示例8: test_that_text_region_is_correct_even_with_regions_larger_than_frame

def test_that_text_region_is_correct_even_with_regions_larger_than_frame():
    frame = cv2.imread("tests/ocr/menu.png")
    text, region, _ = list(iterate_menu())[6]
    result = stbt.match_text(
        text, frame=frame, region=region.extend(right=+12800))
    assert result
    assert region.contains(result.region)
开发者ID:Winnetou,项目名称:stb-tester,代码行数:7,代码来源:test_ocr.py


示例9: test_match_text_stringify_result

def test_match_text_stringify_result():
    frame = load_image("ocr/menu.png")
    result = stbt.match_text(u"Onion Bhaji", frame=frame)

    assert re.match(
        r"TextMatchResult\(time=None, match=True, region=Region\(.*\), "
        r"frame=<1280x720x3>, text=u'Onion Bhaji'\)",
        str(result))
开发者ID:stb-tester,项目名称:stb-tester,代码行数:8,代码来源:test_ocr.py


示例10: _read_text

 def _read_text(self, title, patterns=None):
     title = stbt.match_text(
         title, frame=self._frame,
         region=stbt.Region(x=620, y=145, right=950, bottom=460),
         text_color=(124, 94, 114))
     if not title:
         stbt.debug("NetworkAbout: Didn't find %r" % title)
         return None
     region = title.region.right_of().extend(x=10, y=-5, bottom=10)
     return stbt.ocr(self._frame, region, tesseract_user_patterns=patterns)
开发者ID:stb-tester,项目名称:stb-tester-test-pack,代码行数:10,代码来源:roku.py


示例11: test_that_match_text_returns_no_match_for_non_matching_text

def test_that_match_text_returns_no_match_for_non_matching_text():
    frame = load_image("ocr/menu.png")
    assert not stbt.match_text(u"Noodle Soup", frame=frame)
开发者ID:stb-tester,项目名称:stb-tester,代码行数:3,代码来源:test_ocr.py


示例12: test_ocr_debug

def test_ocr_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("action-panel.png")
    r = stbt.Region(0, 370, right=1280, bottom=410)
    c = (235, 235, 235)
    nonoverlapping = stbt.Region(2000, 2000, width=10, height=10)

    with scoped_curdir(), scoped_debug_level(2):

        stbt.ocr(f)
        stbt.ocr(f, region=r)
        stbt.ocr(f, region=r, text_color=c)
        stbt.ocr(f, region=nonoverlapping)

        stbt.match_text("Summary", f)  # no match
        stbt.match_text("Summary", f, region=r)  # no match
        stbt.match_text("Summary", f, region=r, text_color=c)
        stbt.match_text("Summary", f, region=nonoverlapping)

        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/source.png
            stbt-debug/00001/tessinput.png
            stbt-debug/00001/upsampled.png
            stbt-debug/00002
            stbt-debug/00002/index.html
            stbt-debug/00002/source.png
            stbt-debug/00002/tessinput.png
            stbt-debug/00002/upsampled.png
            stbt-debug/00003
            stbt-debug/00003/index.html
            stbt-debug/00003/source.png
            stbt-debug/00003/tessinput.png
            stbt-debug/00003/text_color_difference.png
            stbt-debug/00003/text_color_threshold.png
            stbt-debug/00003/upsampled.png
            stbt-debug/00004
            stbt-debug/00004/index.html
            stbt-debug/00004/source.png
            stbt-debug/00005
            stbt-debug/00005/index.html
            stbt-debug/00005/source.png
            stbt-debug/00005/tessinput.png
            stbt-debug/00005/upsampled.png
            stbt-debug/00006
            stbt-debug/00006/index.html
            stbt-debug/00006/source.png
            stbt-debug/00006/tessinput.png
            stbt-debug/00006/upsampled.png
            stbt-debug/00007
            stbt-debug/00007/index.html
            stbt-debug/00007/source.png
            stbt-debug/00007/tessinput.png
            stbt-debug/00007/text_color_difference.png
            stbt-debug/00007/text_color_threshold.png
            stbt-debug/00007/upsampled.png
            stbt-debug/00008
            stbt-debug/00008/index.html
            stbt-debug/00008/source.png
            """)
开发者ID:stb-tester,项目名称:stb-tester,代码行数:66,代码来源:test_stbt_debug.py


示例13: test_that_match_text_accepts_unicode

def test_that_match_text_accepts_unicode():
    f = cv2.imread("tests/ocr/unicode.png")
    assert stbt.match_text("David", f, lang='eng+deu')  # ascii
    assert stbt.match_text(u"Röthlisberger", f, lang='eng+deu')  # unicode
    assert stbt.match_text("Röthlisberger", f, lang='eng+deu')  # utf-8 bytes
开发者ID:rinaldomerlo,项目名称:stb-tester,代码行数:5,代码来源:test_ocr.py


示例14: test

 def test(text, region):
     result = stbt.match_text(text, frame=frame)
     assert result
     assert region.contains(result.region)  # pylint: disable=E1101
开发者ID:Winnetou,项目名称:stb-tester,代码行数:4,代码来源:test_ocr.py


示例15: test_that_default_language_is_configurable

def test_that_default_language_is_configurable():
    f = load_image("ocr/unicode.png")
    assert not stbt.match_text(u"Röthlisberger", f)  # reads Réthlisberger
    with temporary_config({"ocr.lang": "deu"}):
        assert stbt.match_text(u"Röthlisberger", f)
        assert u"Röthlisberger" in stbt.ocr(f)
开发者ID:stb-tester,项目名称:stb-tester,代码行数:6,代码来源:test_ocr.py


示例16: test_match_text_case_sensitivity

def test_match_text_case_sensitivity():
    frame = cv2.imread("tests/ocr/menu.png", cv2.IMREAD_GRAYSCALE)
    assert stbt.match_text("ONION BHAJI", frame)
    assert stbt.match_text("ONION BHAJI", frame, case_sensitive=False)
    assert not stbt.match_text("ONION BHAJI", frame, case_sensitive=True)
开发者ID:rinaldomerlo,项目名称:stb-tester,代码行数:5,代码来源:test_ocr.py


示例17: test_match_text_on_single_channel_image

def test_match_text_on_single_channel_image():
    frame = cv2.imread("tests/ocr/menu.png", cv2.IMREAD_GRAYSCALE)
    assert stbt.match_text("Onion Bhaji", frame)
开发者ID:rinaldomerlo,项目名称:stb-tester,代码行数:3,代码来源:test_ocr.py


示例18: test_that_roku_home_says_streaming_channels

def test_that_roku_home_says_streaming_channels():
    stbt.press('KEY_HOME')
    assert stbt.wait_until(lambda: stbt.match_text("Streaming Channels"))
开发者ID:JMassapina,项目名称:stb-tester-test-pack,代码行数:3,代码来源:example_test.py


示例19: test

 def test(text, region, upsample):
     result = stbt.match_text(text, frame=frame, upsample=upsample)
     assert result
     assert region.contains(result.region)  # pylint:disable=no-member
开发者ID:stb-tester,项目名称:stb-tester,代码行数:4,代码来源:test_ocr.py


示例20: test_that_match_text_returns_no_match_for_non_matching_text

def test_that_match_text_returns_no_match_for_non_matching_text():
    frame = cv2.imread("tests/ocr/menu.png")
    assert not stbt.match_text(u"Noodle Soup", frame=frame)
开发者ID:Winnetou,项目名称:stb-tester,代码行数:3,代码来源:test_ocr.py



注:本文中的stbt.match_text函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python stbt.ocr函数代码示例发布时间:2022-05-27
下一篇:
Python helper.Teacher类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap