Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录
切换导航
U
ubains-module-test
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
郑晓兵
ubains-module-test
Commits
f67c8064
提交
f67c8064
authored
12月 31, 2024
作者:
陈泽健
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
补充展厅中开屏的关于灯光控制、窗帘控制、指挥大屏控制以及配合监控视频来判断灯光与指挥大屏是否正确打开。
上级
339c4532
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
213 行增加
和
23 行删除
+213
-23
app_base.cpython-310.pyc
预定系统/Base/__pycache__/app_base.cpython-310.pyc
+0
-0
app_base.py
预定系统/Base/app_base.py
+93
-12
README.md
预定系统/README.md
+3
-2
__st__.cpython-310.pyc
预定系统/cases/展厅巡检/00展厅中控屏/__pycache__/__st__.cpython-310.pyc
+0
-0
展厅中控屏.cpython-310.pyc
预定系统/cases/展厅巡检/00展厅中控屏/__pycache__/展厅中控屏.cpython-310.pyc
+0
-0
__st__.py
预定系统/cases/展厅巡检/00展厅中控屏/__st__.py
+25
-0
展厅中控屏.py
预定系统/cases/展厅巡检/00展厅中控屏/展厅中控屏.py
+91
-8
无纸化1.0.cpython-310.pyc
预定系统/cases/展厅巡检/02无纸化/__pycache__/无纸化1.0.cpython-310.pyc
+0
-0
无纸化1.0.py
预定系统/cases/展厅巡检/02无纸化/无纸化1.0.py
+1
-1
没有找到文件。
预定系统/Base/__pycache__/app_base.cpython-310.pyc
浏览文件 @
f67c8064
No preview for this file type
预定系统/Base/app_base.py
浏览文件 @
f67c8064
...
...
@@ -162,33 +162,115 @@ def compare_images_feature_matching(image1_path, image2_path):
# else:
# logging.error("图片不同")
def
capture_frame_from_rtsp
(
rtsp_url
,
output_path
):
import
cv2
import
logging
import
os
import
shutil
# 导入 shutil 模块以检查磁盘空间
# 配置日志
logging
.
basicConfig
(
level
=
logging
.
INFO
,
format
=
'
%(asctime)
s -
%(levelname)
s -
%(message)
s'
)
def
check_output_path
(
output_path
):
output_dir
=
os
.
path
.
dirname
(
output_path
)
if
not
os
.
path
.
exists
(
output_dir
):
try
:
os
.
makedirs
(
output_dir
)
logging
.
info
(
f
"创建目录: {output_dir}"
)
except
Exception
as
e
:
logging
.
error
(
f
"无法创建目录 {output_dir}: {e}"
)
return
False
# 检查文件权限
if
not
os
.
access
(
output_dir
,
os
.
W_OK
):
logging
.
error
(
f
"没有写权限: {output_dir}"
)
return
False
return
True
def
capture_frame_from_rtsp
(
rtsp_url
,
file_name
,
output_path
=
None
):
"""
从RTSP流中捕获一帧并保存为图像文件。
"""
try
:
# 验证输入参数
if
not
rtsp_url
:
logging
.
error
(
"RTSP URL 为空"
)
return
False
# 获取当前脚本所在的根目录
script_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
root_dir
=
os
.
path
.
dirname
(
script_dir
)
# 构建默认输出路径
if
output_path
is
None
:
output_path
=
os
.
path
.
join
(
root_dir
,
"reports"
,
"imgs"
,
"Exhibit_Inspect"
,
"Control_Manage"
,
file_name
)
# 检查并创建输出目录
if
not
check_output_path
(
output_path
):
return
False
# 打开RTSP流
cap
=
cv2
.
VideoCapture
(
rtsp_url
)
if
not
cap
.
isOpened
():
logging
.
error
(
"无法打开RTSP流"
)
return
False
# 读取一帧
ret
,
frame
=
cap
.
read
()
# 尝试多次读取帧以确保获取有效帧
for
_
in
range
(
5
):
# 尝试读取5次
ret
,
frame
=
cap
.
read
()
if
ret
and
frame
is
not
None
:
break
else
:
logging
.
error
(
"无法从RTSP流中读取有效帧"
)
cap
.
release
()
return
False
if
not
ret
:
logging
.
error
(
"无法从RTSP流中读取帧"
)
# 确认帧不为空
if
frame
is
None
or
frame
.
size
==
0
:
logging
.
error
(
"捕获到的帧为空"
)
cap
.
release
()
return
False
# 保存帧为图像文件
cv2
.
imwrite
(
output_path
,
frame
)
logging
.
info
(
f
"帧已保存到 {output_path}"
)
# 检查帧的形状和类型
logging
.
info
(
f
"捕获到的帧尺寸: {frame.shape}, 数据类型: {frame.dtype}"
)
# 尝试保存帧为图像文件
success
=
False
try
:
# 使用 cv2.imencode 保存图像到内存中,再写入文件
_
,
img_encoded
=
cv2
.
imencode
(
'.png'
,
frame
)
with
open
(
output_path
,
'wb'
)
as
f
:
f
.
write
(
img_encoded
.
tobytes
())
success
=
True
except
Exception
as
e
:
logging
.
error
(
f
"无法保存帧到 {output_path}: {e}"
)
logging
.
error
(
f
"检查路径是否存在: {os.path.exists(os.path.dirname(output_path))}"
)
logging
.
error
(
f
"检查路径是否可写: {os.access(os.path.dirname(output_path), os.W_OK)}"
)
# 使用 shutil.disk_usage 检查磁盘空间
try
:
total
,
used
,
free
=
shutil
.
disk_usage
(
os
.
path
.
dirname
(
output_path
))
logging
.
error
(
f
"检查磁盘空间: {free // (2 ** 20)} MB available"
)
except
Exception
as
e
:
logging
.
error
(
f
"无法检查磁盘空间: {e}"
)
if
success
:
logging
.
info
(
f
"帧已保存到 {output_path}"
)
else
:
logging
.
error
(
f
"帧保存失败"
)
# 释放资源
cap
.
release
()
return
True
return
success
except
Exception
as
e
:
logging
.
error
(
f
"捕获帧时发生错误: {e}"
,
exc_info
=
True
)
return
False
\ No newline at end of file
return
False
# if __name__ == '__main__':
# # 先截取当前空间的灯光状态图片
# rtsp_url = "rtsp://admin:huawei@123@192.168.4.15/LiveMedia/ch1/Media2" # 替换为你的RTSP流地址
# logging.info("开始捕获RTSP流中的帧")
# if capture_frame_from_rtsp(rtsp_url,"light_on.png"):
# logging.info("帧捕获成功")
# else:
# logging.error("帧捕获失败")
预定系统/README.md
浏览文件 @
f67c8064
...
...
@@ -145,4 +145,5 @@
30.
2024-12-30
-
封装亮度判断的compare_brightness函数处理,后续通过亮度判断灯光是否正确打开。
31.
2024-12-31
-
补充对于rtsp流抓取一帧保存为图片,然后再进行对应的亮度判断。处理优化调用。
\ No newline at end of file
-
补充对于rtsp流抓取一帧保存为图片,然后再进行对应的亮度判断。处理优化调用。
-
补充展厅中开屏的关于灯光控制、窗帘控制、指挥大屏控制以及配合监控视频来判断灯光与指挥大屏是否正确打开。
\ No newline at end of file
预定系统/cases/展厅巡检/00展厅中控屏/__pycache__/__st__.cpython-310.pyc
浏览文件 @
f67c8064
No preview for this file type
预定系统/cases/展厅巡检/00展厅中控屏/__pycache__/展厅中控屏.cpython-310.pyc
浏览文件 @
f67c8064
No preview for this file type
预定系统/cases/展厅巡检/00展厅中控屏/__st__.py
浏览文件 @
f67c8064
...
...
@@ -26,11 +26,35 @@ def suite_setup():
admin_login
(
"Test02"
,
"ubains@123"
)
sleep
(
5
)
INFO
(
"请检查灯光开启的状态是否正常"
)
STEP
(
2
,
"检查灯光开启状态"
)
# 这是全部灯光关闭后在软件界面上的状态显示
INFO
(
"请检查灯光关闭的状态是否正常"
)
SELENIUM_LOG_SCREEN
(
wd
,
"50
%
"
,
"Exhibit_Inspect"
,
"Control_Manage"
,
"light_all_off"
)
# 这是全部灯光开启后在软件界面上的状态显示
INFO
(
"请检查灯光开启的状态是否正常"
)
SELENIUM_LOG_SCREEN
(
wd
,
"50
%
"
,
"Exhibit_Inspect"
,
"Control_Manage"
,
"light_all_on"
)
# 这是灯光开启前的截图
INFO
(
"请检查灯光开启前的监控视频状态是否正常"
)
SELENIUM_LOG_SCREEN
(
wd
,
"50
%
"
,
"Exhibit_Inspect"
,
"Control_Manage"
,
"light_down"
)
# 这是灯光开启后的截图
INFO
(
"请检查灯光开启后的监控视频状态是否正常"
)
SELENIUM_LOG_SCREEN
(
wd
,
"50
%
"
,
"Exhibit_Inspect"
,
"Control_Manage"
,
"light_on"
)
STEP
(
3
,
"检查空调开启状态"
)
# 这是空调关闭的状态显示
INFO
(
"请检查空调关闭的状态是否正常"
)
SELENIUM_LOG_SCREEN
(
wd
,
"50
%
"
,
"Exhibit_Inspect"
,
"Control_Manage"
,
"air_condition_off"
)
# 这是空调开启的状态显示
INFO
(
"请检查空调开启的状态是否正常"
)
SELENIUM_LOG_SCREEN
(
wd
,
"50
%
"
,
"Exhibit_Inspect"
,
"Control_Manage"
,
"air_condition_off"
)
STEP
(
4
,
"检查指挥大屏开启状态"
)
# 这是指挥大屏关闭的监控视频显示
INFO
(
"请检查指挥大屏关闭的监控视频状态是否正常"
)
SELENIUM_LOG_SCREEN
(
wd
,
"50
%
"
,
"Exhibit_Inspect"
,
"Control_Manage"
,
"command_screen_down"
)
# 这是指挥大屏开启的监控视频显示
INFO
(
"请检查指挥大屏开启的监控视频状态是否正常"
)
SELENIUM_LOG_SCREEN
(
wd
,
"50
%
"
,
"Exhibit_Inspect"
,
"Control_Manage"
,
"command_screen_on"
)
def
suite_teardown
():
browser_quit
()
\ No newline at end of file
预定系统/cases/展厅巡检/00展厅中控屏/展厅中控屏.py
浏览文件 @
f67c8064
from
appium.webdriver.common.appiumby
import
AppiumBy
from
dominate.tags
import
button
from
预定系统
.
Base
.
app_base
import
*
import
logging
from
time
import
sleep
...
...
@@ -38,9 +40,8 @@ class Exhibition_hall_Control_000x:
# 先截取当前空间的灯光状态图片
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
):
if
capture_frame_from_rtsp
(
rtsp_url
,
"light_down.png"
):
logging
.
info
(
"帧捕获成功"
)
else
:
logging
.
error
(
"帧捕获失败"
)
...
...
@@ -54,6 +55,9 @@ class Exhibition_hall_Control_000x:
light_button
.
click
()
logging
.
info
(
"点击【灯光控制】按钮成功"
)
sleep
(
20
)
# 截图获取当前软件的灯光控制界面
app_drive
.
get_screenshot_as_file
(
r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Control_Manage\light_all_off.png"
)
# 开启所有区域灯光
# 定位【接待区】灯光
...
...
@@ -104,15 +108,19 @@ class Exhibition_hall_Control_000x:
light_training_room_button
.
click
()
sleep
(
2
)
# 截图获取当前软件的灯光控制界面
app_drive
.
get_screenshot_as_file
(
r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Control_Manage\light_all_on.png"
)
# 先截取当前空间的灯光状态图片
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
):
if
capture_frame_from_rtsp
(
rtsp_url
,
"light_on.png"
):
logging
.
info
(
"帧捕获成功"
)
else
:
logging
.
error
(
"帧捕获失败"
)
# 切换至窗帘控制界面
logging
.
info
(
"尝试定位【窗帘控制】按钮元素,并点击按钮"
)
curtain_button
=
app_drive
.
find_element
(
AppiumBy
.
XPATH
,
...
...
@@ -120,14 +128,89 @@ class Exhibition_hall_Control_000x:
curtain_button
.
click
()
sleep
(
2
)
# 所有窗帘全部上升
logging
.
info
(
"尝试定位【窗帘上升】按钮元素,并点击按钮"
)
for
i
in
range
(
1
,
6
):
logging
.
info
(
f
"尝试定位第{i}个【窗帘上升】按钮元素,并点击按钮"
)
logging
.
info
(
"尝试定位所有【窗帘上升】按钮元素,并点击按钮"
)
# 上升按钮的定位
curtain_up_locator
=
[
'3'
,
'4'
,
'5'
,
'1'
,
'13'
]
for
i
in
curtain_up_locator
:
curtain_up_button
=
app_drive
.
find_element
(
AppiumBy
.
XPATH
,
f
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[{i}]"
)
f
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[{i}]"
)
curtain_up_button
.
click
()
sleep
(
2
)
sleep
(
10
)
# 所有窗帘全部下降
logging
.
info
(
"尝试定位所有【窗帘下降】按钮元素,并点击按钮"
)
# 下降按钮的定位
curtain_down_locator
=
[
'10'
,
'11'
,
'12'
,
'6'
,
'15'
]
for
i
in
curtain_down_locator
:
curtain_down_button
=
app_drive
.
find_element
(
AppiumBy
.
XPATH
,
f
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[{i}]"
)
curtain_down_button
.
click
()
sleep
(
2
)
# 切换至空调控制界面
logging
.
info
(
"尝试定位【空调控制】按钮元素,并点击按钮"
)
air_conditioner_button
=
app_drive
.
find_element
(
AppiumBy
.
XPATH
,
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[1]/android.widget.Button[5]"
)
air_conditioner_button
.
click
()
sleep
(
2
)
# 点击【打开空调】按钮
logging
.
info
(
"尝试定位【打开空调】按钮元素,并点击按钮"
)
open_air_conditioner_button
=
app_drive
.
find_element
(
AppiumBy
.
XPATH
,
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[14]"
)
open_air_conditioner_button
.
click
()
sleep
(
20
)
app_drive
.
get_screenshot_as_file
(
r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Control_Manage\air_condition_on.png"
)
sleep
(
2
)
# 点击【关闭空调】按钮
logging
.
info
(
"尝试定位【关闭空调】按钮元素,并点击按钮"
)
close_air_conditioner_button
=
app_drive
.
find_element
(
AppiumBy
.
XPATH
,
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button[14]"
)
close_air_conditioner_button
.
click
()
sleep
(
20
)
app_drive
.
get_screenshot_as_file
(
r"D:\GithubData\自动化\ubains-module-test\预定系统\reports\imgs\Exhibit_Inspect\Control_Manage\air_condition_off.png"
)
sleep
(
2
)
# 切换至指挥中心控制界面
# 打开指挥中心大屏幕
logging
.
info
(
"尝试定位【开启指挥中心控制】按钮元素,并点击按钮"
)
center_button
=
app_drive
.
find_element
(
AppiumBy
.
XPATH
,
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[1]/android.widget.Button[8]"
)
center_button
.
click
()
sleep
(
2
)
open_center_button
=
app_drive
.
find_element
(
AppiumBy
.
XPATH
,
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button"
)
open_center_button
.
click
()
sleep
(
10
)
# 从rtsp流中截取一帧保存为图片
logging
.
info
(
"开始捕获RTSP流中的帧"
)
if
capture_frame_from_rtsp
(
rtsp_url
,
"command_screen_on.png"
):
logging
.
info
(
"帧捕获成功"
)
else
:
logging
.
error
(
"帧捕获失败"
)
# 关闭指挥中心大屏幕
logging
.
info
(
"尝试定位【关闭指挥中心控制】按钮元素,并点击按钮"
)
close_center_button
=
app_drive
.
find_element
(
AppiumBy
.
XPATH
,
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[2]/android.widget.Button"
)
close_center_button
.
click
()
sleep
(
10
)
# 从rtsp流中截取一帧保存为图片
logging
.
info
(
"开始捕获RTSP流中的帧"
)
if
capture_frame_from_rtsp
(
rtsp_url
,
"command_screen_down.png"
):
logging
.
info
(
"帧捕获成功"
)
else
:
logging
.
error
(
"帧捕获失败"
)
# 切换至音乐区域
logging
.
info
(
"尝试定位【音乐】按钮元素,并点击按钮"
)
music_button
=
app_drive
.
find_element
(
AppiumBy
.
XPATH
,
"/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.RelativeLayout/android.widget.RelativeLayout/android.widget.RelativeLayout[1]/android.widget.Button[9]"
)
music_button
.
click
()
sleep
(
2
)
except
Exception
as
e
:
# 捕获并记录任何发生的错误
...
...
预定系统/cases/展厅巡检/02无纸化/__pycache__/无纸化1.0.cpython-310.pyc
浏览文件 @
f67c8064
No preview for this file type
预定系统/cases/展厅巡检/02无纸化/无纸化1.0.py
浏览文件 @
f67c8064
...
...
@@ -19,7 +19,7 @@ class Exhibition_hall_NoPaperinspection_000x:
try
:
# 腾讯:"com.tencent.wemeet.app" ".StartupActivity"
# 无纸化1.0:"com.ubains.system.develop.mqtt" "com.ubains.system.activity.RouterActivity"
app_drive
=
app_setup_driver
(
"Android"
,
"7.1.2"
,
"展厅无纸化设备1.0"
,
"com.ubains.system.develop.mqtt"
,
"com.ubains.system.activity.RouterActivity"
,
"192.168.5.15
9
:5555"
)
app_drive
=
app_setup_driver
(
"Android"
,
"7.1.2"
,
"展厅无纸化设备1.0"
,
"com.ubains.system.develop.mqtt"
,
"com.ubains.system.activity.RouterActivity"
,
"192.168.5.15
8
:5555"
)
app_drive
.
implicitly_wait
(
20
)
# 设置缺省等待时间
# 使用显式等待来等待元素出现
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论