parent
06797a02e9
commit
7e6eae1b87
6
.env
6
.env
|
@ -1,6 +0,0 @@
|
|||
PIPENV_VERBOSITY=-1
|
||||
|
||||
DISPLAY=":0"
|
||||
QT_QPA_PLATFORM=
|
||||
QT_ACCESSIBILITY=1
|
||||
QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1
|
1
env.sh
1
env.sh
|
@ -69,7 +69,6 @@ echo -e "${flag_feel}安装 pip 包\n"
|
|||
sudo pip3 install -U pip > /tmp/env.log 2>&1
|
||||
sudo pip3 config set global.timeout 10000 > /tmp/env.log 2>&1
|
||||
sudo pip3 config set global.index-url ${pypi_mirror} > /tmp/env.log 2>&1
|
||||
sudo pip3 config set global.extra-index-url https://it.uniontech.com/nexus/repository/pypi-public/simple
|
||||
sudo pip3 install pipenv > /tmp/env.log 2>&1
|
||||
if [ $? = 0 ]; then
|
||||
echo -e "pipenv\t安装成功 √"
|
||||
|
|
|
@ -41,8 +41,11 @@ class AssertCommon:
|
|||
widget: str,
|
||||
rate: float = 0.9,
|
||||
multiple: bool = False,
|
||||
match_number: int = None,
|
||||
picture_abspath: str = None,
|
||||
network_retry: int = None,
|
||||
pause: [int, float] = None,
|
||||
timeout: [int, float] = None,
|
||||
match_number: int = None,
|
||||
):
|
||||
"""
|
||||
期望界面存在模板图片
|
||||
|
@ -57,8 +60,11 @@ class AssertCommon:
|
|||
widget,
|
||||
rate=rate,
|
||||
multiple=multiple,
|
||||
match_number=match_number,
|
||||
picture_abspath=picture_abspath,
|
||||
network_retry=network_retry,
|
||||
pause=pause,
|
||||
timeout=timeout,
|
||||
max_match_number=match_number,
|
||||
)
|
||||
except TemplateElementNotFound as exc:
|
||||
raise AssertionError(exc) from TemplateElementNotFound
|
||||
|
@ -96,8 +102,11 @@ class AssertCommon:
|
|||
widget: str,
|
||||
rate: float = 0.9,
|
||||
multiple: bool = False,
|
||||
match_number: int = None,
|
||||
picture_abspath: str = None,
|
||||
network_retry: int = None,
|
||||
pause: [int, float] = None,
|
||||
timeout: [int, float] = None,
|
||||
match_number: int = None,
|
||||
):
|
||||
"""
|
||||
期望界面不存在模板图片
|
||||
|
@ -113,8 +122,11 @@ class AssertCommon:
|
|||
widget,
|
||||
rate=rate,
|
||||
multiple=multiple,
|
||||
match_number=match_number,
|
||||
picture_abspath=picture_abspath,
|
||||
network_retry=network_retry,
|
||||
pause=pause,
|
||||
timeout=timeout,
|
||||
max_match_number=match_number,
|
||||
)
|
||||
raise TemplateElementFound(widget)
|
||||
except TemplateElementNotFound:
|
||||
|
@ -385,7 +397,15 @@ class AssertCommon:
|
|||
|
||||
@staticmethod
|
||||
def assert_ocr_exist(
|
||||
*args, picture_abspath=None, similarity=0.6, return_first=False, lang="ch"
|
||||
*args,
|
||||
picture_abspath=None,
|
||||
similarity=0.6,
|
||||
return_first=False,
|
||||
lang="ch",
|
||||
network_retry: int = None,
|
||||
pause: [int, float] = None,
|
||||
timeout: [int, float] = None,
|
||||
max_match_number: int = None,
|
||||
):
|
||||
"""断言文案存在"""
|
||||
pic = None
|
||||
|
@ -397,6 +417,10 @@ class AssertCommon:
|
|||
similarity=similarity,
|
||||
return_first=return_first,
|
||||
lang=lang,
|
||||
network_retry=network_retry,
|
||||
pause=pause,
|
||||
timeout=timeout,
|
||||
max_match_number=max_match_number,
|
||||
)
|
||||
if res is False:
|
||||
raise AssertionError(
|
||||
|
@ -415,7 +439,15 @@ class AssertCommon:
|
|||
|
||||
@staticmethod
|
||||
def assert_ocr_not_exist(
|
||||
*args, picture_abspath=None, similarity=0.6, return_first=False, lang="ch"
|
||||
*args,
|
||||
picture_abspath=None,
|
||||
similarity=0.6,
|
||||
return_first=False,
|
||||
lang="ch",
|
||||
network_retry: int = None,
|
||||
pause: [int, float] = None,
|
||||
timeout: [int, float] = None,
|
||||
max_match_number: int = None,
|
||||
):
|
||||
"""断言文案不存在"""
|
||||
pic = None
|
||||
|
@ -427,6 +459,10 @@ class AssertCommon:
|
|||
similarity=similarity,
|
||||
return_first=return_first,
|
||||
lang=lang,
|
||||
network_retry=network_retry,
|
||||
pause=pause,
|
||||
timeout=timeout,
|
||||
max_match_number=max_match_number,
|
||||
)
|
||||
if res is False:
|
||||
pass
|
||||
|
|
|
@ -21,36 +21,35 @@ from setting.globalconfig import GlobalConfig
|
|||
image_setting.PORT = 8889
|
||||
image_setting.SERVER_IP = GlobalConfig.OPENCV_SERVER_HOST
|
||||
|
||||
from src import logger
|
||||
|
||||
|
||||
class ImageUtils(ImageCenter):
|
||||
"""图像识别的工具类"""
|
||||
|
||||
@staticmethod
|
||||
def opencv_compare_images_SSIM(
|
||||
module_name, imageA_name, imageB_name, ssim=None, app_name=None
|
||||
):
|
||||
"""
|
||||
判断两张图片是否相同
|
||||
(临时解决安全中心需要外部依赖的问题,基础框架提供对应的接口;)
|
||||
:param module_name:模块
|
||||
:param imageA_name:预存图片A
|
||||
:param imageB_name:比较图片B
|
||||
example:opencv_compare_images_SSIM('system_check', 'system_check_315116', 'pms_315116')
|
||||
"""
|
||||
# pylint: disable=invalid-name,I1101,E1101
|
||||
if ssim is None:
|
||||
ssim = GlobalConfig.IMAGE_RATE
|
||||
picture_path = f"{GlobalConfig.APPS_PATH}/{app_name}/res/picture"
|
||||
contrast_path = f"/home/{GlobalConfig.USERNAME}/Pictures/{app_name}"
|
||||
file_a = cv.imread(f"{picture_path}/{module_name}/{imageA_name}.png")
|
||||
file_b = cv.imread(f"{contrast_path}/{module_name}/{imageB_name}.png")
|
||||
file_a = cv.cvtColor(file_a, cv.COLOR_BGR2GRAY)
|
||||
file_b = cv.cvtColor(file_b, cv.COLOR_BGR2GRAY)
|
||||
result = cv.matchTemplate(file_b, file_a, cv.TM_CCOEFF_NORMED)
|
||||
similarity = cv.minMaxLoc(result)[1]
|
||||
logger.info("SSIM = " + str(similarity))
|
||||
if similarity >= ssim:
|
||||
return True
|
||||
return False
|
||||
# 移除此方法
|
||||
# @staticmethod
|
||||
# def opencv_compare_images_SSIM(
|
||||
# module_name, imageA_name, imageB_name, ssim=None, app_name=None
|
||||
# ):
|
||||
# """
|
||||
# 判断两张图片是否相同
|
||||
# (临时解决安全中心需要外部依赖的问题,基础框架提供对应的接口;)
|
||||
# :param module_name:模块
|
||||
# :param imageA_name:预存图片A
|
||||
# :param imageB_name:比较图片B
|
||||
# example:opencv_compare_images_SSIM('system_check', 'system_check_315116', 'pms_315116')
|
||||
# """
|
||||
# # pylint: disable=invalid-name,I1101,E1101
|
||||
# if ssim is None:
|
||||
# ssim = GlobalConfig.IMAGE_RATE
|
||||
# picture_path = f"{GlobalConfig.APPS_PATH}/{app_name}/res/picture"
|
||||
# contrast_path = f"/home/{GlobalConfig.USERNAME}/Pictures/{app_name}"
|
||||
# file_a = cv.imread(f"{picture_path}/{module_name}/{imageA_name}.png")
|
||||
# file_b = cv.imread(f"{contrast_path}/{module_name}/{imageB_name}.png")
|
||||
# file_a = cv.cvtColor(file_a, cv.COLOR_BGR2GRAY)
|
||||
# file_b = cv.cvtColor(file_b, cv.COLOR_BGR2GRAY)
|
||||
# result = cv.matchTemplate(file_b, file_a, cv.TM_CCOEFF_NORMED)
|
||||
# similarity = cv.minMaxLoc(result)[1]
|
||||
# logger.info("SSIM = " + str(similarity))
|
||||
# if similarity >= ssim:
|
||||
# return True
|
||||
# return False
|
||||
|
|
Loading…
Reference in New Issue