找图功能 Map finding function
| 2 | import time |
| 3 | |
| 4 | class MapFindingOperation: |
| 5 | """ |
| 6 | 找图功能 |
| 7 | Map finding function |
| 8 | """ |
| 9 | def find_images(self, image_name: str, region: tuple = (0,0,0,0), algorithm: tuple = (0,0,0), similarity: float = 0.9, multi: int = 1, wait_time: float = 5, interval_time: float = 0.5) -> list: |
| 10 | """ |
| 11 | 寻找图片坐标,在当前屏幕中寻找给定图片中心点的坐标,返回坐标列表(如果想拿一个坐标取第一个坐标元祖即可) |
| 12 | Find the coordinates of the picture, find the coordinates of the center point of a given picture in the current screen, and return to the coordinate list (if you want to take a coordinate and take the first coordinate ancestor) |
| 13 | |
| 14 | image_name: 图片名称(手机中)/storage/emulated/0/ 手机根目录 |
| 15 | region: 截图区域,默认全屏,``region = (起点x、起点y、终点x、终点y)``,得到一个矩形 |
| 16 | algorithm: |
| 17 | 处理屏幕截图所用的算法,默认原图,注意:给定图片处理时所用的算法,应该和此方法的算法一致; |
| 18 | ``algorithm = (algorithm_type, threshold, max_val)`` |
| 19 | |
| 20 | 按元素顺序分别代表: |
| 21 | 0. ``algorithm_type`` 算法类型 |
| 22 | 1. ``threshold`` 阈值 |
| 23 | 2. ``max_val`` 最大值 |
| 24 | |
| 25 | ``threshold`` 和 ``max_val`` 同为 255 时灰度处理. |
| 26 | ``algorithm_type`` 算法类型说明: |
| 27 | 0. ``THRESH_BINARY`` 算法,当前点值大于阈值 `threshold` 时,取最大值 ``max_val``,否则设置为 0; |
| 28 | 1. ``THRESH_BINARY_INV`` 算法,当前点值大于阈值 `threshold` 时,设置为 0,否则设置为最大值 max_val; |
| 29 | 2. ``THRESH_TOZERO`` 算法,当前点值大于阈值 `threshold` 时,不改变,否则设置为 0; |
| 30 | 3. ``THRESH_TOZERO_INV`` 算法,当前点值大于阈值 ``threshold`` 时,设置为 0,否则不改变; |
| 31 | 4. ``THRESH_TRUNC`` 算法,当前点值大于阈值 ``threshold`` 时,设置为阈值 ``threshold``,否则不改变; |
| 32 | 5. ``ADAPTIVE_THRESH_MEAN_C`` 算法,自适应阈值; |
| 33 | 6. ``ADAPTIVE_THRESH_GAUSSIAN_C`` 算法,自适应阈值; |
| 34 | similarity: 相似度,0-1 的浮点数,默认 0.9; |
| 35 | multi: 目标数量,默认为 1,找到 1 个目标后立即结束; |
| 36 | wait_time: 等待时间,默认取 self.wait_timeout |
| 37 | interval_time: 轮询间隔时间,默认取 self.interval_timeout |
| 38 | return: 坐标列表 或者 [] |
| 39 | |
| 40 | image_name: image name (in mobile phone) /storage/emulated/0/ mobile phone root directory. |
| 41 | region: screenshot area, full screen by default, `` region = (starting point x, starting point y, ending point x, ending point y) ```, and a rectangle is obtained. |
| 42 | algorithm: |
| 43 | The algorithm used to process screen shots defaults to the original image. Note: the algorithm used in the given image processing should be consistent with the algorithm of this method; |
| 44 | |
| 45 | ``algorithm = (algorithm_type, threshold, max_val)`` |
| 46 | |
| 47 | Represents, respectively, in the order of elements: |
| 48 | 0. ``algorithm_type ``` algorithm type |
| 49 | 1. ``threshold ```` threshold |
| 50 | 2. `` Max _ val```` Maximum value |
| 51 | |
| 52 | Gray processing when threshold and max_val are both 255 |
| 53 | `` algorithm _ type``` description of algorithm_type |
| 54 | 0. ``` threshold _ binary``` algorithm, when the current point value is greater than the threshold value ` threshold `, the maximum value ``` max _ val```` is taken, otherwise it is set to 0 |
| 55 | 1. `` threshold _ binary _ inv``` algorithm, when the current point value is greater than the threshold value ` threshold `, set it to 0, otherwise set it to the maximum value max_val; |
| 56 | 2. `` threshold _ tozero``` algorithm, when the current point value is greater than the threshold ` threshold', it will not be changed, otherwise it will be set to 0 |
| 57 | 3. `` threshold _ tozero _ inv``` algorithm, when the current point value is greater than the threshold value ``` threshold ```, it is set to 0, otherwise it will not change |
| 58 | 4. `` threshold _ trunc``` algorithm, when the current point value is greater than the threshold value ``` threshold ```, it is set as the threshold value ``` threshold ```, otherwise it will not be changed |
| 59 | 5. ``` Adaptive _ threshold _ mean _ c``` algorithm, adaptive threshold |
| 60 | 6. ``` Adaptive _ Thresh _ Gaussian _ C``` algorithm, adaptive threshold |
| 61 | similarity: similarity, floating point number of 0-1, default 0.9; |
nothing calls this directly
no outgoing calls
no test coverage detected