提交 339c4532 authored 作者: 陈泽健's avatar 陈泽健

处理优化调用。

上级 0e55beae
...@@ -51,7 +51,7 @@ import logging ...@@ -51,7 +51,7 @@ import logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
def compare_brightness(light_down_path, light_on_path, threshold=50): def compare_brightness(light_down_path, light_on_path, threshold=1):
""" """
对比两张图片的亮度,返回亮度是否增加的布尔值。 对比两张图片的亮度,返回亮度是否增加的布尔值。
light_on_path:传入暗色的图片 light_on_path:传入暗色的图片
...@@ -84,8 +84,8 @@ def compare_brightness(light_down_path, light_on_path, threshold=50): ...@@ -84,8 +84,8 @@ def compare_brightness(light_down_path, light_on_path, threshold=50):
# if __name__ == '__main__': # if __name__ == '__main__':
# logging.info("开始对比亮度") # logging.info("开始对比亮度")
# #
# image1_path = r'D:\GithubData\自动化\ubains-module-test\预定系统\Base\暗图.jpg' # image1_path = r'D:\GithubData\自动化\ubains-module-test\预定系统\Base\captured_frame2.jpg'
# image2_path = r'D:\GithubData\自动化\ubains-module-test\预定系统\Base\亮图.jpg' # image2_path = r'D:\GithubData\自动化\ubains-module-test\预定系统\Base\captured_frame.jpg'
# #
# # 检查图片路径是否存在 # # 检查图片路径是否存在
# if not os.path.exists(image1_path): # if not os.path.exists(image1_path):
...@@ -142,25 +142,25 @@ def compare_images_feature_matching(image1_path, image2_path): ...@@ -142,25 +142,25 @@ def compare_images_feature_matching(image1_path, image2_path):
return False return False
if __name__ == '__main__': # if __name__ == '__main__':
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') # logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logging.info("开始对比图片") # logging.info("开始对比图片")
#
image1_path = r'D:\GithubData\自动化\ubains-module-test\预定系统\Base\暗图.jpg' # image1_path = r'D:\GithubData\自动化\ubains-module-test\预定系统\Base\captured_frame2.jpg'
image2_path = r'D:\GithubData\自动化\ubains-module-test\预定系统\Base\亮图.jpg' # image2_path = r'D:\GithubData\自动化\ubains-module-test\预定系统\Base\captured_frame.jpg'
#
if not os.path.exists(image1_path): # if not os.path.exists(image1_path):
logging.error(f"图片 {image1_path} 不存在") # logging.error(f"图片 {image1_path} 不存在")
exit(1) # exit(1)
if not os.path.exists(image2_path): # if not os.path.exists(image2_path):
logging.error(f"图片 {image2_path} 不存在") # logging.error(f"图片 {image2_path} 不存在")
exit(1) # exit(1)
#
# 对比两张截图的相似度 # # 对比两张截图的相似度
if compare_images_feature_matching(image1_path, image2_path): # if compare_images_feature_matching(image1_path, image2_path):
logging.info("图片相同") # logging.info("图片相同")
else: # else:
logging.error("图片不同") # logging.error("图片不同")
def capture_frame_from_rtsp(rtsp_url, output_path): def capture_frame_from_rtsp(rtsp_url, output_path):
""" """
...@@ -192,16 +192,3 @@ def capture_frame_from_rtsp(rtsp_url, output_path): ...@@ -192,16 +192,3 @@ def capture_frame_from_rtsp(rtsp_url, output_path):
except Exception as e: except Exception as e:
logging.error(f"捕获帧时发生错误: {e}", exc_info=True) logging.error(f"捕获帧时发生错误: {e}", exc_info=True)
return False return False
\ No newline at end of file
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logging.info("开始捕获RTSP流中的帧")
rtsp_url = "rtsp://admin:huawei@123@192.168.4.15/LiveMedia/ch1/Media2" # 替换为你的RTSP流地址
output_path = "captured_frame.jpg" # 保存帧的路径
if capture_frame_from_rtsp(rtsp_url, output_path):
logging.info("帧捕获成功")
else:
logging.error("帧捕获失败")
\ No newline at end of file
...@@ -145,4 +145,4 @@ ...@@ -145,4 +145,4 @@
30. 2024-12-30 30. 2024-12-30
- 封装亮度判断的compare_brightness函数处理,后续通过亮度判断灯光是否正确打开。 - 封装亮度判断的compare_brightness函数处理,后续通过亮度判断灯光是否正确打开。
31. 2024-12-31 31. 2024-12-31
- 补充对于rtsp流抓取一帧保存为图片,然后再进行对应的亮度判断。 - 补充对于rtsp流抓取一帧保存为图片,然后再进行对应的亮度判断。处理优化调用。
\ No newline at end of file \ No newline at end of file
...@@ -25,8 +25,12 @@ def suite_setup(): ...@@ -25,8 +25,12 @@ def suite_setup():
wd = GSTORE['wd'] wd = GSTORE['wd']
admin_login("Test02", "ubains@123") admin_login("Test02", "ubains@123")
sleep(5) sleep(5)
INFO("请检查灯光开启的状态是否正常")
# 这是灯光开启前的截图
SELENIUM_LOG_SCREEN(wd,"50%","Exhibit_Inspect","Control_Manage","light_down")
# 这是灯光开启后的截图
SELENIUM_LOG_SCREEN(wd, "50%", "Exhibit_Inspect", "Control_Manage", "light_on")
SELENIUM_LOG_SCREEN(wd,"50%","Exhibit_Inspect","Tx_meeting","会场画面截屏")
def suite_teardown(): def suite_teardown():
browser_quit() browser_quit()
\ No newline at end of file
...@@ -36,6 +36,15 @@ class Exhibition_hall_Control_000x: ...@@ -36,6 +36,15 @@ class Exhibition_hall_Control_000x:
air_button.click() air_button.click()
sleep(20) sleep(20)
# 先截取当前空间的灯光状态图片
rtsp_url = "rtsp://admin:huawei@123@192.168.4.15/LiveMedia/ch1/Media2" # 替换为你的RTSP流地址
output_path = r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Control_Manage\light_down.png" # 保存帧的路径
logging.info("开始捕获RTSP流中的帧")
if capture_frame_from_rtsp(rtsp_url, output_path):
logging.info("帧捕获成功")
else:
logging.error("帧捕获失败")
# 定位灯光控制按钮元素,并点击按钮 # 定位灯光控制按钮元素,并点击按钮
logging.info("尝试定位【灯光控制】按钮元素,并点击按钮") logging.info("尝试定位【灯光控制】按钮元素,并点击按钮")
light_button = app_drive.find_element(AppiumBy.XPATH, light_button = app_drive.find_element(AppiumBy.XPATH,
...@@ -95,6 +104,15 @@ class Exhibition_hall_Control_000x: ...@@ -95,6 +104,15 @@ class Exhibition_hall_Control_000x:
light_training_room_button.click() light_training_room_button.click()
sleep(2) sleep(2)
# 先截取当前空间的灯光状态图片
rtsp_url = "rtsp://admin:huawei@123@192.168.4.15/LiveMedia/ch1/Media2" # 替换为你的RTSP流地址
output_path = r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Control_Manage\light_on.png" # 保存帧的路径
logging.info("开始捕获RTSP流中的帧")
if capture_frame_from_rtsp(rtsp_url, output_path):
logging.info("帧捕获成功")
else:
logging.error("帧捕获失败")
# 切换至窗帘控制界面 # 切换至窗帘控制界面
logging.info("尝试定位【窗帘控制】按钮元素,并点击按钮") logging.info("尝试定位【窗帘控制】按钮元素,并点击按钮")
curtain_button = app_drive.find_element(AppiumBy.XPATH, curtain_button = app_drive.find_element(AppiumBy.XPATH,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论