Compare commits

..

2 Commits

Author SHA1 Message Date
Gehusileng fc70493fa6 1
5 months ago
Gehusileng 9be37a1750 1
5 months ago

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

@ -112,21 +112,22 @@ def visualize_results(img_path: str, detections: List[Dict[str, Any]]) -> None:
# 准备播报文本
# 地面避障
announcement_text1 = "前方有障碍,请注意。" # 基础播报文本
announcement_text2 = "左侧有障碍,请注意。"
announcement_text3 = "右侧有障碍,请注意。"
# 高空避障
announcement_text4 = "上方有障碍,请注意。"
# 绘制边界框和标签
for detection in detections:
label = detection['label']
bbox = detection['bbox']
# 地面避障和高空避障的播报文本
announcement_texts = {
'front': "前方有障碍,请注意。",
'left': "左侧有障碍,请注意。",
'right': "右侧有障碍,请注意。",
'above': "上方有障碍,请注意。"
}
for detection in detections:
label = detection['label'] # 获取障碍物的标签
announcer.announce(f"{announcement_text1}")
# 停止语音播报
announcer.stop()
# 根据障碍物的位置获取对应的播报文本
announcement_text = announcement_texts.get(label, "未知位置的障碍,请注意。")
# 使用announcer进行播报
announcer.announce(announcement_text)
# 注意这里假设bbox的格式是(x, y, w, h),你需要根据实际情况调整
x, y, w, h = map(int, bbox)

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save