File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# -*- coding: utf-8 -*-
2- """Supervision SDK 使用示例"""
2+ """svision SDK 使用示例"""
33
44import sys
55from pathlib import Path
99project_root = Path (__file__ ).resolve ().parent .parent
1010sys .path .insert (0 , str (project_root ))
1111
12- from svision import find_location , find_text_position , recognize_text
13- from svision .options import Options
12+ from svision import find_location , find_text_position , recognize_text # noqa: E402
1413
1514
1615def main ():
17- # OCR 配置(按需)
18- # Options.OCR_LANGUAGE = "ch"
19- # Options.OCR_USE_GPU = True
20- # Options.OCR_DEVICE = "gpu:0"
21- # Options.OCR_USE_ANGLE_CLS = False
22-
2316 target_image = cv2 .imread ("test/assets/target.png" )
2417 if target_image is None :
2518 raise RuntimeError ("无法读取目标图像" )
2619
2720 # 模板匹配
28- pos = find_location (target_image , "test/assets/template1.png" , threshold = 0.8 )
21+ find_location (target_image , "test/assets/template1.png" , threshold = 0.8 )
2922
3023 # OCR 全量识别
31- texts = recognize_text (target_image )
24+ recognize_text (target_image )
3225
3326 # 查找指定文本位置
34- text_pos = find_text_position (target_image , "控制台" )
27+ find_text_position (target_image , "控制台" )
3528
3629
3730if __name__ == "__main__" :
Original file line number Diff line number Diff line change 1111sys .path .insert (0 , str (project_root ))
1212
1313print ("=" * 60 )
14- print ("📦 Supervision 项目测试" )
14+ print ("📦 svision 项目测试" )
1515print ("=" * 60 )
1616print ()
1717
3131
3232try :
3333 from PIL import Image
34- print (f " ✅ PIL" )
34+ print (" ✅ PIL" )
3535except ImportError as e :
3636 print (f" ❌ PIL: { e } " )
3737
4040
4141try :
4242 from svision .options import Options
43- print (f " ✅ supervision .options" )
43+ print (" ✅ svision .options" )
4444except ImportError as e :
45- print (f" ❌ supervision .options: { e } " )
45+ print (f" ❌ svision .options: { e } " )
4646
4747try :
4848 from svision .aircv import aircv as aircv_module
49- print (f " ✅ supervision .aircv" )
49+ print (" ✅ svision .aircv" )
5050except ImportError as e :
51- print (f" ❌ supervision .aircv: { e } " )
51+ print (f" ❌ svision .aircv: { e } " )
5252
5353try :
5454 from svision .orc import TextRecognizer
55- print (f " ✅ supervision .orc" )
55+ print (" ✅ svision .orc" )
5656except ImportError as e :
57- print (f" ❌ supervision .orc: { e } " )
57+ print (f" ❌ svision .orc: { e } " )
5858
5959print ()
6060print ("✓ 测试 3: 检查测试资源" )
6464 files = list (test_assets .glob ("*.png" ))
6565 print (f" ✅ 测试资源目录存在 ({ len (files )} 个图像文件)" )
6666else :
67- print (f " ❌ 测试资源目录不存在" )
67+ print (" ❌ 测试资源目录不存在" )
6868
6969print ()
7070print ("=" * 60 )
Original file line number Diff line number Diff line change 1818project_root = Path (__file__ ).parent .parent
1919sys .path .insert (0 , str (project_root ))
2020
21- from svision import (
21+ from svision import ( # noqa: E402
2222 find_location ,
23- find_all_locations ,
2423 recognize_text ,
25- find_text_position ,
2624)
27- from svision .orc import TextRecognizer , clear_ocr_cache
28- from svision .options import Options
29- from svision .utils import logger
30- import logging
25+ from svision .utils import logger # noqa: E402
26+ import logging # noqa: E402
3127
3228
3329class TestConfig :
You can’t perform that action at this time.
0 commit comments