From ef5739fa17944d197f9548ff7efa9d87be84b33e Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Sat, 13 Sep 2025 13:29:56 +0800
Subject: [PATCH 01/32] =?UTF-8?q?=E5=85=B7=E8=BA=AB=E4=BA=BA=E8=A7=86?=
=?UTF-8?q?=E8=A7=89=E8=AF=86=E5=88=AB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/humanoid_hlaa/README.md.txt | 0
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 src/humanoid_hlaa/README.md.txt
diff --git a/src/humanoid_hlaa/README.md.txt b/src/humanoid_hlaa/README.md.txt
new file mode 100644
index 0000000000..e69de29bb2
From 49ffa4468031ae0ed0347aae5cbe9989617a940d Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Sat, 13 Sep 2025 14:59:04 +0800
Subject: [PATCH 02/32] =?UTF-8?q?=E5=85=B7=E8=BA=AB=E4=BA=BA=E8=A7=86?=
=?UTF-8?q?=E8=A7=89=E8=AF=86=E5=88=AB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../README.md.txt | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename src/{humanoid_hlaa => Humanoid_Machine Vision Recognition}/README.md.txt (100%)
diff --git a/src/humanoid_hlaa/README.md.txt b/src/Humanoid_Machine Vision Recognition/README.md.txt
similarity index 100%
rename from src/humanoid_hlaa/README.md.txt
rename to src/Humanoid_Machine Vision Recognition/README.md.txt
From 9f98a37d03d832e2212e18cc06772ca4683e4c6a Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Sat, 13 Sep 2025 17:06:36 +0800
Subject: [PATCH 03/32] =?UTF-8?q?=E5=85=B7=E8=BA=AB=E4=BA=BA=E8=A7=86?=
=?UTF-8?q?=E8=A7=89=E8=AF=86=E5=88=AB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../README.md.txt | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename src/{Humanoid_Machine Vision Recognition => Humanoid_Machine_vision_Recognition}/README.md.txt (100%)
diff --git a/src/Humanoid_Machine Vision Recognition/README.md.txt b/src/Humanoid_Machine_vision_Recognition/README.md.txt
similarity index 100%
rename from src/Humanoid_Machine Vision Recognition/README.md.txt
rename to src/Humanoid_Machine_vision_Recognition/README.md.txt
From e41aeda5633ca9828875065dfffebbc551e0b9ac Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Sat, 13 Sep 2025 17:16:51 +0800
Subject: [PATCH 04/32] =?UTF-8?q?=E5=85=B7=E8=BA=AB=E4=BA=BA=E8=A7=86?=
=?UTF-8?q?=E8=A7=89=E8=AF=86=E5=88=AB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../README.md.txt | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename src/{humanoid_hlaa => humanoid_machine_vision_recognition}/README.md.txt (100%)
diff --git a/src/humanoid_hlaa/README.md.txt b/src/humanoid_machine_vision_recognition/README.md.txt
similarity index 100%
rename from src/humanoid_hlaa/README.md.txt
rename to src/humanoid_machine_vision_recognition/README.md.txt
From b30548bc836935aa7293ebc2a49a04fa3969a0fd Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Sat, 13 Sep 2025 18:14:34 +0800
Subject: [PATCH 05/32] =?UTF-8?q?=E5=85=B7=E8=BA=AB=E4=BA=BA=E8=A7=86?=
=?UTF-8?q?=E8=A7=89=E8=AF=86=E5=88=AB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/Humanoid_Machine_vision_Recognition/README.md | 0
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 src/Humanoid_Machine_vision_Recognition/README.md
diff --git a/src/Humanoid_Machine_vision_Recognition/README.md b/src/Humanoid_Machine_vision_Recognition/README.md
new file mode 100644
index 0000000000..e69de29bb2
From 26a59994be27996485f7dd4e639edb258e28fd1a Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Sat, 13 Sep 2025 18:22:45 +0800
Subject: [PATCH 06/32] README.md.txt
---
src/humanoid_machine_vision_recognition/README.md.txt | 0
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 src/humanoid_machine_vision_recognition/README.md.txt
diff --git a/src/humanoid_machine_vision_recognition/README.md.txt b/src/humanoid_machine_vision_recognition/README.md.txt
deleted file mode 100644
index e69de29bb2..0000000000
From 327d7b050e92fe679b8fe3a97550e0f058db91a5 Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Sat, 13 Sep 2025 18:59:14 +0800
Subject: [PATCH 07/32] =?UTF-8?q?=E5=A4=84=E7=90=86=20README.md.txt=20?=
=?UTF-8?q?=E7=9B=B8=E5=85=B3=E5=8F=98=E6=9B=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/Humanoid_Machine_vision_Recognition/README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/Humanoid_Machine_vision_Recognition/README.md b/src/Humanoid_Machine_vision_Recognition/README.md
index e69de29bb2..e89b7ad11a 100644
--- a/src/Humanoid_Machine_vision_Recognition/README.md
+++ b/src/Humanoid_Machine_vision_Recognition/README.md
@@ -0,0 +1 @@
+这是一个具身人视觉识别系统
\ No newline at end of file
From 90c0ed5a694832fbad2179af5a06428442abef8a Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Sat, 13 Sep 2025 19:24:01 +0800
Subject: [PATCH 08/32] =?UTF-8?q?=E5=A4=84=E7=90=86=20README.md=20?=
=?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=92=8CREADME.md.txt=E5=88=A0=E9=99=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/Humanoid_Machine_vision_Recognition/README.md | 1 -
src/Humanoid_Machine_vision_Recognition/README.md.txt | 0
2 files changed, 1 deletion(-)
delete mode 100644 src/Humanoid_Machine_vision_Recognition/README.md.txt
diff --git a/src/Humanoid_Machine_vision_Recognition/README.md b/src/Humanoid_Machine_vision_Recognition/README.md
index e89b7ad11a..e69de29bb2 100644
--- a/src/Humanoid_Machine_vision_Recognition/README.md
+++ b/src/Humanoid_Machine_vision_Recognition/README.md
@@ -1 +0,0 @@
-这是一个具身人视觉识别系统
\ No newline at end of file
diff --git a/src/Humanoid_Machine_vision_Recognition/README.md.txt b/src/Humanoid_Machine_vision_Recognition/README.md.txt
deleted file mode 100644
index e69de29bb2..0000000000
From 394d49f9559eed7c744ea471b05b1258dd5373ba Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Mon, 15 Sep 2025 08:52:59 +0800
Subject: [PATCH 09/32] Update README.md
---
src/Humanoid_Machine_vision_Recognition/README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/Humanoid_Machine_vision_Recognition/README.md b/src/Humanoid_Machine_vision_Recognition/README.md
index e69de29bb2..e1af47c7fa 100644
--- a/src/Humanoid_Machine_vision_Recognition/README.md
+++ b/src/Humanoid_Machine_vision_Recognition/README.md
@@ -0,0 +1 @@
+杩欐槸鍏疯韩浜鸿瑙夎瘑鍒ā鍧
From a4f0e09ac2347995aa98bd509cde48c1ee0f0204 Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Mon, 22 Sep 2025 10:04:09 +0800
Subject: [PATCH 10/32] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A0=94=E7=A9=B6?=
=?UTF-8?q?=E8=AF=BE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/detection/README.md | 1 +
1 file changed, 1 insertion(+)
create mode 100644 src/detection/README.md
diff --git a/src/detection/README.md b/src/detection/README.md
new file mode 100644
index 0000000000..0d16c3c448
--- /dev/null
+++ b/src/detection/README.md
@@ -0,0 +1 @@
+2D涓3D妫娴
\ No newline at end of file
From d8a4de519c0c0ce0111e8f4db35f67e72a04a768 Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Mon, 22 Sep 2025 10:23:36 +0800
Subject: [PATCH 11/32] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A0=94=E7=A9=B6?=
=?UTF-8?q?=E8=AF=BE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/Humanoid_Machine_vision_Recognition/README.md | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 src/Humanoid_Machine_vision_Recognition/README.md
diff --git a/src/Humanoid_Machine_vision_Recognition/README.md b/src/Humanoid_Machine_vision_Recognition/README.md
deleted file mode 100644
index e1af47c7fa..0000000000
--- a/src/Humanoid_Machine_vision_Recognition/README.md
+++ /dev/null
@@ -1 +0,0 @@
-杩欐槸鍏疯韩浜鸿瑙夎瘑鍒ā鍧
From 7daf1ef2ac04e9c336fcb5281a0d0517b54047bb Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Tue, 18 Nov 2025 08:28:40 +0800
Subject: [PATCH 12/32] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6?=
=?UTF-8?q?=E7=9B=AE=E5=BD=95=E4=BB=A5=E5=8F=8A=E5=85=B6=E5=8C=85=E5=90=AB?=
=?UTF-8?q?=E7=9A=84README=E6=96=87=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/detection/README.md | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 src/detection/README.md
diff --git a/src/detection/README.md b/src/detection/README.md
deleted file mode 100644
index 0d16c3c448..0000000000
--- a/src/detection/README.md
+++ /dev/null
@@ -1 +0,0 @@
-2D涓3D妫娴
\ No newline at end of file
From deca5a8916aad67e1b818a796794205319a5fbb8 Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Tue, 18 Nov 2025 08:45:12 +0800
Subject: [PATCH 13/32] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E7=9A=84?=
=?UTF-8?q?=E8=87=AA=E8=BF=B0=E6=96=87=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/InterconVis_PedSafety_Enh/README.md | 113 ++++++++++++++++++++++++
1 file changed, 113 insertions(+)
create mode 100644 src/InterconVis_PedSafety_Enh/README.md
diff --git a/src/InterconVis_PedSafety_Enh/README.md b/src/InterconVis_PedSafety_Enh/README.md
new file mode 100644
index 0000000000..afbc3105da
--- /dev/null
+++ b/src/InterconVis_PedSafety_Enh/README.md
@@ -0,0 +1,113 @@
+# CVIPS: Connected Vision for Increased Pedestrian Safety
+Implementation of the CVIPS project.
+- [X] Dataset
+- [X] CARLA data generation code
+
+
+
+## Dataset
+The CVIPS dataset is available [here](https://drive.google.com/drive/folders/1gCCrIslzVkupyF0lj_1I9qXTB2_a4tjd?usp=drive_link).
+
+
+
+
+
+## Installation
+Please check [installation](https://carla.readthedocs.io/en/0.9.14/build_windows) on how to setup CARLA for windows
+
+
+
+## Dataset Generation
+Our dataset is generated using the CARLA simulator, providing diverse scenarios for collaborative perception.
+
+### Running the Data Generation Script
+
+1. Clone the repository:
+ ```
+ git clone https://github.com/cvips/CVIPS.git
+ cd CVIPS
+ ```
+
+2. Install the required dependencies:
+ ```
+ pip install -r requirements.txt
+ ```
+
+3. Ensure CARLA is properly installed and running. Start the CARLA server in a separate terminal:
+ ```
+ /path/to/carla/CarlaUE4.exe
+ ```
+
+4. Run the data generation script:
+ ```
+ python cvips_generation.py
+ ```
+
+ This script will connect to the CARLA server and generate the dataset based on the specified parameters.
+
+Note: Make sure to adjust the CARLA server path and any configuration parameters in `cvips_generation.py` as needed for your specific setup.
+
+### Sample Examples
+
+Here are some example commands to generate different scenarios:
+
+1. Four-way intersection in Town10HD with clear weather at noon:
+ ```
+ python cvips_generation.py --town Town10HD --intersection 4way --setup wsee --weather clear --time_of_the_day noon --crowd_level medium --crossing_percentage 0.1 --seed_value 23 --scenario scenario00001
+ ```
+
+2. Four-way intersection in Town04 with rainy weather at sunset:
+ ```
+ python cvips_generation.py --town Town04 --intersection 4way --setup wwss --weather rainy --time_of_the_day sunset --crowd_level medium --crossing_percentage 0.1 --seed_value 42 --scenario scenario00002
+ ```
+
+3. Three-way intersection in Town05 with clear weather at night:
+ ```
+ python cvips_generation.py --town Town05 --intersection 3way --setup wwss --weather clear --time_of_the_day night --crowd_level medium --crossing_percentage 0.1 --seed_value 73 --scenario scenario00005
+ ```
+
+4. Four-way intersection in Town10HD with cloudy weather at noon:
+ ```
+ python cvips_generation.py --town Town10HD --intersection 4way --setup wwws --weather cloudy --time_of_the_day noon --crowd_level medium --crossing_percentage 0.1 --seed_value 101 --scenario scenario00011
+ ```
+
+These examples demonstrate various combinations of towns, intersection types, weather conditions, times of day, and camera setups. Users can modify these parameters to generate different scenarios as needed.
+
+### Sample Visualizations
+
+We provide visualizations to demonstrate different perspectives in our dataset:
+(this can be done using [Code/data_viz.py](Code\data_viz.py))
+1. **Infrastructure View** (6 cameras)
+
+ This visualization shows the scene from fixed infrastructure cameras, providing a comprehensive view of the intersection from multiple angles.
+
+2. **Vehicle View** (6 cameras)
+
+ This visualization demonstrates the perspective from a moving vehicle, showcasing the view from various angles around the vehicle.
+
+3. **Collaborative View** (4 cameras)
+
+ This visualization combines views from both vehicles and infrastructure, illustrating the collaborative perception aspect of our dataset.
+
+
+- Multiple camera perspectives (infrastructure, vehicle-mounted, and collaborative)
+- Various weather conditions and times of day ()
+- Diverse traffic scenarios with multiple vehicles and pedestrians setup (controlled by seeds, number of pedestrians, number of vehicles to be spawned)
+
+
+
+## For Detection in collaborative setup check the documentation of V2XFormer
+First, prepare the dataset with this format [data_preparation](docs/data_preparation.md) .
+Then, use [V2XFormer](https://github.com/tianqi-wang1996/DeepAccident) according to the instructions here
+1. [Installation](https://github.com/tianqi-wang1996/DeepAccident/blob/main/docs/installation.md)
+2. [Training and Evaluation](https://github.com/tianqi-wang1996/DeepAccident/blob/main/docs/getting_started.md) -- adjust the datapaths and number of classes accordingly
+
+## Acknowledgement
+This project is based on the following open-source projects: [BEVerse](https://github.com/zhangyp15/BEVerse), [Fiery](https://github.com/wayveai/fiery), [open-mmlab](https://github.com/open-mmlab), and [DeepAccident](https://arxiv.org/pdf/2304.01168).
+
+## Citation
+
+
+
+
+```
From d0405ffa81a15de061a31ba015ae57b658462427 Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Tue, 18 Nov 2025 09:11:21 +0800
Subject: [PATCH 14/32] =?UTF-8?q?=E6=89=8B=E5=8A=A8=E5=88=9B=E5=BB=BA?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=8C=E5=AE=9E=E7=8E=B0CARLA=E8=BF=9E?=
=?UTF-8?q?=E6=8E=A5=E4=B8=8E=E6=95=B0=E6=8D=AE=E7=94=9F=E6=88=90=E7=9A=84?=
=?UTF-8?q?=E6=A0=B8=E5=BF=83=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../cvips_generation.py | 24 +++++++++++++++++++
1 file changed, 24 insertions(+)
create mode 100644 src/InterconVis_PedSafety_Enh/cvips_generation.py
diff --git a/src/InterconVis_PedSafety_Enh/cvips_generation.py b/src/InterconVis_PedSafety_Enh/cvips_generation.py
new file mode 100644
index 0000000000..267be481a7
--- /dev/null
+++ b/src/InterconVis_PedSafety_Enh/cvips_generation.py
@@ -0,0 +1,24 @@
+import carla
+import time
+
+# 杩炴帴CARLA鏈嶅姟锛堥粯璁ょ鍙2000锛
+client = carla.Client('localhost', 2000)
+client.set_timeout(10.0)
+world = client.get_world()
+
+# 绀轰緥锛氱敓鎴愯溅杈嗗苟閲囬泦鏁版嵁
+blueprint_library = world.get_blueprint_library()
+vehicle_bp = blueprint_library.filter('model3')[0]
+spawn_point = world.get_map().get_spawn_points()[0]
+vehicle = world.spawn_actor(vehicle_bp, spawn_point)
+
+try:
+ # 妯℃嫙鏁版嵁閲囬泦锛堝彲鏍规嵁闇姹傛墿灞曪級
+ print("寮濮嬮噰闆嗘暟鎹...")
+ for _ in range(5):
+ transform = vehicle.get_transform()
+ print(f"杞﹁締浣嶇疆: {transform.location}")
+ time.sleep(1)
+finally:
+ vehicle.destroy()
+ print("鏁版嵁閲囬泦缁撴潫")
\ No newline at end of file
From 740fe77c998fa707264ccf338778b90617733fc4 Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Tue, 18 Nov 2025 09:25:28 +0800
Subject: [PATCH 15/32] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=94=B9=E8=BF=9Bcarla?=
=?UTF-8?q?=E8=BF=9E=E6=8E=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../cvips_generation.py | 43 ++++++++++---------
1 file changed, 23 insertions(+), 20 deletions(-)
diff --git a/src/InterconVis_PedSafety_Enh/cvips_generation.py b/src/InterconVis_PedSafety_Enh/cvips_generation.py
index 267be481a7..fce42067ca 100644
--- a/src/InterconVis_PedSafety_Enh/cvips_generation.py
+++ b/src/InterconVis_PedSafety_Enh/cvips_generation.py
@@ -1,24 +1,27 @@
import carla
+import argparse
import time
-# 杩炴帴CARLA鏈嶅姟锛堥粯璁ょ鍙2000锛
-client = carla.Client('localhost', 2000)
-client.set_timeout(10.0)
-world = client.get_world()
+# 鍙傛暟瑙f瀽+CARLA杩炴帴+鍦板浘鍔犺浇
+if __name__ == "__main__":
+ # 1. 瑙f瀽鍛戒护琛屽弬鏁帮紙甯﹁緭鍏ユ牎楠岋級
+ parser = argparse.ArgumentParser(description='CVIPS鍦烘櫙鏁版嵁鐢熸垚宸ュ叿')
+ parser.add_argument('--town', type=str, required=True, choices=['Town04', 'Town10HD', 'Town07'],
+ help='CARLA鍩庨晣鍦板浘锛堟敮鎸侊細Town04/Town10HD/Town07锛')
+ parser.add_argument('--intersection', type=str, required=True, choices=['3way', '4way'],
+ help='璺彛绫诲瀷锛3way=涓夊弶璺彛锛4way=鍥涘矓璺彛锛')
+ parser.add_argument('--weather', type=str, required=True, choices=['clear', 'rainy', 'cloudy'],
+ help='澶╂皵鏉′欢锛坈lear=鏅村ぉ锛宺ainy=闆ㄥぉ锛宑loudy=闃村ぉ锛')
+ parser.add_argument('--time_of_day', type=str, required=True, choices=['noon', 'sunset', 'night'],
+ help='鏃舵锛坣oon=涓崍锛宻unset=鏃ヨ惤锛宯ight=澶滄櫄锛')
+ args = parser.parse_args()
-# 绀轰緥锛氱敓鎴愯溅杈嗗苟閲囬泦鏁版嵁
-blueprint_library = world.get_blueprint_library()
-vehicle_bp = blueprint_library.filter('model3')[0]
-spawn_point = world.get_map().get_spawn_points()[0]
-vehicle = world.spawn_actor(vehicle_bp, spawn_point)
-
-try:
- # 妯℃嫙鏁版嵁閲囬泦锛堝彲鏍规嵁闇姹傛墿灞曪級
- print("寮濮嬮噰闆嗘暟鎹...")
- for _ in range(5):
- transform = vehicle.get_transform()
- print(f"杞﹁締浣嶇疆: {transform.location}")
- time.sleep(1)
-finally:
- vehicle.destroy()
- print("鏁版嵁閲囬泦缁撴潫")
\ No newline at end of file
+ try:
+ # 2. 杩炴帴CARLA鏈嶅姟鍣紙璁剧疆瓒呮椂閲嶈瘯鏈哄埗锛
+ client = carla.Client('localhost', 2000)
+ client.set_timeout(15.0)
+ client.load_world(args.town) # 鍔犺浇鎸囧畾鍩庨晣
+ world = client.get_world()
+ print(f"鉁 鎴愬姛杩炴帴CARLA骞跺姞杞藉湴鍥撅細{args.town}")
+ except Exception as e:
+ print(f"鉂 杩炴帴澶辫触锛歿str(e)}锛岃妫鏌ARLA鏈嶅姟鍣ㄦ槸鍚﹀惎鍔")
\ No newline at end of file
From dc692080fe01be4fc55580ae00bcb9a2bfee935b Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Tue, 18 Nov 2025 17:13:41 +0800
Subject: [PATCH 16/32] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=86=B2=E7=AA=81?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../cvips_generation.py | 30 ++-----------------
1 file changed, 2 insertions(+), 28 deletions(-)
diff --git a/src/InterconVis_PedSafety_Enh/cvips_generation.py b/src/InterconVis_PedSafety_Enh/cvips_generation.py
index 667c36a007..20f8b1975d 100644
--- a/src/InterconVis_PedSafety_Enh/cvips_generation.py
+++ b/src/InterconVis_PedSafety_Enh/cvips_generation.py
@@ -1,9 +1,8 @@
import carla
-<<<<<<< HEAD
import argparse
import time
-# 鍙傛暟瑙f瀽+CARLA杩炴帴+鍦板浘鍔犺浇
+# 瀹屾暣浠g爜锛氬弬鏁拌В鏋+CARLA杩炴帴+鍦板浘鍔犺浇
if __name__ == "__main__":
# 1. 瑙f瀽鍛戒护琛屽弬鏁帮紙甯﹁緭鍏ユ牎楠岋級
parser = argparse.ArgumentParser(description='CVIPS鍦烘櫙鏁版嵁鐢熸垚宸ュ叿')
@@ -25,29 +24,4 @@
world = client.get_world()
print(f"鉁 鎴愬姛杩炴帴CARLA骞跺姞杞藉湴鍥撅細{args.town}")
except Exception as e:
- print(f"鉂 杩炴帴澶辫触锛歿str(e)}锛岃妫鏌ARLA鏈嶅姟鍣ㄦ槸鍚﹀惎鍔")
-=======
-import time
-
-# 杩炴帴CARLA鏈嶅姟锛堥粯璁ょ鍙2000锛
-client = carla.Client('localhost', 2000)
-client.set_timeout(10.0)
-world = client.get_world()
-
-# 绀轰緥锛氱敓鎴愯溅杈嗗苟閲囬泦鏁版嵁
-blueprint_library = world.get_blueprint_library()
-vehicle_bp = blueprint_library.filter('model3')[0]
-spawn_point = world.get_map().get_spawn_points()[0]
-vehicle = world.spawn_actor(vehicle_bp, spawn_point)
-
-try:
- # 妯℃嫙鏁版嵁閲囬泦锛堝彲鏍规嵁闇姹傛墿灞曪級
- print("寮濮嬮噰闆嗘暟鎹...")
- for _ in range(5):
- transform = vehicle.get_transform()
- print(f"杞﹁締浣嶇疆: {transform.location}")
- time.sleep(1)
-finally:
- vehicle.destroy()
- print("鏁版嵁閲囬泦缁撴潫")
->>>>>>> 2aed4c9d022da20198dd176e94c525d3c39b4c39
+ print(f"鉂 杩炴帴澶辫触锛歿str(e)}锛岃妫鏌ARLA鏈嶅姟鍣ㄦ槸鍚﹀惎鍔")
\ No newline at end of file
From d3b396368371f6cdda6ebfb83c7c90d214c56655 Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Thu, 20 Nov 2025 10:36:56 +0800
Subject: [PATCH 17/32] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=BF=9E=E6=8E=A5?=
=?UTF-8?q?=E5=92=8C=E8=B5=84=E6=BA=90=E5=A4=84=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../cvips_generation.py | 128 ++++++++++++++++--
1 file changed, 118 insertions(+), 10 deletions(-)
diff --git a/src/InterconVis_PedSafety_Enh/cvips_generation.py b/src/InterconVis_PedSafety_Enh/cvips_generation.py
index 20f8b1975d..223b86f448 100644
--- a/src/InterconVis_PedSafety_Enh/cvips_generation.py
+++ b/src/InterconVis_PedSafety_Enh/cvips_generation.py
@@ -1,9 +1,12 @@
import carla
import argparse
import time
+import atexit
-# 瀹屾暣浠g爜锛氬弬鏁拌В鏋+CARLA杩炴帴+鍦板浘鍔犺浇
-if __name__ == "__main__":
+# 鍏ㄥ眬鍙橀噺锛氬瓨鍌ㄧ敓鎴愮殑CARLA Actor锛堣溅杈嗐佷紶鎰熷櫒绛夛級锛岀敤浜庨鍑烘椂娓呯悊
+generated_actors = []
+
+def main():
# 1. 瑙f瀽鍛戒护琛屽弬鏁帮紙甯﹁緭鍏ユ牎楠岋級
parser = argparse.ArgumentParser(description='CVIPS鍦烘櫙鏁版嵁鐢熸垚宸ュ叿')
parser.add_argument('--town', type=str, required=True, choices=['Town04', 'Town10HD', 'Town07'],
@@ -16,12 +19,117 @@
help='鏃舵锛坣oon=涓崍锛宻unset=鏃ヨ惤锛宯ight=澶滄櫄锛')
args = parser.parse_args()
+ # 2. 杩炴帴CARLA鏈嶅姟鍣紙甯﹂噸璇曟満鍒讹級
+ client, world = connect_carla_with_retry(args.town)
+ if not world:
+ return # 杩炴帴澶辫触鐩存帴閫鍑
+
+ # 3. 閰嶇疆澶╂皵鍜屾椂娈碉紙璁╁弬鏁板疄闄呯敓鏁堬級
+ configure_weather_and_time(world, args.weather, args.time_of_day)
+
+ # 4. 鍩轰簬璺彛绫诲瀷鐢熸垚鍦烘櫙锛堥鐣欐牳蹇冮昏緫锛屽彲鏍规嵁闇姹傛墿灞曪級
+ generate_intersection_scene(world, args.intersection)
+
+ # 5. 淇濇寔鍦烘櫙杩愯锛堟寜 Ctrl+C 閫鍑哄苟娓呯悊璧勬簮锛
+ print("\n馃殫 鍦烘櫙宸插惎鍔紒鎸 Ctrl+C 閫鍑哄苟娓呯悊璧勬簮...")
try:
- # 2. 杩炴帴CARLA鏈嶅姟鍣紙璁剧疆瓒呮椂閲嶈瘯鏈哄埗锛
- client = carla.Client('localhost', 2000)
- client.set_timeout(15.0)
- client.load_world(args.town) # 鍔犺浇鎸囧畾鍩庨晣
- world = client.get_world()
- print(f"鉁 鎴愬姛杩炴帴CARLA骞跺姞杞藉湴鍥撅細{args.town}")
- except Exception as e:
- print(f"鉂 杩炴帴澶辫触锛歿str(e)}锛岃妫鏌ARLA鏈嶅姟鍣ㄦ槸鍚﹀惎鍔")
\ No newline at end of file
+ while True:
+ time.sleep(1)
+ except KeyboardInterrupt:
+ print("\n馃洃 鏀跺埌閫鍑轰俊鍙凤紝寮濮嬫竻鐞嗚祫婧...")
+
+# ------------------------------ 杈呭姪鍑芥暟 ------------------------------
+def connect_carla_with_retry(town_name, max_retries=3, retry_interval=5):
+ """甯﹂噸璇曟満鍒剁殑CARLA杩炴帴鍑芥暟"""
+ client = None
+ world = None
+ for retry in range(max_retries):
+ try:
+ client = carla.Client('localhost', 2000)
+ client.set_timeout(15.0)
+ client.load_world(town_name) # 鍔犺浇鎸囧畾鍦板浘
+ world = client.get_world()
+ print(f"鉁 鎴愬姛杩炴帴CARLA骞跺姞杞藉湴鍥撅細{town_name}")
+ return client, world
+ except Exception as e:
+ error_msg = str(e)
+ if retry < max_retries - 1:
+ print(f"鉂 杩炴帴澶辫触锛坽retry+1}/{max_retries}锛夛細{error_msg}")
+ print(f"鈱 {retry_interval}绉掑悗閲嶈瘯...")
+ time.sleep(retry_interval)
+ else:
+ print(f"鉂 杩炴帴澶辫触锛堝凡杈炬渶澶ч噸璇曟鏁帮級锛歿error_msg}")
+ print("馃挕 璇锋鏌ワ細1. CARLA鏈嶅姟鍣ㄦ槸鍚﹀惎鍔 2. 绔彛鏄惁涓2000 3. 鍦板浘鍚嶇О鏄惁姝g‘")
+ return None, None
+
+def configure_weather_and_time(world, weather_type, time_of_day):
+ """閰嶇疆CARLA鐨勫ぉ姘斿拰鏃舵锛堣鍛戒护琛屽弬鏁扮敓鏁堬級"""
+ # CARLA棰勮澶╂皵鏄犲皠锛堝搴旇嚜瀹氫箟鍙傛暟锛
+ base_weather_mapping = {
+ 'clear': carla.WeatherParameters.ClearNoon,
+ 'rainy': carla.WeatherParameters.RainyNoon,
+ 'cloudy': carla.WeatherParameters.CloudyNoon
+ }
+
+ # 鑾峰彇鍩虹澶╂皵鍙傛暟骞舵牴鎹椂娈佃皟鏁
+ weather = base_weather_mapping[weather_type]
+ if time_of_day == 'sunset':
+ weather.sun_altitude_angle = -15.0 # 鏃ヨ惤锛氬お闃抽珮搴﹁涓鸿礋锛堝湴骞崇嚎浠ヤ笅锛
+ weather.ambient_light = 0.3 # 闄嶄綆鐜鍏夊己搴
+ weather.directional_light_intensity = 0.5 # 闄嶄綆鐩村皠鍏夊己搴
+ weather.fog_density = 0.1 # 鏃ヨ惤娣诲姞杞诲井闆炬皵
+ elif time_of_day == 'night':
+ weather.sun_altitude_angle = -60.0 # 澶滄櫄锛氬お闃抽珮搴﹁鏋佷綆
+ weather.ambient_light = 0.05 # 鏋佷綆鐜鍏
+ weather.directional_light_intensity = 0.01 # 鍑犱箮鏃犵洿灏勫厜
+ weather.moon_altitude_angle = 45.0 # 鏈堜寒楂樺害瑙
+ weather.moon_intensity = 0.8 # 鏈堜寒浜害
+ weather.stars_intensity = 0.5 # 鏄熸槦浜害
+ # noon锛堜腑鍗堬級锛氫娇鐢ㄩ粯璁ら璁撅紝鏃犻渶棰濆璋冩暣
+
+ # 搴旂敤澶╂皵璁剧疆
+ world.set_weather(weather)
+ print(f"鉁 宸查厤缃幆澧冿細澶╂皵={weather_type}锛屾椂娈={time_of_day}")
+
+def generate_intersection_scene(world, intersection_type):
+ """鍩轰簬璺彛绫诲瀷鐢熸垚鍦烘櫙锛堟牳蹇冮昏緫锛屽彲鎵╁睍锛"""
+ print(f"馃搶 寮濮嬬敓鎴恵intersection_type}璺彛鍦烘櫙...")
+
+ # ------------------------------
+ # 姝ゅ涓洪鐣欓昏緫锛屽彲鏍规嵁闇姹傛墿灞曪細
+ # 1. 瀹氫綅鍦板浘涓搴旂被鍨嬬殑璺彛鍧愭爣锛堥渶鎻愬墠璋冪爺鐩爣鍦板浘鐨勮矾鍙d綅缃級
+ # 2. 鍦ㄨ矾鍙e懆鍥寸敓鎴愯溅杈嗐佽浜恒佺孩缁跨伅绛堿ctor
+ # 3. 璁剧疆杞﹁締琛岄┒璺嚎銆佷氦閫氳鍒欑瓑
+ # ------------------------------
+ example_spawn_point = get_example_spawn_point(world)
+ if example_spawn_point:
+ # 绀轰緥锛氱敓鎴1杈嗘祴璇曡溅杈嗭紙娣诲姞鍒板叏灞鍒楄〃锛屾柟渚块鍑烘椂娓呯悊锛
+ vehicle_bp = world.get_blueprint_library().find('vehicle.tesla.model3')
+ vehicle = world.spawn_actor(vehicle_bp, example_spawn_point)
+ generated_actors.append(vehicle)
+ print(f"鉁 宸插湪璺彛闄勮繎鐢熸垚娴嬭瘯杞﹁締锛圛D锛歿vehicle.id}锛")
+ else:
+ print("鈿狅笍 鏈壘鍒板悎閫傜殑杞﹁締鐢熸垚鐐癸紝璺彛鍦烘櫙鐢熸垚澶辫触")
+
+def get_example_spawn_point(world):
+ """鑾峰彇绀轰緥鐢熸垚鐐癸紙鍙牴鎹疄闄呭湴鍥捐矾鍙d綅缃慨鏀癸級"""
+ spawn_points = world.get_map().get_spawn_points()
+ # 鍙栧墠10涓敓鎴愮偣涓殑绗3涓綔涓虹ず渚嬶紙鍙牴鎹湴鍥捐矾鍙d綅缃皟鏁寸储寮曪級
+ return spawn_points[2] if len(spawn_points) > 2 else None
+
+def clean_up_actors():
+ """閫鍑烘椂娓呯悊鎵鏈夌敓鎴愮殑Actor锛堣溅杈嗐佷紶鎰熷櫒绛夛級"""
+ if generated_actors:
+ print(f"馃Ч 姝e湪娓呯悊 {len(generated_actors)} 涓豢鐪熷璞...")
+ for actor in generated_actors:
+ if actor.is_alive:
+ actor.destroy()
+ print("鉁 璧勬簮娓呯悊瀹屾垚锛")
+ else:
+ print("鉁 鏃犻渶瑕佹竻鐞嗙殑浠跨湡瀵硅薄")
+
+# 娉ㄥ唽閫鍑哄洖璋冿細绋嬪簭缁堟鏃惰嚜鍔ㄦ竻鐞嗚祫婧
+atexit.register(clean_up_actors)
+
+if __name__ == "__main__":
+ main()
\ No newline at end of file
From 672201b4c4c8f13ff82d292b40592e94e7328eb2 Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Thu, 20 Nov 2025 11:24:28 +0800
Subject: [PATCH 18/32] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BB=88=E7=AB=AF?=
=?UTF-8?q?=E5=91=BD=E4=BB=A4=E8=AF=B4=E6=98=8E=E5=92=8C=E9=A1=B9=E7=9B=AE?=
=?UTF-8?q?=E4=BE=9D=E8=B5=96=E6=96=87=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/InterconVis_PedSafety_Enh/Terminal_Commands.txt | 11 +++++++++++
src/InterconVis_PedSafety_Enh/requirements.txt | 5 +++++
2 files changed, 16 insertions(+)
create mode 100644 src/InterconVis_PedSafety_Enh/Terminal_Commands.txt
create mode 100644 src/InterconVis_PedSafety_Enh/requirements.txt
diff --git a/src/InterconVis_PedSafety_Enh/Terminal_Commands.txt b/src/InterconVis_PedSafety_Enh/Terminal_Commands.txt
new file mode 100644
index 0000000000..56726ea4aa
--- /dev/null
+++ b/src/InterconVis_PedSafety_Enh/Terminal_Commands.txt
@@ -0,0 +1,11 @@
+# 娴嬭瘯1锛氬熀纭鍦烘櫙锛圱own04+4宀旇矾鍙+鏅村ぉ+涓崍锛
+python cvips_generation.py --town Town04 --intersection 4way --weather clear --time_of_day noon
+
+# 娴嬭瘯2锛氬鏉傚満鏅紙Town10HD+3宀旇矾鍙+闆ㄥぉ+鏃ヨ惤+楂樿浜哄瘑搴︼級
+python cvips_generation.py --town Town10HD --intersection 3way --weather rainy --time_of_day sunset --crowd_level high --crossing_percentage 0.3
+
+# 娴嬭瘯3锛氬闂村満鏅紙Town07+4宀旇矾鍙+闃村ぉ+澶滈棿+鑷畾涔夐殢鏈虹瀛愶級
+python cvips_generation.py --town Town07 --intersection 4way --weather cloudy --time_of_day night --seed_value 123 --scenario scenario00005
+
+# 娴嬭瘯4锛氭渶绠鍦烘櫙锛圱own04+3宀旇矾鍙+鏅村ぉ+鏃ヨ惤锛
+python cvips_generation.py --town Town04 --intersection 3way --weather clear --time_of_day sunset
\ No newline at end of file
diff --git a/src/InterconVis_PedSafety_Enh/requirements.txt b/src/InterconVis_PedSafety_Enh/requirements.txt
new file mode 100644
index 0000000000..8651856a79
--- /dev/null
+++ b/src/InterconVis_PedSafety_Enh/requirements.txt
@@ -0,0 +1,5 @@
+carla==0.9.14
+pygame==2.1.0
+numpy==1.21.5
+Pillow==9.2.0
+icecream==2.1.3
\ No newline at end of file
From b2da81079f9ede0a992663252b605d10da54a363 Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Thu, 20 Nov 2025 15:05:04 +0800
Subject: [PATCH 19/32] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8C=87=E4=BB=A4?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=E6=A0=BC=E5=BC=8F=EF=BC=8C=E4=BF=AE=E6=94=B9?=
=?UTF-8?q?=E8=BF=90=E8=A1=8C=E6=96=87=E4=BB=B6(=E4=B9=8B=E5=89=8D?=
=?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81=E4=BF=9D=E5=AD=98=E4=B8=8D=E6=88=90?=
=?UTF-8?q?=E5=8A=9F)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Terminal_Commands.md | 16 ++++
.../cvips_generation.py | 75 ++++++++++---------
2 files changed, 56 insertions(+), 35 deletions(-)
create mode 100644 src/InterconVis_PedSafety_Enh/Terminal_Commands.md
diff --git a/src/InterconVis_PedSafety_Enh/Terminal_Commands.md b/src/InterconVis_PedSafety_Enh/Terminal_Commands.md
new file mode 100644
index 0000000000..2e6bc226d4
--- /dev/null
+++ b/src/InterconVis_PedSafety_Enh/Terminal_Commands.md
@@ -0,0 +1,16 @@
+# 娴嬭瘯1锛氬熀纭鍦烘櫙锛圱own04+4宀旇矾鍙+鏅村ぉ+涓崍锛
+```shell
+python cvips_generation.py --town Town04 --intersection 4way --weather clear --time_of_day noon
+```
+# 娴嬭瘯2锛氬鏉傚満鏅紙Town10HD+3宀旇矾鍙+闆ㄥぉ+鏃ヨ惤+楂樿浜哄瘑搴︼級
+```shell
+python cvips_generation.py --town Town10HD --intersection 3way --weather rainy --time_of_day sunset --crowd_level high --crossing_percentage 0.3
+```
+# 娴嬭瘯3锛氬闂村満鏅紙Town07+4宀旇矾鍙+闃村ぉ+澶滈棿+鑷畾涔夐殢鏈虹瀛愶級
+```shell
+python cvips_generation.py --town Town07 --intersection 4way --weather cloudy --time_of_day night --seed_value 123 --scenario scenario00005
+```
+# 娴嬭瘯4锛氭渶绠鍦烘櫙锛圱own04+3宀旇矾鍙+鏅村ぉ+鏃ヨ惤锛
+```shell
+python cvips_generation.py --town Town04 --intersection 3way --weather clear --time_of_day sunset
+```
\ No newline at end of file
diff --git a/src/InterconVis_PedSafety_Enh/cvips_generation.py b/src/InterconVis_PedSafety_Enh/cvips_generation.py
index 223b86f448..0448f7124d 100644
--- a/src/InterconVis_PedSafety_Enh/cvips_generation.py
+++ b/src/InterconVis_PedSafety_Enh/cvips_generation.py
@@ -27,7 +27,7 @@ def main():
# 3. 閰嶇疆澶╂皵鍜屾椂娈碉紙璁╁弬鏁板疄闄呯敓鏁堬級
configure_weather_and_time(world, args.weather, args.time_of_day)
- # 4. 鍩轰簬璺彛绫诲瀷鐢熸垚鍦烘櫙锛堥鐣欐牳蹇冮昏緫锛屽彲鏍规嵁闇姹傛墿灞曪級
+ # 4. 鍩轰簬璺彛绫诲瀷鐢熸垚鍦烘櫙锛堝熀纭閫昏緫锛
generate_intersection_scene(world, args.intersection)
# 5. 淇濇寔鍦烘櫙杩愯锛堟寜 Ctrl+C 閫鍑哄苟娓呯悊璧勬簮锛
@@ -63,47 +63,53 @@ def connect_carla_with_retry(town_name, max_retries=3, retry_interval=5):
return None, None
def configure_weather_and_time(world, weather_type, time_of_day):
- """閰嶇疆CARLA鐨勫ぉ姘斿拰鏃舵锛堣鍛戒护琛屽弬鏁扮敓鏁堬級"""
- # CARLA棰勮澶╂皵鏄犲皠锛堝搴旇嚜瀹氫箟鍙傛暟锛
- base_weather_mapping = {
- 'clear': carla.WeatherParameters.ClearNoon,
- 'rainy': carla.WeatherParameters.RainyNoon,
- 'cloudy': carla.WeatherParameters.CloudyNoon
- }
-
- # 鑾峰彇鍩虹澶╂皵鍙傛暟骞舵牴鎹椂娈佃皟鏁
- weather = base_weather_mapping[weather_type]
- if time_of_day == 'sunset':
- weather.sun_altitude_angle = -15.0 # 鏃ヨ惤锛氬お闃抽珮搴﹁涓鸿礋锛堝湴骞崇嚎浠ヤ笅锛
- weather.ambient_light = 0.3 # 闄嶄綆鐜鍏夊己搴
- weather.directional_light_intensity = 0.5 # 闄嶄綆鐩村皠鍏夊己搴
- weather.fog_density = 0.1 # 鏃ヨ惤娣诲姞杞诲井闆炬皵
+ """閰嶇疆CARLA鐨勫ぉ姘斿拰鏃舵锛堢粏鍖栦笉鍚屽ぉ姘-鏃舵鐨勭幆澧冨弬鏁帮級"""
+ # 鍒濆鍖栧ぉ姘斿弬鏁
+ weather = carla.WeatherParameters()
+
+ # 閰嶇疆澶╂皵绫诲瀷
+ if weather_type == 'clear':
+ weather.cloudiness = 0.0
+ weather.precipitation = 0.0
+ elif weather_type == 'rainy':
+ weather.cloudiness = 80.0
+ weather.precipitation = 50.0
+ weather.precipitation_deposits = 30.0
+ weather.wind_intensity = 10.0 # 闆ㄥぉ澧炲姞椋庡姏
+ elif weather_type == 'cloudy':
+ weather.cloudiness = 70.0
+ weather.precipitation = 0.0
+ weather.fog_density = 0.2 # 闃村ぉ澧炲姞闆炬皵
+
+ # 閰嶇疆鏃舵锛堥氳繃澶槼楂樺害瑙掋佺幆澧冨厜绛夊弬鏁帮級
+ if time_of_day == 'noon':
+ weather.sun_altitude_angle = 90.0 # 姝e崍澶槼楂樺害瑙
+ weather.ambient_light = 1.0
+ weather.directional_light_intensity = 2.0
+ elif time_of_day == 'sunset':
+ weather.sun_altitude_angle = -15.0 # 鏃ヨ惤澶槼楂樺害瑙掞紙鍦板钩绾夸互涓嬶級
+ weather.ambient_light = 0.3
+ weather.directional_light_intensity = 0.5
+ weather.fog_density = 0.1 # 鏃ヨ惤闆炬皵
elif time_of_day == 'night':
- weather.sun_altitude_angle = -60.0 # 澶滄櫄锛氬お闃抽珮搴﹁鏋佷綆
- weather.ambient_light = 0.05 # 鏋佷綆鐜鍏
- weather.directional_light_intensity = 0.01 # 鍑犱箮鏃犵洿灏勫厜
- weather.moon_altitude_angle = 45.0 # 鏈堜寒楂樺害瑙
- weather.moon_intensity = 0.8 # 鏈堜寒浜害
- weather.stars_intensity = 0.5 # 鏄熸槦浜害
- # noon锛堜腑鍗堬級锛氫娇鐢ㄩ粯璁ら璁撅紝鏃犻渶棰濆璋冩暣
-
+ weather.sun_altitude_angle = -60.0 # 澶滈棿澶槼楂樺害瑙
+ weather.ambient_light = 0.05
+ weather.directional_light_intensity = 0.01
+ weather.moon_altitude_angle = 45.0 # 鏈堜寒楂樺害瑙
+ weather.moon_intensity = 0.8 # 鏈堜寒浜害
+ weather.stars_intensity = 0.5 # 鏄熸槦浜害
+
# 搴旂敤澶╂皵璁剧疆
world.set_weather(weather)
print(f"鉁 宸查厤缃幆澧冿細澶╂皵={weather_type}锛屾椂娈={time_of_day}")
def generate_intersection_scene(world, intersection_type):
- """鍩轰簬璺彛绫诲瀷鐢熸垚鍦烘櫙锛堟牳蹇冮昏緫锛屽彲鎵╁睍锛"""
+ """鍩轰簬璺彛绫诲瀷鐢熸垚鍩虹鍦烘櫙锛堝彲鍚庣画鎵╁睍锛"""
print(f"馃搶 寮濮嬬敓鎴恵intersection_type}璺彛鍦烘櫙...")
- # ------------------------------
- # 姝ゅ涓洪鐣欓昏緫锛屽彲鏍规嵁闇姹傛墿灞曪細
- # 1. 瀹氫綅鍦板浘涓搴旂被鍨嬬殑璺彛鍧愭爣锛堥渶鎻愬墠璋冪爺鐩爣鍦板浘鐨勮矾鍙d綅缃級
- # 2. 鍦ㄨ矾鍙e懆鍥寸敓鎴愯溅杈嗐佽浜恒佺孩缁跨伅绛堿ctor
- # 3. 璁剧疆杞﹁締琛岄┒璺嚎銆佷氦閫氳鍒欑瓑
- # ------------------------------
example_spawn_point = get_example_spawn_point(world)
if example_spawn_point:
- # 绀轰緥锛氱敓鎴1杈嗘祴璇曡溅杈嗭紙娣诲姞鍒板叏灞鍒楄〃锛屾柟渚块鍑烘椂娓呯悊锛
+ # 绀轰緥锛氱敓鎴1杈嗘祴璇曡溅杈
vehicle_bp = world.get_blueprint_library().find('vehicle.tesla.model3')
vehicle = world.spawn_actor(vehicle_bp, example_spawn_point)
generated_actors.append(vehicle)
@@ -112,13 +118,12 @@ def generate_intersection_scene(world, intersection_type):
print("鈿狅笍 鏈壘鍒板悎閫傜殑杞﹁締鐢熸垚鐐癸紝璺彛鍦烘櫙鐢熸垚澶辫触")
def get_example_spawn_point(world):
- """鑾峰彇绀轰緥鐢熸垚鐐癸紙鍙牴鎹疄闄呭湴鍥捐矾鍙d綅缃慨鏀癸級"""
+ """鑾峰彇绀轰緥鐢熸垚鐐"""
spawn_points = world.get_map().get_spawn_points()
- # 鍙栧墠10涓敓鎴愮偣涓殑绗3涓綔涓虹ず渚嬶紙鍙牴鎹湴鍥捐矾鍙d綅缃皟鏁寸储寮曪級
return spawn_points[2] if len(spawn_points) > 2 else None
def clean_up_actors():
- """閫鍑烘椂娓呯悊鎵鏈夌敓鎴愮殑Actor锛堣溅杈嗐佷紶鎰熷櫒绛夛級"""
+ """閫鍑烘椂娓呯悊鎵鏈夌敓鎴愮殑Actor"""
if generated_actors:
print(f"馃Ч 姝e湪娓呯悊 {len(generated_actors)} 涓豢鐪熷璞...")
for actor in generated_actors:
From 2197eeb7c58886301c2c5212e2755f9e01164641 Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Thu, 20 Nov 2025 15:25:25 +0800
Subject: [PATCH 20/32] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=8C=87=E4=BB=A4?=
=?UTF-8?q?=E8=AF=B4=E6=98=8E?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Terminal_Commands.md | 21 ++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/src/InterconVis_PedSafety_Enh/Terminal_Commands.md b/src/InterconVis_PedSafety_Enh/Terminal_Commands.md
index 2e6bc226d4..0908add989 100644
--- a/src/InterconVis_PedSafety_Enh/Terminal_Commands.md
+++ b/src/InterconVis_PedSafety_Enh/Terminal_Commands.md
@@ -1,16 +1,23 @@
-# 娴嬭瘯1锛氬熀纭鍦烘櫙锛圱own04+4宀旇矾鍙+鏅村ぉ+涓崍锛
+# 1. 鍩虹鍦烘櫙锛氬悇鍦板浘+璺彛绫诲瀷楠岃瘉
```shell
python cvips_generation.py --town Town04 --intersection 4way --weather clear --time_of_day noon
+python cvips_generation.py --town Town10HD --intersection 3way --weather clear --time_of_day sunset
+python cvips_generation.py --town Town07 --intersection 4way --weather cloudy --time_of_day noon
```
-# 娴嬭瘯2锛氬鏉傚満鏅紙Town10HD+3宀旇矾鍙+闆ㄥぉ+鏃ヨ惤+楂樿浜哄瘑搴︼級
+# 2. 澶╂皵+鏃舵缁勫悎鍦烘櫙锛堣鐩栨墍鏈夌幆澧冪粍鍚堬級
```shell
-python cvips_generation.py --town Town10HD --intersection 3way --weather rainy --time_of_day sunset --crowd_level high --crossing_percentage 0.3
+python cvips_generation.py --town Town04 --intersection 3way --weather rainy --time_of_day night
+python cvips_generation.py --town Town10HD --intersection 4way --weather cloudy --time_of_day sunset
+python cvips_generation.py --town Town07 --intersection 3way --weather clear --time_of_day night
+python cvips_generation.py --town Town04 --intersection 4way --weather rainy --time_of_day noon
```
-# 娴嬭瘯3锛氬闂村満鏅紙Town07+4宀旇矾鍙+闃村ぉ+澶滈棿+鑷畾涔夐殢鏈虹瀛愶級
+# 3. 杈圭晫鍦烘櫙锛堟瀬闄愮幆澧冩祴璇曪級
```shell
-python cvips_generation.py --town Town07 --intersection 4way --weather cloudy --time_of_day night --seed_value 123 --scenario scenario00005
+python cvips_generation.py --town Town10HD --intersection 4way --weather rainy --time_of_day night
+python cvips_generation.py --town Town07 --intersection 3way --weather cloudy --time_of_day night
```
-# 娴嬭瘯4锛氭渶绠鍦烘櫙锛圱own04+3宀旇矾鍙+鏅村ぉ+鏃ヨ惤锛
+# 4. 甯哥敤鍦烘櫙蹇嵎鎸囦护
```shell
-python cvips_generation.py --town Town04 --intersection 3way --weather clear --time_of_day sunset
+python cvips_generation.py --town Town04 --intersection 3way --weather clear --time_of_day noon
+python cvips_generation.py --town Town10HD --intersection 4way --weather clear --time_of_day sunset
```
\ No newline at end of file
From d69375b0bf052f00a07b020ae468151a302b596b Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Mon, 24 Nov 2025 10:25:33 +0800
Subject: [PATCH 21/32] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BD=A6=E8=BE=86?=
=?UTF-8?q?=E5=AF=B9=E8=B1=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../cvips_generation.py | 158 +++++++++---------
1 file changed, 83 insertions(+), 75 deletions(-)
diff --git a/src/InterconVis_PedSafety_Enh/cvips_generation.py b/src/InterconVis_PedSafety_Enh/cvips_generation.py
index 0448f7124d..df65e44881 100644
--- a/src/InterconVis_PedSafety_Enh/cvips_generation.py
+++ b/src/InterconVis_PedSafety_Enh/cvips_generation.py
@@ -2,35 +2,45 @@
import argparse
import time
import atexit
+import random
-# 鍏ㄥ眬鍙橀噺锛氬瓨鍌ㄧ敓鎴愮殑CARLA Actor锛堣溅杈嗐佷紶鎰熷櫒绛夛級锛岀敤浜庨鍑烘椂娓呯悊
+# 鍏ㄥ眬鍙橀噺
generated_actors = []
+client = None
+world = None
def main():
- # 1. 瑙f瀽鍛戒护琛屽弬鏁帮紙甯﹁緭鍏ユ牎楠岋級
- parser = argparse.ArgumentParser(description='CVIPS鍦烘櫙鏁版嵁鐢熸垚宸ュ叿')
- parser.add_argument('--town', type=str, required=True, choices=['Town04', 'Town10HD', 'Town07'],
- help='CARLA鍩庨晣鍦板浘锛堟敮鎸侊細Town04/Town10HD/Town07锛')
- parser.add_argument('--intersection', type=str, required=True, choices=['3way', '4way'],
- help='璺彛绫诲瀷锛3way=涓夊弶璺彛锛4way=鍥涘矓璺彛锛')
- parser.add_argument('--weather', type=str, required=True, choices=['clear', 'rainy', 'cloudy'],
- help='澶╂皵鏉′欢锛坈lear=鏅村ぉ锛宺ainy=闆ㄥぉ锛宑loudy=闃村ぉ锛')
- parser.add_argument('--time_of_day', type=str, required=True, choices=['noon', 'sunset', 'night'],
- help='鏃舵锛坣oon=涓崍锛宻unset=鏃ヨ惤锛宯ight=澶滄櫄锛')
+ global client, world
+
+ parser = argparse.ArgumentParser(description='CARLA 0.9.14 杞﹁締鐢熸垚宸ュ叿 (鏀寔鐜閰嶇疆)')
+ parser.add_argument('--town', type=str, required=True, help='鍩庨晣鍦板浘 (渚嬪: Town04)')
+ parser.add_argument('--num_vehicles', type=int, default=10, help='鐢熸垚杞﹁締鏁伴噺')
+ parser.add_argument('--seed', type=int, default=None, help='闅忔満绉嶅瓙')
+ # 鏂板鐜鍙傛暟
+ parser.add_argument('--weather', type=str, default='clear', choices=['clear', 'rainy', 'cloudy'], help='澶╂皵绫诲瀷')
+ parser.add_argument('--time_of_day', type=str, default='noon', choices=['noon', 'sunset', 'night'], help='鏃舵')
args = parser.parse_args()
- # 2. 杩炴帴CARLA鏈嶅姟鍣紙甯﹂噸璇曟満鍒讹級
+ # 璁剧疆闅忔満绉嶅瓙
+ if args.seed is not None:
+ random.seed(args.seed)
+ print(f"鉁 宸茶缃殢鏈虹瀛: {args.seed}")
+
+ # 杩炴帴 CARLA
client, world = connect_carla_with_retry(args.town)
if not world:
- return # 杩炴帴澶辫触鐩存帴閫鍑
+ return
- # 3. 閰嶇疆澶╂皵鍜屾椂娈碉紙璁╁弬鏁板疄闄呯敓鏁堬級
+ # --- 鏂板浠g爜锛氶厤缃ぉ姘斿拰鏃堕棿 ---
+ print("\n馃尋锔 姝e湪閰嶇疆鐜...")
configure_weather_and_time(world, args.weather, args.time_of_day)
- # 4. 鍩轰簬璺彛绫诲瀷鐢熸垚鍦烘櫙锛堝熀纭閫昏緫锛
- generate_intersection_scene(world, args.intersection)
+ # 鐢熸垚杞﹁締
+ print("\n馃搶 寮濮嬬敓鎴愬満鏅...")
+ generate_vehicles(world, args.num_vehicles)
+ print("\n鉁 鍦烘櫙鐢熸垚瀹屾瘯锛")
- # 5. 淇濇寔鍦烘櫙杩愯锛堟寜 Ctrl+C 閫鍑哄苟娓呯悊璧勬簮锛
+ # 淇濇寔杩愯
print("\n馃殫 鍦烘櫙宸插惎鍔紒鎸 Ctrl+C 閫鍑哄苟娓呯悊璧勬簮...")
try:
while True:
@@ -39,101 +49,99 @@ def main():
print("\n馃洃 鏀跺埌閫鍑轰俊鍙凤紝寮濮嬫竻鐞嗚祫婧...")
# ------------------------------ 杈呭姪鍑芥暟 ------------------------------
+
def connect_carla_with_retry(town_name, max_retries=3, retry_interval=5):
- """甯﹂噸璇曟満鍒剁殑CARLA杩炴帴鍑芥暟"""
- client = None
- world = None
+ """甯﹂噸璇曟満鍒剁殑 CARLA 杩炴帴鍑芥暟"""
+ global client
for retry in range(max_retries):
try:
client = carla.Client('localhost', 2000)
client.set_timeout(15.0)
- client.load_world(town_name) # 鍔犺浇鎸囧畾鍦板浘
+ client.load_world(town_name)
world = client.get_world()
- print(f"鉁 鎴愬姛杩炴帴CARLA骞跺姞杞藉湴鍥撅細{town_name}")
+ print(f"鉁 鎴愬姛杩炴帴 CARLA 骞跺姞杞藉湴鍥撅細{town_name}")
return client, world
except Exception as e:
error_msg = str(e)
if retry < max_retries - 1:
- print(f"鉂 杩炴帴澶辫触锛坽retry+1}/{max_retries}锛夛細{error_msg}")
+ print(f"鉂 杩炴帴澶辫触锛坽retry + 1}/{max_retries}锛夛細{error_msg}")
print(f"鈱 {retry_interval}绉掑悗閲嶈瘯...")
time.sleep(retry_interval)
else:
print(f"鉂 杩炴帴澶辫触锛堝凡杈炬渶澶ч噸璇曟鏁帮級锛歿error_msg}")
- print("馃挕 璇锋鏌ワ細1. CARLA鏈嶅姟鍣ㄦ槸鍚﹀惎鍔 2. 绔彛鏄惁涓2000 3. 鍦板浘鍚嶇О鏄惁姝g‘")
+ print("馃挕 璇锋鏌ワ細1. CARLA 鏈嶅姟鍣ㄦ槸鍚﹀惎鍔 2. 绔彛鏄惁涓 2000")
return None, None
+# --- 鏂板鍑芥暟锛氶厤缃ぉ姘斿拰鏃堕棿 ---
def configure_weather_and_time(world, weather_type, time_of_day):
- """閰嶇疆CARLA鐨勫ぉ姘斿拰鏃舵锛堢粏鍖栦笉鍚屽ぉ姘-鏃舵鐨勭幆澧冨弬鏁帮級"""
- # 鍒濆鍖栧ぉ姘斿弬鏁
+ """閰嶇疆 CARLA 鐨勫ぉ姘斿拰鏃舵"""
weather = carla.WeatherParameters()
- # 閰嶇疆澶╂皵绫诲瀷
if weather_type == 'clear':
- weather.cloudiness = 0.0
- weather.precipitation = 0.0
+ weather.cloudiness = 0; weather.precipitation = 0
elif weather_type == 'rainy':
- weather.cloudiness = 80.0
- weather.precipitation = 50.0
- weather.precipitation_deposits = 30.0
- weather.wind_intensity = 10.0 # 闆ㄥぉ澧炲姞椋庡姏
+ weather.cloudiness = 80; weather.precipitation = 50; weather.precipitation_deposits = 30; weather.wind_intensity = 10; weather.fog_density = 0.3
elif weather_type == 'cloudy':
- weather.cloudiness = 70.0
- weather.precipitation = 0.0
- weather.fog_density = 0.2 # 闃村ぉ澧炲姞闆炬皵
-
- # 閰嶇疆鏃舵锛堥氳繃澶槼楂樺害瑙掋佺幆澧冨厜绛夊弬鏁帮級
+ weather.cloudiness = 70; weather.precipitation = 0; weather.fog_density = 0.2
+
if time_of_day == 'noon':
- weather.sun_altitude_angle = 90.0 # 姝e崍澶槼楂樺害瑙
- weather.ambient_light = 1.0
- weather.directional_light_intensity = 2.0
+ weather.sun_altitude_angle = 90; weather.ambient_light = 1.0
elif time_of_day == 'sunset':
- weather.sun_altitude_angle = -15.0 # 鏃ヨ惤澶槼楂樺害瑙掞紙鍦板钩绾夸互涓嬶級
- weather.ambient_light = 0.3
- weather.directional_light_intensity = 0.5
- weather.fog_density = 0.1 # 鏃ヨ惤闆炬皵
+ weather.sun_altitude_angle = -15; weather.ambient_light = 0.3
elif time_of_day == 'night':
- weather.sun_altitude_angle = -60.0 # 澶滈棿澶槼楂樺害瑙
- weather.ambient_light = 0.05
- weather.directional_light_intensity = 0.01
- weather.moon_altitude_angle = 45.0 # 鏈堜寒楂樺害瑙
- weather.moon_intensity = 0.8 # 鏈堜寒浜害
- weather.stars_intensity = 0.5 # 鏄熸槦浜害
+ weather.sun_altitude_angle = -60; weather.ambient_light = 0.05; weather.moon_altitude_angle = 45; weather.moon_intensity = 0.8
- # 搴旂敤澶╂皵璁剧疆
world.set_weather(weather)
print(f"鉁 宸查厤缃幆澧冿細澶╂皵={weather_type}锛屾椂娈={time_of_day}")
-def generate_intersection_scene(world, intersection_type):
- """鍩轰簬璺彛绫诲瀷鐢熸垚鍩虹鍦烘櫙锛堝彲鍚庣画鎵╁睍锛"""
- print(f"馃搶 寮濮嬬敓鎴恵intersection_type}璺彛鍦烘櫙...")
-
- example_spawn_point = get_example_spawn_point(world)
- if example_spawn_point:
- # 绀轰緥锛氱敓鎴1杈嗘祴璇曡溅杈
- vehicle_bp = world.get_blueprint_library().find('vehicle.tesla.model3')
- vehicle = world.spawn_actor(vehicle_bp, example_spawn_point)
- generated_actors.append(vehicle)
- print(f"鉁 宸插湪璺彛闄勮繎鐢熸垚娴嬭瘯杞﹁締锛圛D锛歿vehicle.id}锛")
- else:
- print("鈿狅笍 鏈壘鍒板悎閫傜殑杞﹁締鐢熸垚鐐癸紝璺彛鍦烘櫙鐢熸垚澶辫触")
+def generate_vehicles(world, num_vehicles):
+ """鐢熸垚鎸囧畾鏁伴噺鐨勮溅杈嗗苟寮鍚嚜鍔ㄩ┚椹 (CARLA 0.9.14 鍏煎)"""
+ if num_vehicles <= 0:
+ print("鈩癸笍 杞﹁締鏁伴噺涓 0锛屼笉鐢熸垚杞﹁締銆")
+ return
-def get_example_spawn_point(world):
- """鑾峰彇绀轰緥鐢熸垚鐐"""
spawn_points = world.get_map().get_spawn_points()
- return spawn_points[2] if len(spawn_points) > 2 else None
+ if not spawn_points:
+ print("鈿狅笍 鏈壘鍒拌溅杈嗙敓鎴愮偣銆")
+ return
+
+ vehicle_bps = world.get_blueprint_library().filter('vehicle.*')
+ tm = client.get_trafficmanager(8000)
+ tm.set_global_distance_to_leading_vehicle(2.5)
+
+ print(f"馃殫 姝e湪鐢熸垚 {num_vehicles} 杈嗚溅杈...")
+ for i in range(num_vehicles):
+ spawn_point = random.choice(spawn_points)
+ vehicle_bp = random.choice(vehicle_bps)
+
+ # 閫氳繃钃濆浘璁剧疆鏈澶ч熷害 (CARLA 0.9.14 鍏煎鏂瑰紡)
+ try:
+ max_speed_kmh = random.uniform(25, 35)
+ vehicle_bp.set_attribute('speed', str(max_speed_kmh / 3.6))
+ except Exception:
+ pass # 蹇界暐涓嶆敮鎸佹灞炴х殑杞﹁締
+
+ vehicle = world.try_spawn_actor(vehicle_bp, spawn_point)
+ if vehicle:
+ generated_actors.append(vehicle)
+ vehicle.set_autopilot(True, tm.get_port())
+
+ num_generated = len([a for a in generated_actors if a.type_id.startswith('vehicle')])
+ print(f"鉁 鎴愬姛鐢熸垚 {num_generated} 杈嗚溅杈嗐")
def clean_up_actors():
- """閫鍑烘椂娓呯悊鎵鏈夌敓鎴愮殑Actor"""
+ """閫鍑烘椂娓呯悊鎵鏈夌敓鎴愮殑 Actor"""
+ global client
if generated_actors:
- print(f"馃Ч 姝e湪娓呯悊 {len(generated_actors)} 涓豢鐪熷璞...")
- for actor in generated_actors:
- if actor.is_alive:
- actor.destroy()
+ print(f"\n馃Ч 姝e湪娓呯悊 {len(generated_actors)} 涓豢鐪熷璞...")
+ batch = [carla.command.DestroyActor(x) for x in generated_actors]
+ if client:
+ client.apply_batch(batch)
+ generated_actors.clear()
print("鉁 璧勬簮娓呯悊瀹屾垚锛")
else:
- print("鉁 鏃犻渶瑕佹竻鐞嗙殑浠跨湡瀵硅薄")
+ print("\n鉁 鏃犻渶瑕佹竻鐞嗙殑浠跨湡瀵硅薄銆")
-# 娉ㄥ唽閫鍑哄洖璋冿細绋嬪簭缁堟鏃惰嚜鍔ㄦ竻鐞嗚祫婧
atexit.register(clean_up_actors)
if __name__ == "__main__":
From ac1fb5837d4ba611c020c150127c532ed36714e6 Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Mon, 24 Nov 2025 11:38:11 +0800
Subject: [PATCH 22/32] =?UTF-8?q?=E6=9B=B4=E6=96=B0README.md=E5=92=8CComma?=
=?UTF-8?q?nds=E6=96=87=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/InterconVis_PedSafety_Enh/README.md | 124 +++++++-----------
.../Terminal_Commands.md | 31 ++---
2 files changed, 64 insertions(+), 91 deletions(-)
diff --git a/src/InterconVis_PedSafety_Enh/README.md b/src/InterconVis_PedSafety_Enh/README.md
index afbc3105da..c4cbc54a47 100644
--- a/src/InterconVis_PedSafety_Enh/README.md
+++ b/src/InterconVis_PedSafety_Enh/README.md
@@ -1,113 +1,85 @@
-# CVIPS: Connected Vision for Increased Pedestrian Safety
-Implementation of the CVIPS project.
-- [X] Dataset
-- [X] CARLA data generation code
+#CVIPS: 闈㈠悜鎻愬崌琛屼汉瀹夊叏鐨勫崗鍚岃瑙 (Connected Vision for Increased Pedestrian Safety)
+CVIPS 椤圭洰鐨勫疄鐜般
+- [X] 鏁版嵁闆
+- [X] CARLA 鏁版嵁鐢熸垚浠g爜
-## Dataset
-The CVIPS dataset is available [here](https://drive.google.com/drive/folders/1gCCrIslzVkupyF0lj_1I9qXTB2_a4tjd?usp=drive_link).
+## 鏁版嵁闆 (Dataset)
+CVIPS 鏁版嵁闆嗗彲鍦ㄦ澶勮幏鍙:[here](https://drive.google.com/drive/folders/1gCCrIslzVkupyF0lj_1I9qXTB2_a4tjd?usp=drive_link).
-## Installation
-Please check [installation](https://carla.readthedocs.io/en/0.9.14/build_windows) on how to setup CARLA for windows
+## 瀹夎 (Installation)
+璇峰弬鑰 [installation](https://carla.readthedocs.io/en/0.9.14/build_windows) 浜嗚В濡備綍鍦 Windows 涓婅缃 CARLA銆
+## 鏁版嵁闆嗙敓鎴 (Dataset Generation)
+鎴戜滑鐨勬暟鎹泦鏄娇鐢 CARLA 妯℃嫙鍣ㄧ敓鎴愮殑锛屼负鍗忓悓鎰熺煡鎻愪緵浜嗗鏍峰寲鐨勫満鏅
+###杩愯鏁版嵁鐢熸垚鑴氭湰 (Running the Data Generation Script)
-## Dataset Generation
-Our dataset is generated using the CARLA simulator, providing diverse scenarios for collaborative perception.
-
-### Running the Data Generation Script
-
-1. Clone the repository:
+1. 鍏嬮殕姝や粨搴
```
git clone https://github.com/cvips/CVIPS.git
cd CVIPS
```
-2. Install the required dependencies:
+2. 瀹夎鎵闇鐨勪緷璧栧寘:
```
pip install -r requirements.txt
```
-3. Ensure CARLA is properly installed and running. Start the CARLA server in a separate terminal:
+3. 纭繚 CARLA 宸叉纭畨瑁呭苟杩愯銆傚湪涓涓崟鐙殑缁堢涓惎鍔 CARLA 鏈嶅姟鍣:
```
/path/to/carla/CarlaUE4.exe
```
-4. Run the data generation script:
+4. 杩愯鏁版嵁鐢熸垚鑴氭湰:
```
python cvips_generation.py
```
- This script will connect to the CARLA server and generate the dataset based on the specified parameters.
-
-Note: Make sure to adjust the CARLA server path and any configuration parameters in `cvips_generation.py` as needed for your specific setup.
-
+ 璇ヨ剼鏈皢杩炴帴鍒 CARLA 鏈嶅姟鍣紝骞舵牴鎹寚瀹氱殑鍙傛暟鐢熸垚鏁版嵁闆嗐
+娉ㄦ剰锛氳鏍规嵁浣犵壒瀹氱殑璁剧疆闇姹傦紝璋冩暣 cvips_generation.py 涓殑 CARLA 鏈嶅姟鍣ㄨ矾寰勪互鍙婁换浣曢厤缃弬鏁般
### Sample Examples
-Here are some example commands to generate different scenarios:
-
-1. Four-way intersection in Town10HD with clear weather at noon:
- ```
- python cvips_generation.py --town Town10HD --intersection 4way --setup wsee --weather clear --time_of_the_day noon --crowd_level medium --crossing_percentage 0.1 --seed_value 23 --scenario scenario00001
- ```
-
-2. Four-way intersection in Town04 with rainy weather at sunset:
- ```
- python cvips_generation.py --town Town04 --intersection 4way --setup wwss --weather rainy --time_of_the_day sunset --crowd_level medium --crossing_percentage 0.1 --seed_value 42 --scenario scenario00002
- ```
-
-3. Three-way intersection in Town05 with clear weather at night:
- ```
- python cvips_generation.py --town Town05 --intersection 3way --setup wwss --weather clear --time_of_the_day night --crowd_level medium --crossing_percentage 0.1 --seed_value 73 --scenario scenario00005
- ```
-
-4. Four-way intersection in Town10HD with cloudy weather at noon:
- ```
- python cvips_generation.py --town Town10HD --intersection 4way --setup wwws --weather cloudy --time_of_the_day noon --crowd_level medium --crossing_percentage 0.1 --seed_value 101 --scenario scenario00011
- ```
-
-These examples demonstrate various combinations of towns, intersection types, weather conditions, times of day, and camera setups. Users can modify these parameters to generate different scenarios as needed.
-
-### Sample Visualizations
-
-We provide visualizations to demonstrate different perspectives in our dataset:
-(this can be done using [Code/data_viz.py](Code\data_viz.py))
-1. **Infrastructure View** (6 cameras)
-
- This visualization shows the scene from fixed infrastructure cameras, providing a comprehensive view of the intersection from multiple angles.
-
-2. **Vehicle View** (6 cameras)
-
- This visualization demonstrates the perspective from a moving vehicle, showcasing the view from various angles around the vehicle.
-
-3. **Collaborative View** (4 cameras)
-
- This visualization combines views from both vehicles and infrastructure, illustrating the collaborative perception aspect of our dataset.
-
-
-- Multiple camera perspectives (infrastructure, vehicle-mounted, and collaborative)
-- Various weather conditions and times of day ()
-- Diverse traffic scenarios with multiple vehicles and pedestrians setup (controlled by seeds, number of pedestrians, number of vehicles to be spawned)
-
+#绀轰緥鍛戒护 (Sample Examples)
+# 1. 榛樿閰嶇疆锛氬湪 Town04 鐢熸垚 10 杈嗚溅杈嗭紝澶╂皵涓烘櫞澶╋紝鏃堕棿涓轰腑鍗
+```shell
+python generate_vehicles_only.py --town Town04
+```
+# 2. 鑷畾涔夎溅杈嗘暟閲忥細鍦 Town04 鐢熸垚 15 杈嗚溅杈
+```shell
+python generate_vehicles_only.py --town Town04 --num_vehicles 15
+```
+# 3. 鑷畾涔夊ぉ姘旓細鍦 Town04 鐢熸垚 10 杈嗚溅杈嗭紝澶╂皵涓洪洦澶
+```shell
+python generate_vehicles_only.py --town Town04 --weather rainy
+```
+# 4. 鑷畾涔夋椂闂达細鍦 Town04 鐢熸垚 10 杈嗚溅杈嗭紝鏃堕棿涓哄鏅
+```shell
+python generate_vehicles_only.py --town Town04 --time_of_day night
+```
+# 5. 瀹屾暣鑷畾涔夛細鍦 Town07 鐢熸垚 20 杈嗚溅杈嗭紝澶╂皵涓哄浜戯紝鏃堕棿涓烘棩钀
+```shell
+python generate_vehicles_only.py --town Town07 --num_vehicles 20 --weather cloudy --time_of_day sunset
+```
+# 6. 璁剧疆闅忔満绉嶅瓙锛堜繚璇佸満鏅彲澶嶇幇锛夛細鍦 Town10HD 鐢熸垚 12 杈嗚溅杈嗭紝浣跨敤绉嶅瓙 123
+```shell
+python generate_vehicles_only.py --town Town10HD --num_vehicles 12 --seed 123
+```
+杩欎簺绀轰緥灞曠ず浜嗗煄闀囥佷氦鍙夎矾鍙g被鍨嬨佸ぉ姘旂姸鍐点佹椂闂存锛岃溅杈嗗拰鎽勫儚澶磋缃殑鍚勭缁勫悎銆傜敤鎴峰彲浠ユ牴鎹渶瑕佷慨鏀硅繖浜涘弬鏁颁互鐢熸垚涓嶅悓鐨勫満鏅
-## For Detection in collaborative setup check the documentation of V2XFormer
-First, prepare the dataset with this format [data_preparation](docs/data_preparation.md) .
-Then, use [V2XFormer](https://github.com/tianqi-wang1996/DeepAccident) according to the instructions here
-1. [Installation](https://github.com/tianqi-wang1996/DeepAccident/blob/main/docs/installation.md)
-2. [Training and Evaluation](https://github.com/tianqi-wang1996/DeepAccident/blob/main/docs/getting_started.md) -- adjust the datapaths and number of classes accordingly
-
-## Acknowledgement
-This project is based on the following open-source projects: [BEVerse](https://github.com/zhangyp15/BEVerse), [Fiery](https://github.com/wayveai/fiery), [open-mmlab](https://github.com/open-mmlab), and [DeepAccident](https://arxiv.org/pdf/2304.01168).
+### 鏍锋湰鍙鍖 (Sample Visualizations)
-## Citation
+鎴戜滑鎻愪緵浜嗗彲瑙嗗寲缁撴灉鏉ュ睍绀烘垜浠暟鎹泦涓殑涓嶅悓瑙嗚:
+
+## 鑷磋阿 (Acknowledgement)
+鏈」鐩熀浜庝互涓嬪紑婧愰」鐩: BEVerse, Fiery, open-mmlab, 浠ュ強 DeepAccident銆
-```
diff --git a/src/InterconVis_PedSafety_Enh/Terminal_Commands.md b/src/InterconVis_PedSafety_Enh/Terminal_Commands.md
index 0908add989..58ca64a9ba 100644
--- a/src/InterconVis_PedSafety_Enh/Terminal_Commands.md
+++ b/src/InterconVis_PedSafety_Enh/Terminal_Commands.md
@@ -1,23 +1,24 @@
-# 1. 鍩虹鍦烘櫙锛氬悇鍦板浘+璺彛绫诲瀷楠岃瘉
+# 1. 榛樿閰嶇疆锛氬湪 Town04 鐢熸垚 10 杈嗚溅杈嗭紝澶╂皵涓烘櫞澶╋紝鏃堕棿涓轰腑鍗
```shell
-python cvips_generation.py --town Town04 --intersection 4way --weather clear --time_of_day noon
-python cvips_generation.py --town Town10HD --intersection 3way --weather clear --time_of_day sunset
-python cvips_generation.py --town Town07 --intersection 4way --weather cloudy --time_of_day noon
+python generate_vehicles_only.py --town Town04
```
-# 2. 澶╂皵+鏃舵缁勫悎鍦烘櫙锛堣鐩栨墍鏈夌幆澧冪粍鍚堬級
+# 2. 鑷畾涔夎溅杈嗘暟閲忥細鍦 Town04 鐢熸垚 15 杈嗚溅杈
```shell
-python cvips_generation.py --town Town04 --intersection 3way --weather rainy --time_of_day night
-python cvips_generation.py --town Town10HD --intersection 4way --weather cloudy --time_of_day sunset
-python cvips_generation.py --town Town07 --intersection 3way --weather clear --time_of_day night
-python cvips_generation.py --town Town04 --intersection 4way --weather rainy --time_of_day noon
+python generate_vehicles_only.py --town Town04 --num_vehicles 15
```
-# 3. 杈圭晫鍦烘櫙锛堟瀬闄愮幆澧冩祴璇曪級
+# 3. 鑷畾涔夊ぉ姘旓細鍦 Town04 鐢熸垚 10 杈嗚溅杈嗭紝澶╂皵涓洪洦澶
```shell
-python cvips_generation.py --town Town10HD --intersection 4way --weather rainy --time_of_day night
-python cvips_generation.py --town Town07 --intersection 3way --weather cloudy --time_of_day night
+python generate_vehicles_only.py --town Town04 --weather rainy
```
-# 4. 甯哥敤鍦烘櫙蹇嵎鎸囦护
+# 4. 鑷畾涔夋椂闂达細鍦 Town04 鐢熸垚 10 杈嗚溅杈嗭紝鏃堕棿涓哄鏅
```shell
-python cvips_generation.py --town Town04 --intersection 3way --weather clear --time_of_day noon
-python cvips_generation.py --town Town10HD --intersection 4way --weather clear --time_of_day sunset
+python generate_vehicles_only.py --town Town04 --time_of_day night
+```
+# 5. 瀹屾暣鑷畾涔夛細鍦 Town07 鐢熸垚 20 杈嗚溅杈嗭紝澶╂皵涓哄浜戯紝鏃堕棿涓烘棩钀
+```shell
+python generate_vehicles_only.py --town Town07 --num_vehicles 20 --weather cloudy --time_of_day sunset
+```
+# 6. 璁剧疆闅忔満绉嶅瓙锛堜繚璇佸満鏅彲澶嶇幇锛夛細鍦 Town10HD 鐢熸垚 12 杈嗚溅杈嗭紝浣跨敤绉嶅瓙 123
+```shell
+python generate_vehicles_only.py --town Town10HD --num_vehicles 12 --seed 123
```
\ No newline at end of file
From 39588aaff8a3c7570cb23d6440f35cac4fc08c5e Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Wed, 26 Nov 2025 10:24:50 +0800
Subject: [PATCH 23/32] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=A1=8C=E4=BA=BA?=
=?UTF-8?q?=E5=AF=B9=E8=B1=A1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../cvips_generation.py | 100 +++++++++++++-----
1 file changed, 74 insertions(+), 26 deletions(-)
diff --git a/src/InterconVis_PedSafety_Enh/cvips_generation.py b/src/InterconVis_PedSafety_Enh/cvips_generation.py
index df65e44881..fdeb2492b2 100644
--- a/src/InterconVis_PedSafety_Enh/cvips_generation.py
+++ b/src/InterconVis_PedSafety_Enh/cvips_generation.py
@@ -12,35 +12,31 @@
def main():
global client, world
- parser = argparse.ArgumentParser(description='CARLA 0.9.14 杞﹁締鐢熸垚宸ュ叿 (鏀寔鐜閰嶇疆)')
- parser.add_argument('--town', type=str, required=True, help='鍩庨晣鍦板浘 (渚嬪: Town04)')
- parser.add_argument('--num_vehicles', type=int, default=10, help='鐢熸垚杞﹁締鏁伴噺')
+ parser = argparse.ArgumentParser(description='CARLA 0.9.14 杞﹁締鍜岃浜虹敓鎴愬伐鍏 (浼樺寲瑙傛祴鐗)')
+ parser.add_argument('--town', type=str, default='Town01', help='鍩庨晣鍦板浘 (渚嬪: Town01, Town04)')
+ parser.add_argument('--num_vehicles', type=int, default=20, help='鐢熸垚杞﹁締鏁伴噺')
+ parser.add_argument('--num_pedestrians', type=int, default=100, help='鐢熸垚琛屼汉鏁伴噺')
parser.add_argument('--seed', type=int, default=None, help='闅忔満绉嶅瓙')
- # 鏂板鐜鍙傛暟
parser.add_argument('--weather', type=str, default='clear', choices=['clear', 'rainy', 'cloudy'], help='澶╂皵绫诲瀷')
parser.add_argument('--time_of_day', type=str, default='noon', choices=['noon', 'sunset', 'night'], help='鏃舵')
args = parser.parse_args()
- # 璁剧疆闅忔満绉嶅瓙
if args.seed is not None:
random.seed(args.seed)
print(f"鉁 宸茶缃殢鏈虹瀛: {args.seed}")
- # 杩炴帴 CARLA
client, world = connect_carla_with_retry(args.town)
if not world:
return
- # --- 鏂板浠g爜锛氶厤缃ぉ姘斿拰鏃堕棿 ---
print("\n馃尋锔 姝e湪閰嶇疆鐜...")
configure_weather_and_time(world, args.weather, args.time_of_day)
- # 鐢熸垚杞﹁締
print("\n馃搶 寮濮嬬敓鎴愬満鏅...")
generate_vehicles(world, args.num_vehicles)
+ generate_pedestrians(world, args.num_pedestrians)
print("\n鉁 鍦烘櫙鐢熸垚瀹屾瘯锛")
- # 淇濇寔杩愯
print("\n馃殫 鍦烘櫙宸插惎鍔紒鎸 Ctrl+C 閫鍑哄苟娓呯悊璧勬簮...")
try:
while True:
@@ -49,9 +45,7 @@ def main():
print("\n馃洃 鏀跺埌閫鍑轰俊鍙凤紝寮濮嬫竻鐞嗚祫婧...")
# ------------------------------ 杈呭姪鍑芥暟 ------------------------------
-
def connect_carla_with_retry(town_name, max_retries=3, retry_interval=5):
- """甯﹂噸璇曟満鍒剁殑 CARLA 杩炴帴鍑芥暟"""
global client
for retry in range(max_retries):
try:
@@ -72,11 +66,8 @@ def connect_carla_with_retry(town_name, max_retries=3, retry_interval=5):
print("馃挕 璇锋鏌ワ細1. CARLA 鏈嶅姟鍣ㄦ槸鍚﹀惎鍔 2. 绔彛鏄惁涓 2000")
return None, None
-# --- 鏂板鍑芥暟锛氶厤缃ぉ姘斿拰鏃堕棿 ---
def configure_weather_and_time(world, weather_type, time_of_day):
- """閰嶇疆 CARLA 鐨勫ぉ姘斿拰鏃舵"""
weather = carla.WeatherParameters()
-
if weather_type == 'clear':
weather.cloudiness = 0; weather.precipitation = 0
elif weather_type == 'rainy':
@@ -95,7 +86,6 @@ def configure_weather_and_time(world, weather_type, time_of_day):
print(f"鉁 宸查厤缃幆澧冿細澶╂皵={weather_type}锛屾椂娈={time_of_day}")
def generate_vehicles(world, num_vehicles):
- """鐢熸垚鎸囧畾鏁伴噺鐨勮溅杈嗗苟寮鍚嚜鍔ㄩ┚椹 (CARLA 0.9.14 鍏煎)"""
if num_vehicles <= 0:
print("鈩癸笍 杞﹁締鏁伴噺涓 0锛屼笉鐢熸垚杞﹁締銆")
return
@@ -113,14 +103,11 @@ def generate_vehicles(world, num_vehicles):
for i in range(num_vehicles):
spawn_point = random.choice(spawn_points)
vehicle_bp = random.choice(vehicle_bps)
-
- # 閫氳繃钃濆浘璁剧疆鏈澶ч熷害 (CARLA 0.9.14 鍏煎鏂瑰紡)
try:
- max_speed_kmh = random.uniform(25, 35)
+ max_speed_kmh = random.uniform(20, 30)
vehicle_bp.set_attribute('speed', str(max_speed_kmh / 3.6))
except Exception:
- pass # 蹇界暐涓嶆敮鎸佹灞炴х殑杞﹁締
-
+ pass
vehicle = world.try_spawn_actor(vehicle_bp, spawn_point)
if vehicle:
generated_actors.append(vehicle)
@@ -129,16 +116,77 @@ def generate_vehicles(world, num_vehicles):
num_generated = len([a for a in generated_actors if a.type_id.startswith('vehicle')])
print(f"鉁 鎴愬姛鐢熸垚 {num_generated} 杈嗚溅杈嗐")
+def generate_pedestrians(world, num_pedestrians):
+ """鐢熸垚鎸囧畾鏁伴噺鐨勮浜哄苟璁╀粬浠殢鏈鸿璧 (浼樺寲瑙傛祴鐗)"""
+ if num_pedestrians <= 0:
+ print("鈩癸笍 琛屼汉鏁伴噺涓 0锛屼笉鐢熸垚琛屼汉銆")
+ return
+
+ spawn_points = world.get_map().get_spawn_points()
+ if not spawn_points:
+ print("鈿狅笍 鏈壘鍒颁换浣曠敓鎴愮偣锛屾棤娉曠敓鎴愯浜恒")
+ return
+
+ pedestrian_bps = world.get_blueprint_library().filter('*walker*')
+ pedestrian_bps = [bp for bp in pedestrian_bps if bp.id.startswith('walker.pedestrian')]
+ if not pedestrian_bps:
+ print("鉂 鏈壘鍒拌浜鸿摑鍥撅紒璇锋鏌 CARLA 璧勪骇鏄惁瀹屾暣銆")
+ return
+
+ controller_bp = world.get_blueprint_library().find('controller.ai.walker')
+ print(f"馃懁 姝e湪鐢熸垚 {num_pedestrians} 涓浜... (浼樺寲鍒嗘暎搴)")
+
+ success_count = 0
+ for i in range(num_pedestrians):
+ retry_count = 5
+ while retry_count > 0:
+ spawn_point = random.choice(spawn_points)
+
+ # --- 鏍稿績浼樺寲锛氬鍔犻殢鏈哄亸绉伙紝璁╄浜哄垎甯冩洿鍒嗘暎 ---
+ spawn_point.location.x += random.uniform(-8.0, 8.0)
+ spawn_point.location.y += random.uniform(-8.0, 8.0)
+ spawn_point.location.z += 0.5
+
+ try:
+ pedestrian_bp = random.choice(pedestrian_bps)
+ pedestrian = world.spawn_actor(pedestrian_bp, spawn_point)
+ if pedestrian:
+ generated_actors.append(pedestrian)
+ controller = world.spawn_actor(controller_bp, carla.Transform(), pedestrian)
+ generated_actors.append(controller)
+
+ # --- 琛屼负浼樺寲 ---
+ controller.start()
+ controller.go_to_location(world.get_random_location_from_navigation())
+ controller.set_max_speed(random.uniform(0.5, 1.5)) # 鏇磋嚜鐒剁殑閫熷害鑼冨洿
+
+ success_count += 1
+ break
+ except RuntimeError:
+ retry_count -= 1
+ if retry_count == 0:
+ # 鍑忓皯澶辫触鎻愮ず锛岄伩鍏嶅埛灞
+ if i % 20 == 0:
+ print(f"鈿狅笍 閮ㄥ垎琛屼汉鐢熸垚浣嶇疆琚崰鐢紝宸茶烦杩囥")
+
+ if (i + 1) % 25 == 0:
+ print(f"馃懁 宸茬敓鎴 {success_count}/{i + 1} 涓浜")
+
+ print(f"鉁 鎴愬姛鐢熸垚 {success_count} 涓浜恒")
+
def clean_up_actors():
- """閫鍑烘椂娓呯悊鎵鏈夌敓鎴愮殑 Actor"""
global client
if generated_actors:
print(f"\n馃Ч 姝e湪娓呯悊 {len(generated_actors)} 涓豢鐪熷璞...")
- batch = [carla.command.DestroyActor(x) for x in generated_actors]
- if client:
- client.apply_batch(batch)
- generated_actors.clear()
- print("鉁 璧勬簮娓呯悊瀹屾垚锛")
+ try:
+ batch = [carla.command.DestroyActor(x) for x in generated_actors]
+ if client:
+ client.apply_batch(batch)
+ time.sleep(1)
+ generated_actors.clear()
+ print("鉁 璧勬簮娓呯悊瀹屾垚锛")
+ except Exception as e:
+ print(f"鈿狅笍 娓呯悊璧勬簮鏃跺彂鐢熼敊璇: {e}")
else:
print("\n鉁 鏃犻渶瑕佹竻鐞嗙殑浠跨湡瀵硅薄銆")
From 658433749b94bd6cb963d5fd0a25e39889886d16 Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Wed, 26 Nov 2025 12:24:54 +0800
Subject: [PATCH 24/32] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8C=87=E4=BB=A4?=
=?UTF-8?q?=E8=AF=B4=E6=98=8E?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Terminal_Commands.md | 72 +++++++++++++++----
1 file changed, 60 insertions(+), 12 deletions(-)
diff --git a/src/InterconVis_PedSafety_Enh/Terminal_Commands.md b/src/InterconVis_PedSafety_Enh/Terminal_Commands.md
index 58ca64a9ba..548c3bd435 100644
--- a/src/InterconVis_PedSafety_Enh/Terminal_Commands.md
+++ b/src/InterconVis_PedSafety_Enh/Terminal_Commands.md
@@ -1,24 +1,72 @@
-# 1. 榛樿閰嶇疆锛氬湪 Town04 鐢熸垚 10 杈嗚溅杈嗭紝澶╂皵涓烘櫞澶╋紝鏃堕棿涓轰腑鍗
+## 鍛戒护鏍煎紡
```shell
-python generate_vehicles_only.py --town Town04
+python cvips_generation.py --town <鍩庨晣鍚嶇О> [--num_vehicles < 鏁伴噺 >] [--num_pedestrians < 鏁伴噺 >] [--weather < 澶╂皵绫诲瀷 >] [--time_of_day < 鏃舵 >] [--seed < 绉嶅瓙鍊 >]
```
-# 2. 鑷畾涔夎溅杈嗘暟閲忥細鍦 Town04 鐢熸垚 15 杈嗚溅杈
+## 鍙傛暟璇存槑
+--town: (蹇呭~) CARLA 鍩庨晣鍦板浘鍚嶇О (渚嬪: Town01, Town04)--num_vehicles: (鍙) 鐢熸垚杞﹁締鏁伴噺锛岄粯璁ゅ间负 20--num_pedestrians:(鍙) 鐢熸垚琛屼汉鏁伴噺锛岄粯璁ゅ间负 100--weather: (鍙) 澶╂皵绫诲瀷锛屽彲閫夊: clear (鏅村ぉ), rainy (闆ㄥぉ), cloudy (澶氫簯)锛岄粯璁ゅ间负 clear--time_of_day: (鍙) 鏃舵锛屽彲閫夊: noon (涓崍), sunset (鏃ヨ惤), night (澶滄櫄)锛岄粯璁ゅ间负 noon--seed: (鍙) 闅忔満绉嶅瓙锛岀敤浜庡鐜扮浉鍚屽満鏅
+## 涓銆佸熀纭鍦烘櫙鍛戒护 (鏍稿績鍙傛暟瑕嗙洊)
+### 1. Town01 + 鏅村ぉ + 涓崍 (榛樿閰嶇疆)
```shell
-python generate_vehicles_only.py --town Town04 --num_vehicles 15
+python cvips_generation.py --town Town01
```
-# 3. 鑷畾涔夊ぉ姘旓細鍦 Town04 鐢熸垚 10 杈嗚溅杈嗭紝澶╂皵涓洪洦澶
+### 2. Town01 + 闆ㄥぉ + 澶滄櫄
```shell
-python generate_vehicles_only.py --town Town04 --weather rainy
+python cvips_generation.py --town Town01 --weather rainy --time_of_day night
```
-# 4. 鑷畾涔夋椂闂达細鍦 Town04 鐢熸垚 10 杈嗚溅杈嗭紝鏃堕棿涓哄鏅
+### 3. Town04 + 澶氫簯 + 鏃ヨ惤
```shell
-python generate_vehicles_only.py --town Town04 --time_of_day night
+python cvips_generation.py --town Town04 --weather cloudy --time_of_day sunset
```
-# 5. 瀹屾暣鑷畾涔夛細鍦 Town07 鐢熸垚 20 杈嗚溅杈嗭紝澶╂皵涓哄浜戯紝鏃堕棿涓烘棩钀
+### 4. Town01 + 鏅村ぉ + 澶滄櫄
```shell
-python generate_vehicles_only.py --town Town07 --num_vehicles 20 --weather cloudy --time_of_day sunset
+python cvips_generation.py --town Town01 --time_of_day night
```
-# 6. 璁剧疆闅忔満绉嶅瓙锛堜繚璇佸満鏅彲澶嶇幇锛夛細鍦 Town10HD 鐢熸垚 12 杈嗚溅杈嗭紝浣跨敤绉嶅瓙 123
+### 5. Town04 + 闆ㄥぉ + 涓崍
```shell
-python generate_vehicles_only.py --town Town10HD --num_vehicles 12 --seed 123
+python cvips_generation.py --town Town04 --weather rainy
+```
+## 浜屻佷笉鍚屽瘑搴﹀満鏅懡浠
+### 6. Town01 + 浣庡瘑搴 (10 杈嗚溅锛50 涓浜)
+```shell
+python cvips_generation.py --town Town01 --num_vehicles 10 --num_pedestrians 50
+```
+### 7. Town01 + 涓瘑搴 (25 杈嗚溅锛150 涓浜)
+```shell
+python cvips_generation.py --town Town01 --num_vehicles 25 --num_pedestrians 150
+```
+### 8. Town04 + 楂樺瘑搴 (40 杈嗚溅锛250 涓浜)
+```shell
+python cvips_generation.py --town Town04 --num_vehicles 40 --num_pedestrians 250
+```
+## 涓夈侀殢鏈虹瀛愪笌鍦烘櫙澶嶇幇鍛戒护
+
+### 9. Town01 + 绉嶅瓙 123 (鍙鐜)
+```shell
+python cvips_generation.py --town Town01 --seed 123
+```
+### 10. Town04 + 绉嶅瓙 456 (鍙鐜)
+```shell
+python cvips_generation.py --town Town04 --seed 456
+```
+### 11. Town01 + 闆ㄥぉ澶滄櫄 + 绉嶅瓙 789 (鍙鐜)
+```shell
+python cvips_generation.py --town Town01 --weather rainy --time_of_day night --seed 789
+```
+## 鍥涖佸鍙傛暟缁勫悎鍦烘櫙鍛戒护
+### 12. Town01 + 15 杈嗚溅 + 80 涓浜 + 闆ㄥぉ + 鏃ヨ惤 + 绉嶅瓙 111
+```shell
+python cvips_generation.py --town Town01 --num_vehicles 15 --num_pedestrians 80 --weather rainy --time_of_day sunset --seed 111
+```
+### 13. Town04 + 30 杈嗚溅 + 200 涓浜 + 澶氫簯 + 澶滄櫄 + 绉嶅瓙 222
+```shell
+python cvips_generation.py --town Town04 --num_vehicles 30 --num_pedestrians 200 --weather cloudy --time_of_day night --seed 222
+```
+## 浜斻佽竟缂樺満鏅懡浠 (鏋侀檺鍙傛暟)
+### 14. Town01 + 鏋侀檺楂樺瘑搴 (35 杈嗚溅锛220 涓浜) + 闆ㄥぉ + 澶滄櫄
+```shell
+python cvips_generation.py --town Town01 --num_vehicles 35 --num_pedestrians 220 --weather rainy --time_of_day night
+```
+### 15. Town04 + 鏋侀檺浣庡瘑搴 (5 杈嗚溅锛20 涓浜) + 鏅村ぉ + 涓崍
+```shell
+python cvips_generation.py --town Town04 --num_vehicles 5 --num_pedestrians 20 --weather clear --time_of_day noon
```
\ No newline at end of file
From 8bea41242fac87555633ebf247cbaa29d534bc34 Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Fri, 28 Nov 2025 17:05:38 +0800
Subject: [PATCH 25/32] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=AF=B4=E6=98=8E?=
=?UTF-8?q?=E6=96=87=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/InterconVis_PedSafety_Enh/README.md | 120 +++++++++++-------------
1 file changed, 57 insertions(+), 63 deletions(-)
diff --git a/src/InterconVis_PedSafety_Enh/README.md b/src/InterconVis_PedSafety_Enh/README.md
index c4cbc54a47..5a534a80a2 100644
--- a/src/InterconVis_PedSafety_Enh/README.md
+++ b/src/InterconVis_PedSafety_Enh/README.md
@@ -1,85 +1,79 @@
-#CVIPS: 闈㈠悜鎻愬崌琛屼汉瀹夊叏鐨勫崗鍚岃瑙 (Connected Vision for Increased Pedestrian Safety)
-CVIPS 椤圭洰鐨勫疄鐜般
-- [X] 鏁版嵁闆
-- [X] CARLA 鏁版嵁鐢熸垚浠g爜
-
-
-
-## 鏁版嵁闆 (Dataset)
-CVIPS 鏁版嵁闆嗗彲鍦ㄦ澶勮幏鍙:[here](https://drive.google.com/drive/folders/1gCCrIslzVkupyF0lj_1I9qXTB2_a4tjd?usp=drive_link).
-
-
-
-
-
-## 瀹夎 (Installation)
-璇峰弬鑰 [installation](https://carla.readthedocs.io/en/0.9.14/build_windows) 浜嗚В濡備綍鍦 Windows 涓婅缃 CARLA銆
-
-
+# 椤圭洰绠浠
+CVIPS (Connected Vision for Increased Pedestrian Safety) 鏄竴涓嚧鍔涗簬閫氳繃鍗忓悓瑙嗚鎶鏈紙Connected Vision锛夊拰 V2X锛圴ehicle-to-Everything锛夐氫俊鏉ユ彁鍗囧急鍔块亾璺娇鐢ㄨ咃紙VRU锛岀壒鍒槸琛屼汉锛夊畨鍏ㄧ殑鐮旂┒椤圭洰銆
+鍦ㄥ鏉傜殑鍩庡競浜ら氬満鏅腑锛屽崟杞︽櫤鑳藉線寰鍙楀埌瑙嗙嚎閬尅锛圤cclusion锛夈佹劅鐭ヨ寖鍥村彈闄愬拰鎭跺姡澶╂皵鐨勫奖鍝嶃傛湰椤圭洰鍒╃敤 CARLA 浠跨湡鍣 鏋勫缓楂樹繚鐪熺殑娴嬭瘯鐜锛屾棬鍦ㄧ爺绌讹細
+鍗忓悓鎰熺煡 (Collaborative Perception): 铻嶅悎澶氳鐐癸紙杞﹁締銆佽矾渚у崟鍏 RSU锛変俊鎭
+1. 閬尅澶勭悊: 瑙e喅鈥滈鎺㈠ご鈥濈瓑楂樺嵄鍦烘櫙涓嬬殑琛屼汉妫娴嬮棶棰樸
+2. 鍏ㄥぉ鍊欓瞾妫掓: 鍦ㄩ洦澶┿佸闂寸瓑鏋佺鍏夌収鍜屽ぉ姘斾笅鐨勬劅鐭ユц兘銆
+3. 鏈粨搴撳寘鍚 CVIPS 鐨勬牳蹇冧豢鐪熷満鏅敓鎴愬伐鍏枫佹暟鎹泦閲囬泦鑴氭湰浠ュ強鍗忓悓鎰熺煡绠楁硶瀹炵幇銆
+# 瀹夎涓庝緷璧 (Prerequisites & Installation)
+# 绯荤粺瑕佹眰
+- Ubuntu 20.04 / Windows 10+
+- NVIDIA GPU (鎺ㄨ崘 8GB+ 鏄惧瓨)
+- CARLA Simulator 0.9.14
## 鏁版嵁闆嗙敓鎴 (Dataset Generation)
鎴戜滑鐨勬暟鎹泦鏄娇鐢 CARLA 妯℃嫙鍣ㄧ敓鎴愮殑锛屼负鍗忓悓鎰熺煡鎻愪緵浜嗗鏍峰寲鐨勫満鏅
-###杩愯鏁版嵁鐢熸垚鑴氭湰 (Running the Data Generation Script)
-
+### carla妯℃嫙鍣ㄦ瀯寤
+涓嬭浇浠ヤ笅鐗堟湰鐨刢arla棰勭紪璇戝寘锛堝彲鐩存帴杩愯锛屾棤闇浣跨敤Epic Games Launcher锛
+- [carla0.9.14](https://github.com/carla-simulator/carla/releases/tag/0.9.14)
+### 杩愯鏁版嵁鐢熸垚鑴氭湰 (Running the Data Generation Script)
1. 鍏嬮殕姝や粨搴
- ```
+ ```bash
git clone https://github.com/cvips/CVIPS.git
cd CVIPS
```
-
2. 瀹夎鎵闇鐨勪緷璧栧寘:
- ```
+ ```bash
pip install -r requirements.txt
```
-
3. 纭繚 CARLA 宸叉纭畨瑁呭苟杩愯銆傚湪涓涓崟鐙殑缁堢涓惎鍔 CARLA 鏈嶅姟鍣:
- ```
+ ```bash
/path/to/carla/CarlaUE4.exe
```
-
4. 杩愯鏁版嵁鐢熸垚鑴氭湰:
- ```
+ ```bash
python cvips_generation.py
```
-
- 璇ヨ剼鏈皢杩炴帴鍒 CARLA 鏈嶅姟鍣紝骞舵牴鎹寚瀹氱殑鍙傛暟鐢熸垚鏁版嵁闆嗐
-娉ㄦ剰锛氳鏍规嵁浣犵壒瀹氱殑璁剧疆闇姹傦紝璋冩暣 cvips_generation.py 涓殑 CARLA 鏈嶅姟鍣ㄨ矾寰勪互鍙婁换浣曢厤缃弬鏁般
-### Sample Examples
-
-#绀轰緥鍛戒护 (Sample Examples)
-
-# 1. 榛樿閰嶇疆锛氬湪 Town04 鐢熸垚 10 杈嗚溅杈嗭紝澶╂皵涓烘櫞澶╋紝鏃堕棿涓轰腑鍗
-```shell
-python generate_vehicles_only.py --town Town04
-```
-# 2. 鑷畾涔夎溅杈嗘暟閲忥細鍦 Town04 鐢熸垚 15 杈嗚溅杈
-```shell
-python generate_vehicles_only.py --town Town04 --num_vehicles 15
-```
-# 3. 鑷畾涔夊ぉ姘旓細鍦 Town04 鐢熸垚 10 杈嗚溅杈嗭紝澶╂皵涓洪洦澶
-```shell
-python generate_vehicles_only.py --town Town04 --weather rainy
-```
-# 4. 鑷畾涔夋椂闂达細鍦 Town04 鐢熸垚 10 杈嗚溅杈嗭紝鏃堕棿涓哄鏅
-```shell
-python generate_vehicles_only.py --town Town04 --time_of_day night
-```
-# 5. 瀹屾暣鑷畾涔夛細鍦 Town07 鐢熸垚 20 杈嗚溅杈嗭紝澶╂皵涓哄浜戯紝鏃堕棿涓烘棩钀
-```shell
-python generate_vehicles_only.py --town Town07 --num_vehicles 20 --weather cloudy --time_of_day sunset
-```
-# 6. 璁剧疆闅忔満绉嶅瓙锛堜繚璇佸満鏅彲澶嶇幇锛夛細鍦 Town10HD 鐢熸垚 12 杈嗚溅杈嗭紝浣跨敤绉嶅瓙 123
-```shell
-python generate_vehicles_only.py --town Town10HD --num_vehicles 12 --seed 123
-```
-杩欎簺绀轰緥灞曠ず浜嗗煄闀囥佷氦鍙夎矾鍙g被鍨嬨佸ぉ姘旂姸鍐点佹椂闂存锛岃溅杈嗗拰鎽勫儚澶磋缃殑鍚勭缁勫悎銆傜敤鎴峰彲浠ユ牴鎹渶瑕佷慨鏀硅繖浜涘弬鏁颁互鐢熸垚涓嶅悓鐨勫満鏅
-
+娉細璇ヨ剼鏈皢杩炴帴鍒 CARLA 鏈嶅姟鍣紝骞舵牴鎹寚瀹氱殑鍙傛暟鐢熸垚鏁版嵁闆,闇瑕佸崟鐙垱寤鸿繍琛岃剼鏈 璇锋牴鎹綘鐗瑰畾鐨勮缃渶姹傦紝璋冩暣 cvips_generation.py 涓殑 CARLA 鏈嶅姟鍣ㄨ矾寰勪互鍙婁换浣曢厤缃弬鏁般
+### 閰嶇疆铏氭嫙鐜
+- CARLA 瀵 Python 鐗堟湰锛堟帹鑽 3.7-3.9锛夊拰渚濊禆搴撶増鏈湁涓ユ牸瑕佹眰锛岃櫄鎷熺幆澧冨彲閬垮厤涓庡叾浠栭」鐩殑渚濊禆鍐茬獊
+## 绀轰緥鍙婃牸寮忚鏄
+- 鍛戒护鏍煎紡
+ ```shell
+ python cvips_generation.py --town <鍩庨晣鍚嶇О> [--num_vehicles < 鏁伴噺 >] [--num_pedestrians < 鏁伴噺 >] [--weather < 澶╂皵绫诲瀷 >] [--time_of_day < 鏃舵 >] [--seed < 绉嶅瓙鍊 >]
+## 鍙傛暟璇存槑
+--town: (蹇呭~) CARLA 鍩庨晣鍦板浘鍚嶇О (渚嬪: Town01, Town04)--num_vehicles: (鍙) 鐢熸垚杞﹁締鏁伴噺锛岄粯璁ゅ间负 20--num_pedestrians:(鍙) 鐢熸垚琛屼汉鏁伴噺锛岄粯璁ゅ间负 100--weather: (鍙) 澶╂皵绫诲瀷锛屽彲閫夊: clear (鏅村ぉ), rainy (闆ㄥぉ), cloudy (澶氫簯)锛岄粯璁ゅ间负 clear--time_of_day: (鍙) 鏃舵锛屽彲閫夊: noon (涓崍), sunset (鏃ヨ惤), night (澶滄櫄)锛岄粯璁ゅ间负 noon--seed: (鍙) 闅忔満绉嶅瓙锛岀敤浜庡鐜扮浉鍚屽満鏅
+### 涓銆佸熀纭鍦烘櫙鍛戒护 (鏍稿績鍙傛暟瑕嗙洊)
+1. Town01 + 鏅村ぉ + 涓崍 (榛樿閰嶇疆)
+ ```shell
+ python cvips_generation.py --town Town01
+ ```
+2. Town01 + 闆ㄥぉ + 澶滄櫄
+ ```shell
+ python cvips_generation.py --town Town01 --weather rainy --time_of_day night
+ ```
+### 浜屻佷笉鍚屽瘑搴﹀満鏅懡浠
+1. Town01 + 浣庡瘑搴 (10 杈嗚溅锛50 涓浜)
+ ```shell
+ python cvips_generation.py --town Town01 --num_vehicles 10 --num_pedestrians 50
+2. Town01 + 涓瘑搴 (25 杈嗚溅锛150 涓浜)
+ ```shell
+ python cvips_generation.py --town Town01 --num_vehicles 25 --num_pedestrians 150
+### 涓夈侀殢鏈虹瀛愪笌鍦烘櫙澶嶇幇鍛戒护
+
+1. Town01 + 绉嶅瓙 123 (鍙鐜)
+ ```shell
+ python cvips_generation.py --town Town01 --seed 123
+2. Town04 + 绉嶅瓙 456 (鍙鐜)
+ ```shell
+ python cvips_generation.py --town Town04 --seed 456
+### 鍥涖佸鍙傛暟缁勫悎鍦烘櫙鍛戒护
+1. Town01 + 15 杈嗚溅 + 80 涓浜 + 闆ㄥぉ + 鏃ヨ惤 + 绉嶅瓙 111
+ ```shell
+ python cvips_generation.py --town Town01 --num_vehicles 15 --num_pedestrians 80 --weather rainy --time_of_day sunset --seed 111
### 鏍锋湰鍙鍖 (Sample Visualizations)
鎴戜滑鎻愪緵浜嗗彲瑙嗗寲缁撴灉鏉ュ睍绀烘垜浠暟鎹泦涓殑涓嶅悓瑙嗚:
-
-
-
## 鑷磋阿 (Acknowledgement)
鏈」鐩熀浜庝互涓嬪紑婧愰」鐩: BEVerse, Fiery, open-mmlab, 浠ュ強 DeepAccident銆
From bffe0e45b0fc4d7af925a9266c4f362b9014ba07 Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Fri, 28 Nov 2025 23:50:00 +0800
Subject: [PATCH 26/32] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=91=BD=E4=BB=A4?=
=?UTF-8?q?=E8=AF=B4=E6=98=8E=E6=96=87=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/InterconVis_PedSafety_Enh/Terminal_Commands.md | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/InterconVis_PedSafety_Enh/Terminal_Commands.md b/src/InterconVis_PedSafety_Enh/Terminal_Commands.md
index 548c3bd435..d71dbeb60a 100644
--- a/src/InterconVis_PedSafety_Enh/Terminal_Commands.md
+++ b/src/InterconVis_PedSafety_Enh/Terminal_Commands.md
@@ -3,7 +3,14 @@
python cvips_generation.py --town <鍩庨晣鍚嶇О> [--num_vehicles < 鏁伴噺 >] [--num_pedestrians < 鏁伴噺 >] [--weather < 澶╂皵绫诲瀷 >] [--time_of_day < 鏃舵 >] [--seed < 绉嶅瓙鍊 >]
```
## 鍙傛暟璇存槑
---town: (蹇呭~) CARLA 鍩庨晣鍦板浘鍚嶇О (渚嬪: Town01, Town04)--num_vehicles: (鍙) 鐢熸垚杞﹁締鏁伴噺锛岄粯璁ゅ间负 20--num_pedestrians:(鍙) 鐢熸垚琛屼汉鏁伴噺锛岄粯璁ゅ间负 100--weather: (鍙) 澶╂皵绫诲瀷锛屽彲閫夊: clear (鏅村ぉ), rainy (闆ㄥぉ), cloudy (澶氫簯)锛岄粯璁ゅ间负 clear--time_of_day: (鍙) 鏃舵锛屽彲閫夊: noon (涓崍), sunset (鏃ヨ惤), night (澶滄櫄)锛岄粯璁ゅ间负 noon--seed: (鍙) 闅忔満绉嶅瓙锛岀敤浜庡鐜扮浉鍚屽満鏅
+|鍙傛暟鍚峾绫诲瀷|榛樿鍊紎鍙夊紎浣滅敤璇存槑|
+|:---:|:---:|:---:|:---:|:---:|
+|--town|瀛楃涓瞸town01|town01,town04绛墊鎸囧畾瑕佸姞杞界殑CARLA鍦板浘|
+|--num_vehicles|鏁存暟|20|>=0|瑕佺敓鎴愮殑鑷姩椹鹃┒杞﹁締鏁伴噺|
+|--num_pedestrians|鏁存暟|100|>=0|瑕佺敓鎴愮殑鑷富琛岃蛋鐨勮浜烘暟閲弢
+|--seed|鏁存暟|None|浠绘剰鏁存暟|闅忔満绉嶅瓙锛岃缃悗鍙繚璇佹瘡娆¤繍琛屽畬鍏ㄧ浉鍚岀殑鍦烘櫙锛屼究浜庡鐜般倈
+|--weather|瀛楃涓瞸clear|clear锛宺ainy锛宑loudy|璁剧疆澶╂皵锛宺ainy浼氭湁鏄庢樉鐨勯檷闆ㄥ拰鍦伴潰鍙嶅厜鏁堟灉|
+|--time_of_day|瀛楃涓瞸noon|noon锛宻unset锛宯ight|璁剧疆鏃堕棿锛宯ight浼氬垏鎹㈠埌澶滄櫄骞跺紑鍚湀鍏墊
## 涓銆佸熀纭鍦烘櫙鍛戒护 (鏍稿績鍙傛暟瑕嗙洊)
### 1. Town01 + 鏅村ぉ + 涓崍 (榛樿閰嶇疆)
```shell
From c56df2e3f927b85d99608cba5b1f3f21e96afcab Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Sun, 30 Nov 2025 15:26:23 +0800
Subject: [PATCH 27/32] =?UTF-8?q?=E5=AE=8C=E5=96=84=E8=AF=B4=E6=98=8E?=
=?UTF-8?q?=E6=96=87=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/InterconVis_PedSafety_Enh/README.md | 38 +++++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)
diff --git a/src/InterconVis_PedSafety_Enh/README.md b/src/InterconVis_PedSafety_Enh/README.md
index 5a534a80a2..885f38496f 100644
--- a/src/InterconVis_PedSafety_Enh/README.md
+++ b/src/InterconVis_PedSafety_Enh/README.md
@@ -36,12 +36,46 @@ CVIPS (Connected Vision for Increased Pedestrian Safety) 鏄竴涓嚧鍔涗簬閫
娉細璇ヨ剼鏈皢杩炴帴鍒 CARLA 鏈嶅姟鍣紝骞舵牴鎹寚瀹氱殑鍙傛暟鐢熸垚鏁版嵁闆,闇瑕佸崟鐙垱寤鸿繍琛岃剼鏈 璇锋牴鎹綘鐗瑰畾鐨勮缃渶姹傦紝璋冩暣 cvips_generation.py 涓殑 CARLA 鏈嶅姟鍣ㄨ矾寰勪互鍙婁换浣曢厤缃弬鏁般
### 閰嶇疆铏氭嫙鐜
- CARLA 瀵 Python 鐗堟湰锛堟帹鑽 3.7-3.9锛夊拰渚濊禆搴撶増鏈湁涓ユ牸瑕佹眰锛岃櫄鎷熺幆澧冨彲閬垮厤涓庡叾浠栭」鐩殑渚濊禆鍐茬獊
-## 绀轰緥鍙婃牸寮忚鏄
+### 涓嬭浇Anaconda
+- 涓嬭浇 [Anaconda](https://repo.anaconda.com/archive/Anaconda3-2021.05-Windows-x86_64.exe)銆
+- 瀹夎鏃跺嬀閫 鈥淎dd Anaconda to PATH鈥濓紙Windows 闇鎵嬪姩鍕鹃夛紝Linux/Mac 榛樿娣诲姞锛夈
+- 楠岃瘉瀹夎锛氭墦寮缁堢锛岃緭鍏onda --version锛屾樉绀虹増鏈彿鍗虫垚鍔熴
+### 鍒涘缓婵娲昏櫄鎷熺幆澧冿紙浠呴渶鎵ц涓娆★級
+1. 鎵撳紑缁堢锛堟垨 Anaconda Prompt锛夛紝杩愯浠ヤ笅鍛戒护锛
+ ```bash
+ # 鍒涘缓鍚嶄负cvips_env鐨勮櫄鎷熺幆澧冿紙Python3.7閫傞厤CARLA 0.9.14锛
+ conda create -n cvips_env python=3.7
+ ```
+2. 婵娲昏櫄鎷熺幆澧冿紙姣忔杩愯鑴氭湰鍓嶉兘闇鎵ц锛
+ ```bash
+ conda activate cvips_env # Windows
+ ```
+### 鍦ㄨ櫄鎷熺幆澧冧腑瀹夎 CARLA 渚濊禆锛堜粎闇鎵ц涓娆★級
+- 婵娲荤幆澧冨悗锛岀洿鎺ュ畨瑁呭尮閰嶇増鏈殑 CARLA Python API锛
+ ```bash
+ pip install carla==0.9.14
+ ```
+### 浣跨敤璇存槑
+- 婵娲昏櫄鎷熺幆澧冿紙姣忔杩愯鑴氭湰鍓嶉兘闇鎵ц锛
+ ```bash
+ conda activate cvips_env # Windows
+ ```
+- 鎵撳紑 CARLA 0.9.14 妯℃嫙鍣紙CarlaUE4.exe/./CarlaUE4.sh锛夈
+- 杩涘叆 cvips 鏂囦欢澶圭洰褰曪紙cd 浣犵殑cvips璺緞锛
+- 杈撳叆鎯宠杩愯鐨勮剼鏈
+## 浣跨敤绀轰緥鍙婃牸寮忚鏄
- 鍛戒护鏍煎紡
```shell
python cvips_generation.py --town <鍩庨晣鍚嶇О> [--num_vehicles < 鏁伴噺 >] [--num_pedestrians < 鏁伴噺 >] [--weather < 澶╂皵绫诲瀷 >] [--time_of_day < 鏃舵 >] [--seed < 绉嶅瓙鍊 >]
## 鍙傛暟璇存槑
---town: (蹇呭~) CARLA 鍩庨晣鍦板浘鍚嶇О (渚嬪: Town01, Town04)--num_vehicles: (鍙) 鐢熸垚杞﹁締鏁伴噺锛岄粯璁ゅ间负 20--num_pedestrians:(鍙) 鐢熸垚琛屼汉鏁伴噺锛岄粯璁ゅ间负 100--weather: (鍙) 澶╂皵绫诲瀷锛屽彲閫夊: clear (鏅村ぉ), rainy (闆ㄥぉ), cloudy (澶氫簯)锛岄粯璁ゅ间负 clear--time_of_day: (鍙) 鏃舵锛屽彲閫夊: noon (涓崍), sunset (鏃ヨ惤), night (澶滄櫄)锛岄粯璁ゅ间负 noon--seed: (鍙) 闅忔満绉嶅瓙锛岀敤浜庡鐜扮浉鍚屽満鏅
+|鍙傛暟鍚峾绫诲瀷|榛樿鍊紎鍙夊紎浣滅敤璇存槑|
+|:---:|:---:|:---:|:---:|:---:|
+|--town|瀛楃涓瞸town01|town01,town04绛墊鎸囧畾瑕佸姞杞界殑CARLA鍦板浘|
+|--num_vehicles|鏁存暟|20|>=0|瑕佺敓鎴愮殑鑷姩椹鹃┒杞﹁締鏁伴噺|
+|--num_pedestrians|鏁存暟|100|>=0|瑕佺敓鎴愮殑鑷富琛岃蛋鐨勮浜烘暟閲弢
+|--seed|鏁存暟|None|浠绘剰鏁存暟|闅忔満绉嶅瓙锛岃缃悗鍙繚璇佹瘡娆¤繍琛屽畬鍏ㄧ浉鍚岀殑鍦烘櫙锛屼究浜庡鐜般倈
+|--weather|瀛楃涓瞸clear|clear锛宺ainy锛宑loudy|璁剧疆澶╂皵锛宺ainy浼氭湁鏄庢樉鐨勯檷闆ㄥ拰鍦伴潰鍙嶅厜鏁堟灉|
+|--time_of_day|瀛楃涓瞸noon|noon锛宻unset锛宯ight|璁剧疆鏃堕棿锛宯ight浼氬垏鎹㈠埌澶滄櫄骞跺紑鍚湀鍏墊
### 涓銆佸熀纭鍦烘櫙鍛戒护 (鏍稿績鍙傛暟瑕嗙洊)
1. Town01 + 鏅村ぉ + 涓崍 (榛樿閰嶇疆)
```shell
From dc6f4f7066aaff7ac5b120063a94524cb00718a9 Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Sun, 30 Nov 2025 17:16:14 +0800
Subject: [PATCH 28/32] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=84=9A=E6=9C=AC?=
=?UTF-8?q?=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../cvips_generation.py | 372 +++++++++---------
1 file changed, 192 insertions(+), 180 deletions(-)
diff --git a/src/InterconVis_PedSafety_Enh/cvips_generation.py b/src/InterconVis_PedSafety_Enh/cvips_generation.py
index fdeb2492b2..3b5084034d 100644
--- a/src/InterconVis_PedSafety_Enh/cvips_generation.py
+++ b/src/InterconVis_PedSafety_Enh/cvips_generation.py
@@ -1,196 +1,208 @@
import carla
import argparse
import time
-import atexit
import random
+import logging
-# 鍏ㄥ眬鍙橀噺
-generated_actors = []
-client = None
-world = None
+# 閰嶇疆鏃ュ織
+logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
def main():
- global client, world
-
- parser = argparse.ArgumentParser(description='CARLA 0.9.14 杞﹁締鍜岃浜虹敓鎴愬伐鍏 (浼樺寲瑙傛祴鐗)')
- parser.add_argument('--town', type=str, default='Town01', help='鍩庨晣鍦板浘 (渚嬪: Town01, Town04)')
- parser.add_argument('--num_vehicles', type=int, default=20, help='鐢熸垚杞﹁締鏁伴噺')
- parser.add_argument('--num_pedestrians', type=int, default=100, help='鐢熸垚琛屼汉鏁伴噺')
- parser.add_argument('--seed', type=int, default=None, help='闅忔満绉嶅瓙')
- parser.add_argument('--weather', type=str, default='clear', choices=['clear', 'rainy', 'cloudy'], help='澶╂皵绫诲瀷')
- parser.add_argument('--time_of_day', type=str, default='noon', choices=['noon', 'sunset', 'night'], help='鏃舵')
- args = parser.parse_args()
-
- if args.seed is not None:
+ argparser = argparse.ArgumentParser(
+ description=__doc__)
+ argparser.add_argument(
+ '--town', type=str, default='Town01', help='鍩庨晣鍦板浘')
+ argparser.add_argument(
+ '--num_vehicles', default=30, type=int, help='鐢熸垚杞﹁締鏁伴噺')
+ argparser.add_argument(
+ '--num_pedestrians', default=50, type=int, help='鐢熸垚琛屼汉鏁伴噺')
+ argparser.add_argument(
+ '--seed', default=None, type=int, help='闅忔満绉嶅瓙')
+ argparser.add_argument(
+ '--weather', default='clear', choices=['clear', 'rainy', 'cloudy', 'night'], help='澶╂皵棰勮')
+ args = argparser.parse_args()
+
+ if args.seed:
random.seed(args.seed)
- print(f"鉁 宸茶缃殢鏈虹瀛: {args.seed}")
- client, world = connect_carla_with_retry(args.town)
- if not world:
- return
+ client = carla.Client('localhost', 2000)
+ client.set_timeout(20.0)
- print("\n馃尋锔 姝e湪閰嶇疆鐜...")
- configure_weather_and_time(world, args.weather, args.time_of_day)
+ # 鍏ㄥ眬鍒楄〃锛岀敤浜庢竻鐞
+ vehicles_list = []
+ walkers_list = []
+ all_id = []
- print("\n馃搶 寮濮嬬敓鎴愬満鏅...")
- generate_vehicles(world, args.num_vehicles)
- generate_pedestrians(world, args.num_pedestrians)
- print("\n鉁 鍦烘櫙鐢熸垚瀹屾瘯锛")
-
- print("\n馃殫 鍦烘櫙宸插惎鍔紒鎸 Ctrl+C 閫鍑哄苟娓呯悊璧勬簮...")
try:
- while True:
- time.sleep(1)
- except KeyboardInterrupt:
- print("\n馃洃 鏀跺埌閫鍑轰俊鍙凤紝寮濮嬫竻鐞嗚祫婧...")
-
-# ------------------------------ 杈呭姪鍑芥暟 ------------------------------
-def connect_carla_with_retry(town_name, max_retries=3, retry_interval=5):
- global client
- for retry in range(max_retries):
- try:
- client = carla.Client('localhost', 2000)
- client.set_timeout(15.0)
- client.load_world(town_name)
- world = client.get_world()
- print(f"鉁 鎴愬姛杩炴帴 CARLA 骞跺姞杞藉湴鍥撅細{town_name}")
- return client, world
- except Exception as e:
- error_msg = str(e)
- if retry < max_retries - 1:
- print(f"鉂 杩炴帴澶辫触锛坽retry + 1}/{max_retries}锛夛細{error_msg}")
- print(f"鈱 {retry_interval}绉掑悗閲嶈瘯...")
- time.sleep(retry_interval)
- else:
- print(f"鉂 杩炴帴澶辫触锛堝凡杈炬渶澶ч噸璇曟鏁帮級锛歿error_msg}")
- print("馃挕 璇锋鏌ワ細1. CARLA 鏈嶅姟鍣ㄦ槸鍚﹀惎鍔 2. 绔彛鏄惁涓 2000")
- return None, None
-
-def configure_weather_and_time(world, weather_type, time_of_day):
- weather = carla.WeatherParameters()
- if weather_type == 'clear':
- weather.cloudiness = 0; weather.precipitation = 0
- elif weather_type == 'rainy':
- weather.cloudiness = 80; weather.precipitation = 50; weather.precipitation_deposits = 30; weather.wind_intensity = 10; weather.fog_density = 0.3
- elif weather_type == 'cloudy':
- weather.cloudiness = 70; weather.precipitation = 0; weather.fog_density = 0.2
-
- if time_of_day == 'noon':
- weather.sun_altitude_angle = 90; weather.ambient_light = 1.0
- elif time_of_day == 'sunset':
- weather.sun_altitude_angle = -15; weather.ambient_light = 0.3
- elif time_of_day == 'night':
- weather.sun_altitude_angle = -60; weather.ambient_light = 0.05; weather.moon_altitude_angle = 45; weather.moon_intensity = 0.8
-
- world.set_weather(weather)
- print(f"鉁 宸查厤缃幆澧冿細澶╂皵={weather_type}锛屾椂娈={time_of_day}")
-
-def generate_vehicles(world, num_vehicles):
- if num_vehicles <= 0:
- print("鈩癸笍 杞﹁締鏁伴噺涓 0锛屼笉鐢熸垚杞﹁締銆")
- return
-
- spawn_points = world.get_map().get_spawn_points()
- if not spawn_points:
- print("鈿狅笍 鏈壘鍒拌溅杈嗙敓鎴愮偣銆")
- return
-
- vehicle_bps = world.get_blueprint_library().filter('vehicle.*')
- tm = client.get_trafficmanager(8000)
- tm.set_global_distance_to_leading_vehicle(2.5)
-
- print(f"馃殫 姝e湪鐢熸垚 {num_vehicles} 杈嗚溅杈...")
- for i in range(num_vehicles):
- spawn_point = random.choice(spawn_points)
- vehicle_bp = random.choice(vehicle_bps)
- try:
- max_speed_kmh = random.uniform(20, 30)
- vehicle_bp.set_attribute('speed', str(max_speed_kmh / 3.6))
- except Exception:
- pass
- vehicle = world.try_spawn_actor(vehicle_bp, spawn_point)
- if vehicle:
- generated_actors.append(vehicle)
- vehicle.set_autopilot(True, tm.get_port())
-
- num_generated = len([a for a in generated_actors if a.type_id.startswith('vehicle')])
- print(f"鉁 鎴愬姛鐢熸垚 {num_generated} 杈嗚溅杈嗐")
-
-def generate_pedestrians(world, num_pedestrians):
- """鐢熸垚鎸囧畾鏁伴噺鐨勮浜哄苟璁╀粬浠殢鏈鸿璧 (浼樺寲瑙傛祴鐗)"""
- if num_pedestrians <= 0:
- print("鈩癸笍 琛屼汉鏁伴噺涓 0锛屼笉鐢熸垚琛屼汉銆")
- return
-
- spawn_points = world.get_map().get_spawn_points()
- if not spawn_points:
- print("鈿狅笍 鏈壘鍒颁换浣曠敓鎴愮偣锛屾棤娉曠敓鎴愯浜恒")
- return
-
- pedestrian_bps = world.get_blueprint_library().filter('*walker*')
- pedestrian_bps = [bp for bp in pedestrian_bps if bp.id.startswith('walker.pedestrian')]
- if not pedestrian_bps:
- print("鉂 鏈壘鍒拌浜鸿摑鍥撅紒璇锋鏌 CARLA 璧勪骇鏄惁瀹屾暣銆")
- return
-
- controller_bp = world.get_blueprint_library().find('controller.ai.walker')
- print(f"馃懁 姝e湪鐢熸垚 {num_pedestrians} 涓浜... (浼樺寲鍒嗘暎搴)")
-
- success_count = 0
- for i in range(num_pedestrians):
- retry_count = 5
- while retry_count > 0:
- spawn_point = random.choice(spawn_points)
+ # 1. 鍔犺浇鍦板浘
+ print(f"姝e湪鍔犺浇鍦板浘: {args.town}")
+ client.load_world(args.town)
+ world = client.get_world()
+
+ # 2. 璁剧疆鍚屾妯″紡 (淇濊瘉鐗╃悊璁$畻鍑嗙‘锛岄槻姝㈢灛绉)
+ settings = world.get_settings()
+ settings.synchronous_mode = True
+ settings.fixed_delta_seconds = 0.05 # 20 FPS
+ world.apply_settings(settings)
+
+ # 3. 閰嶇疆浜ら氱鐞嗗櫒
+ traffic_manager = client.get_trafficmanager(8000)
+ traffic_manager.set_synchronous_mode(True)
+ traffic_manager.set_global_distance_to_leading_vehicle(2.5)
+ traffic_manager.set_hybrid_physics_mode(True) # 杩滃杞﹁締鍏抽棴鐗╃悊璁$畻
+ traffic_manager.set_respawn_dormant_vehicles(True)
+
+ if args.seed:
+ traffic_manager.set_random_device_seed(args.seed)
+
+ # 4. 璁剧疆鐜
+ configure_weather(world, args.weather)
+
+ # ==============================
+ # 鐢熸垚杞﹁締 (Vehicles)
+ # ==============================
+ blueprint_library = world.get_blueprint_library()
+ vehicle_bps = blueprint_library.filter('vehicle.*')
+ vehicle_bps = [x for x in vehicle_bps if int(x.get_attribute('number_of_wheels')) == 4]
+ vehicle_bps = [x for x in vehicle_bps if not x.id.endswith('microlino')]
+
+ spawn_points = world.get_map().get_spawn_points()
+ number_of_spawn_points = len(spawn_points)
+
+ if args.num_vehicles < number_of_spawn_points:
+ random.shuffle(spawn_points)
+ elif args.num_vehicles > number_of_spawn_points:
+ logging.warning(f"璇锋眰杞﹁締鏁 {args.num_vehicles} 瓒呰繃鐢熸垚鐐规暟閲 {number_of_spawn_points}")
+ args.num_vehicles = number_of_spawn_points
+
+ SpawnActor = carla.command.SpawnActor
+ SetAutopilot = carla.command.SetAutopilot
+ FutureActor = carla.command.FutureActor
+
+ batch = []
+ for n, transform in enumerate(spawn_points):
+ if n >= args.num_vehicles:
+ break
+ bp = random.choice(vehicle_bps)
+ if bp.has_attribute('color'):
+ color = random.choice(bp.get_attribute('color').recommended_values)
+ bp.set_attribute('color', color)
+ if bp.has_attribute('driver_id'):
+ bp.set_attribute('driver_id', random.choice(bp.get_attribute('driver_id').recommended_values))
- # --- 鏍稿績浼樺寲锛氬鍔犻殢鏈哄亸绉伙紝璁╄浜哄垎甯冩洿鍒嗘暎 ---
- spawn_point.location.x += random.uniform(-8.0, 8.0)
- spawn_point.location.y += random.uniform(-8.0, 8.0)
- spawn_point.location.z += 0.5
+ bp.set_attribute('role_name', 'autopilot')
+
+ batch.append(SpawnActor(bp, transform)
+ .then(SetAutopilot(FutureActor, True, traffic_manager.get_port())))
+
+ for response in client.apply_batch_sync(batch, True):
+ if response.error:
+ logging.error(response.error)
+ else:
+ vehicles_list.append(response.actor_id)
+
+ print(f"鉁 宸茬敓鎴 {len(vehicles_list)} 杈嗚溅")
+
+ for actor in world.get_actors(vehicles_list):
+ traffic_manager.vehicle_percentage_speed_difference(actor, random.randint(-10, 10))
+ traffic_manager.ignore_lights_percentage(actor, 0)
+ traffic_manager.ignore_signs_percentage(actor, 0)
+ traffic_manager.auto_lane_change(actor, True)
+
+ # ==============================
+ # 鐢熸垚琛屼汉 (Pedestrians)
+ # ==============================
+ spawn_points = []
+ for i in range(args.num_pedestrians):
+ spawn_point = carla.Transform()
+ loc = world.get_random_location_from_navigation()
+ if (loc != None):
+ spawn_point.location = loc
+ spawn_points.append(spawn_point)
+
+ walker_bp_list = blueprint_library.filter('walker.pedestrian.*')
+ walker_controller_bp = blueprint_library.find('controller.ai.walker')
+
+ batch = []
+ for spawn_point in spawn_points:
+ walker_bp = random.choice(walker_bp_list)
+ if walker_bp.has_attribute('is_invincible'):
+ walker_bp.set_attribute('is_invincible', 'false')
+ batch.append(SpawnActor(walker_bp, spawn_point))
+
+ results = client.apply_batch_sync(batch, True)
+ for i in range(len(results)):
+ if results[i].error:
+ logging.error(results[i].error)
+ else:
+ walkers_list.append({"id": results[i].actor_id})
+
+ batch = []
+ walker_controller_list = []
+ for i in range(len(walkers_list)):
+ batch.append(SpawnActor(walker_controller_bp, carla.Transform(), walkers_list[i]["id"]))
+
+ results = client.apply_batch_sync(batch, True)
+ for i in range(len(results)):
+ if results[i].error:
+ logging.error(results[i].error)
+ else:
+ walkers_list[i]["con"] = results[i].actor_id
+ walker_controller_list.append(results[i].actor_id)
+
+ all_id = vehicles_list + [x['id'] for x in walkers_list] + [x['con'] for x in walkers_list if 'con' in x]
+ print(f"鉁 宸茬敓鎴 {len(walkers_list)} 涓浜")
+
+ world.tick()
+ world.set_pedestrians_cross_factor(0.1)
+
+ for i, controller_id in enumerate(walker_controller_list):
+ controller = world.get_actor(controller_id)
+ controller.start()
+ controller.go_to_location(world.get_random_location_from_navigation())
- try:
- pedestrian_bp = random.choice(pedestrian_bps)
- pedestrian = world.spawn_actor(pedestrian_bp, spawn_point)
- if pedestrian:
- generated_actors.append(pedestrian)
- controller = world.spawn_actor(controller_bp, carla.Transform(), pedestrian)
- generated_actors.append(controller)
-
- # --- 琛屼负浼樺寲 ---
- controller.start()
- controller.go_to_location(world.get_random_location_from_navigation())
- controller.set_max_speed(random.uniform(0.5, 1.5)) # 鏇磋嚜鐒剁殑閫熷害鑼冨洿
-
- success_count += 1
- break
- except RuntimeError:
- retry_count -= 1
- if retry_count == 0:
- # 鍑忓皯澶辫触鎻愮ず锛岄伩鍏嶅埛灞
- if i % 20 == 0:
- print(f"鈿狅笍 閮ㄥ垎琛屼汉鐢熸垚浣嶇疆琚崰鐢紝宸茶烦杩囥")
+ # ============ 淇敼鐐瑰紑濮 ============
+ # 璁剧疆鏇磋嚜鐒剁殑閫熷害: 0.5 ~ 1.3 m/s (绾 1.8 ~ 4.7 km/h)
+ # 涔嬪墠鐨 1.0~1.8 澶揩浜
+ speed = random.uniform(0.5, 1.3)
+ controller.set_max_speed(speed)
+ # ============ 淇敼鐐圭粨鏉 ============
+
+ print("\n馃殌 浠跨湡宸插惎鍔紒鎸 Ctrl+C 鍋滄...")
- if (i + 1) % 25 == 0:
- print(f"馃懁 宸茬敓鎴 {success_count}/{i + 1} 涓浜")
-
- print(f"鉁 鎴愬姛鐢熸垚 {success_count} 涓浜恒")
-
-def clean_up_actors():
- global client
- if generated_actors:
- print(f"\n馃Ч 姝e湪娓呯悊 {len(generated_actors)} 涓豢鐪熷璞...")
- try:
- batch = [carla.command.DestroyActor(x) for x in generated_actors]
- if client:
- client.apply_batch(batch)
- time.sleep(1)
- generated_actors.clear()
- print("鉁 璧勬簮娓呯悊瀹屾垚锛")
- except Exception as e:
- print(f"鈿狅笍 娓呯悊璧勬簮鏃跺彂鐢熼敊璇: {e}")
- else:
- print("\n鉁 鏃犻渶瑕佹竻鐞嗙殑浠跨湡瀵硅薄銆")
-
-atexit.register(clean_up_actors)
-
-if __name__ == "__main__":
+ while True:
+ world.tick()
+
+ except KeyboardInterrupt:
+ print("\n馃洃 姝e湪鍋滄浠跨湡...")
+ finally:
+ print(f"馃Ч 娓呯悊 {len(all_id)} 涓豢鐪熷璞...")
+ for i, controller_id in enumerate(walker_controller_list):
+ try:
+ controller = world.get_actor(controller_id)
+ controller.stop()
+ except:
+ pass
+ client.apply_batch([carla.command.DestroyActor(x) for x in all_id])
+
+ if world:
+ settings = world.get_settings()
+ settings.synchronous_mode = False
+ settings.fixed_delta_seconds = None
+ world.apply_settings(settings)
+
+ print("鉁 娓呯悊瀹屾垚锛岀▼搴忛鍑恒")
+
+def configure_weather(world, weather_type):
+ weather_presets = {
+ 'clear': carla.WeatherParameters.ClearNoon,
+ 'cloudy': carla.WeatherParameters.CloudyNoon,
+ 'rainy': carla.WeatherParameters.HardRainNoon,
+ 'night': carla.WeatherParameters.ClearNight
+ }
+ preset = weather_presets.get(weather_type, carla.WeatherParameters.ClearNoon)
+ world.set_weather(preset)
+ print(f"馃尋锔 澶╂皵璁剧疆涓: {weather_type}")
+
+if __name__ == '__main__':
main()
\ No newline at end of file
From 7954d2ad45a636c1619872b7c689785179d20276 Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Mon, 8 Dec 2025 10:27:58 +0800
Subject: [PATCH 29/32] =?UTF-8?q?=E7=94=9F=E6=88=90=E6=95=B0=E6=8D=AE?=
=?UTF-8?q?=E5=92=8C=E8=BD=A6=E8=BE=86=E8=84=9A=E6=9C=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../cvips_collector.py | 193 ++++++++++++++++++
1 file changed, 193 insertions(+)
create mode 100644 src/InterconVis_PedSafety_Enh/cvips_collector.py
diff --git a/src/InterconVis_PedSafety_Enh/cvips_collector.py b/src/InterconVis_PedSafety_Enh/cvips_collector.py
new file mode 100644
index 0000000000..92f5b0f378
--- /dev/null
+++ b/src/InterconVis_PedSafety_Enh/cvips_collector.py
@@ -0,0 +1,193 @@
+import carla
+import random
+import queue
+import os
+import argparse
+import time
+
+# ================= 閰嶇疆鍖哄煙 =================
+OUTPUT_FOLDER = "_out_cvips_data"
+
+# 銆愰噸瑕併戞敼鎴 True 寮鍚繚瀛樸傚缓璁厛璺戜竴娆 False 纭鐢婚潰姝e父
+ENABLE_SAVING = True
+
+# 姣忛殧鍑犲抚淇濆瓨涓娆★紵(寤鸿 10-20锛屽お灏忎細鍗★紝澶ぇ閿欒繃缁嗚妭)
+SAVE_INTERVAL = 10
+# ===========================================
+
+def main():
+ argparser = argparse.ArgumentParser(description="CVIPS 鏁版嵁閲囬泦鑴氭湰 V4")
+ argparser.add_argument('--town', default='Town01', help='鍦板浘鍚嶇О')
+ argparser.add_argument('--num_vehicles', default=20, type=int, help='鑳屾櫙杞﹁締鏁')
+ argparser.add_argument('--num_walkers', default=30, type=int, help='琛屼汉鏁')
+ args = argparser.parse_args()
+
+ # 鍒涘缓鐩綍
+ if ENABLE_SAVING:
+ os.makedirs(f"{OUTPUT_FOLDER}/ego_rgb", exist_ok=True)
+ os.makedirs(f"{OUTPUT_FOLDER}/rsu_rgb", exist_ok=True)
+ print(f"馃搧 鍥剧墖灏嗕繚瀛樺湪: {os.path.abspath(OUTPUT_FOLDER)}")
+
+ client = carla.Client('localhost', 2000)
+ client.set_timeout(60.0)
+
+ print(f"姝e湪鍔犺浇鍦板浘 {args.town} (鍙兘闇瑕佸嚑绉)...")
+ world = client.load_world(args.town)
+
+ # 璁剧疆鍚屾妯″紡
+ settings = world.get_settings()
+ settings.synchronous_mode = True
+ settings.fixed_delta_seconds = 0.05
+ world.apply_settings(settings)
+
+ traffic_manager = client.get_trafficmanager(8000)
+ traffic_manager.set_synchronous_mode(True)
+
+ # 杩欓噷鐨勯槦鍒楃敤浜庢帴鏀朵紶鎰熷櫒鏁版嵁
+ sensor_queue = queue.Queue()
+ actor_list = []
+
+ try:
+ # --- 1. 鐢熸垚鐜 ---
+ print("姝e湪鏋勫缓鍦烘櫙...")
+ blueprint_library = world.get_blueprint_library()
+ spawn_points = world.get_map().get_spawn_points()
+
+ ego_spawn_point = spawn_points[0]
+ npc_spawn_points = spawn_points[1:]
+
+ # 鐢熸垚鑳屾櫙杞﹁締
+ bg_vehicle_bp = blueprint_library.filter('vehicle.*')[0]
+ for _ in range(args.num_vehicles):
+ t = random.choice(npc_spawn_points)
+ actor = world.try_spawn_actor(bg_vehicle_bp, t)
+ if actor:
+ actor.set_autopilot(True)
+ actor_list.append(actor)
+
+ # 鐢熸垚琛屼汉
+ walker_bp = blueprint_library.filter('walker.pedestrian.*')[0]
+ for _ in range(args.num_walkers):
+ loc = world.get_random_location_from_navigation()
+ if loc:
+ w = world.try_spawn_actor(walker_bp, carla.Transform(loc))
+ if w: actor_list.append(w)
+
+ # --- 2. 涓昏溅 (Ego) ---
+ print("鐢熸垚涓昏溅...")
+ ego_bp = blueprint_library.find('vehicle.tesla.model3')
+ ego_bp.set_attribute('role_name', 'hero')
+ ego_vehicle = world.spawn_actor(ego_bp, ego_spawn_point)
+ ego_vehicle.set_autopilot(True)
+ actor_list.append(ego_vehicle)
+
+ # --- 3. RSU (璺晶鍗曞厓) ---
+ rsu_loc = ego_spawn_point.location
+ rsu_loc.z += 8.0
+ rsu_loc.x += 5.0
+ # 淇 45 搴
+ rsu_transform = carla.Transform(rsu_loc, carla.Rotation(pitch=-45, yaw=ego_spawn_point.rotation.yaw))
+
+ # --- 4. 浼犳劅鍣ㄨ缃 (鍏抽敭淇敼) ---
+ camera_bp = blueprint_library.find('sensor.camera.rgb')
+ camera_bp.set_attribute('image_size_x', '800')
+ camera_bp.set_attribute('image_size_y', '600')
+ camera_bp.set_attribute('fov', '90') # 瑙嗛噹骞夸竴鐐
+
+ # 銆愬叧閿慨鏀癸細寰皟涓昏溅鐩告満浣嶇疆銆
+ # 涔嬪墠鐨 x=1.5, z=2.4 鍙兘鍦ㄦ煇浜涜溅鍨嬬殑杞﹂《閲屻
+ # 鏀逛负 x=1.0 (闈犲悗涓鐐), z=2.0 (浣庝竴鐐)锛岄氬父鍦ㄦ尅椋庣幓鐠冨唴渚с
+ cam_transform = carla.Transform(carla.Location(x=1.0, z=2.0))
+ ego_cam = world.spawn_actor(camera_bp, cam_transform, attach_to=ego_vehicle)
+ actor_list.append(ego_cam)
+
+ rsu_cam = world.spawn_actor(camera_bp, rsu_transform)
+ actor_list.append(rsu_cam)
+
+ # 鐩戝惉鏁版嵁
+ ego_cam.listen(lambda image: sensor_queue.put((image.frame, 'ego_rgb', image)))
+ rsu_cam.listen(lambda image: sensor_queue.put((image.frame, 'rsu_rgb', image)))
+
+ print("\n馃敟 姝e湪棰勭儹浠跨湡 (Warm Up) ... 绛夊緟 50 甯ц鐢婚潰绋冲畾")
+ # --- 5. 鐑韩闃舵 (涓嶄繚瀛樻暟鎹) ---
+ for _ in range(50):
+ world.tick()
+ # 鎶婁骇鐢熺殑鍨冨溇鏁版嵁浠庨槦鍒楅噷娓呯┖
+ try:
+ for _ in range(2): sensor_queue.get(timeout=1.0)
+ except: pass
+
+ print("馃殌 浠跨湡姝e紡寮濮嬶紒姝e湪閲囬泦鏁版嵁...")
+
+ # --- 6. 姝e紡寰幆 ---
+ frame_number = 0
+ spectator = world.get_spectator()
+
+ while True:
+ # 1. 鎺ㄥ姩涓栫晫涓甯
+ world.tick()
+ w_frame = world.get_snapshot().frame
+
+ # 2. 瑙嗚璺熼殢 (淇濇寔 V3 鐨勮窡闅忛昏緫)
+ ego_tf = ego_vehicle.get_transform()
+ ego_fv = ego_tf.get_forward_vector()
+ spectator_loc = ego_tf.location - (ego_fv * 6.0) + carla.Location(z=3.0)
+ spectator_rot = ego_tf.rotation
+ spectator_rot.pitch = -15.0
+ spectator.set_transform(carla.Transform(spectator_loc, spectator_rot))
+
+ # 3. 涓ユ牸鐨勬暟鎹幏鍙栭昏緫
+ # 鎴戜滑闇瑕佺‘淇濆彇鍑虹殑 2 寮犲浘锛岀‘瀹炲睘浜庡綋鍓嶇殑杩欎竴甯 w_frame
+ try:
+ current_frame_data = {} # 鐢ㄥ瓧鍏稿瓨锛歿'ego_rgb': img, 'rsu_rgb': img}
+
+ # 灏濊瘯浠庨槦鍒楀彇鏁版嵁锛岀洿鍒版妸杩欎竴甯х殑涓や釜鐩告満閮藉彇鍒
+ # 璁剧疆瓒呮椂闃叉姝诲惊鐜
+ timeout_counter = 0
+ while len(current_frame_data) < 2 and timeout_counter < 10:
+ data = sensor_queue.get(timeout=1.0)
+ frame_id, s_type, img_obj = data
+
+ # 鍙湁褰撴暟鎹抚鍙 == 涓栫晫甯у彿锛屾墠绠楁湁鏁堟暟鎹
+ # (鍏佽鏈 1 甯х殑璇樊锛屽洜涓篊ARLA鏈夋椂鍊欎細宸1甯)
+ if abs(frame_id - w_frame) <= 1:
+ current_frame_data[s_type] = img_obj
+ else:
+ # 涓㈠純鏃ф暟鎹
+ pass
+ timeout_counter += 1
+
+ # 4. 淇濆瓨鏁版嵁
+ if ENABLE_SAVING and (frame_number % SAVE_INTERVAL == 0):
+ # 纭繚涓や釜鐩告満鐨勬暟鎹兘榻愪簡鎵嶄繚瀛
+ if len(current_frame_data) == 2:
+ print(f"馃捑 淇濆瓨甯 [{w_frame}] | Ego & RSU OK", end='\r')
+
+ # 淇濆瓨 Ego
+ fname_ego = f"{OUTPUT_FOLDER}/ego_rgb/{w_frame:06d}.png"
+ current_frame_data['ego_rgb'].save_to_disk(fname_ego)
+
+ # 淇濆瓨 RSU
+ fname_rsu = f"{OUTPUT_FOLDER}/rsu_rgb/{w_frame:06d}.png"
+ current_frame_data['rsu_rgb'].save_to_disk(fname_rsu)
+ else:
+ print(f"鈿狅笍 涓㈠抚: 鏁版嵁涓嶅畬鏁", end='\r')
+
+ except queue.Empty:
+ print("鈿狅笍 浼犳劅鍣ㄦ暟鎹秴鏃")
+ continue
+
+ frame_number += 1
+
+ except KeyboardInterrupt:
+ print("\n馃洃 鐢ㄦ埛鍋滄")
+ finally:
+ print("\n馃Ч 娓呯悊鐜板満...")
+ settings.synchronous_mode = False
+ world.apply_settings(settings)
+ for actor in actor_list:
+ if actor.is_alive: actor.destroy()
+ print("鉁 瀹屾垚銆")
+
+if __name__ == '__main__':
+ main()
\ No newline at end of file
From be38ad9504226c2e018d593fceb2d59efb179b88 Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Mon, 8 Dec 2025 11:26:56 +0800
Subject: [PATCH 30/32] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=84=9A=E6=9C=AC?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=8C=E5=87=8F=E5=B0=91=E7=94=BB=E9=9D=A2?=
=?UTF-8?q?=E5=8D=A1=E9=A1=BF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../cvips_collector.py | 211 +++++++++++-------
1 file changed, 129 insertions(+), 82 deletions(-)
diff --git a/src/InterconVis_PedSafety_Enh/cvips_collector.py b/src/InterconVis_PedSafety_Enh/cvips_collector.py
index 92f5b0f378..6e3372d150 100644
--- a/src/InterconVis_PedSafety_Enh/cvips_collector.py
+++ b/src/InterconVis_PedSafety_Enh/cvips_collector.py
@@ -4,55 +4,77 @@
import os
import argparse
import time
+import threading
# ================= 閰嶇疆鍖哄煙 =================
-OUTPUT_FOLDER = "_out_cvips_data"
+# 杈撳嚭鏂囦欢澶瑰悕绉
+OUTPUT_FOLDER = "_out_cvips_final"
-# 銆愰噸瑕併戞敼鎴 True 寮鍚繚瀛樸傚缓璁厛璺戜竴娆 False 纭鐢婚潰姝e父
+# 鏄惁寮鍚繚瀛 (璋冭瘯瑙嗚鏃跺彲璁句负 False)
ENABLE_SAVING = True
-# 姣忛殧鍑犲抚淇濆瓨涓娆★紵(寤鸿 10-20锛屽お灏忎細鍗★紝澶ぇ閿欒繃缁嗚妭)
-SAVE_INTERVAL = 10
+# 閲囬泦闂撮殧锛氭瘡 15 甯т繚瀛樹竴娆 (骞宠 1080P 鐨勫瓨鍌ㄥ帇鍔)
+SAVE_INTERVAL = 15
# ===========================================
+# 鍏ㄥ眬鏍囧織浣嶏紝鎺у埗鍚庡彴绾跨▼浣曟椂鍋滄
+writing_thread_running = True
+
def main():
- argparser = argparse.ArgumentParser(description="CVIPS 鏁版嵁閲囬泦鑴氭湰 V4")
+ argparser = argparse.ArgumentParser(description="CVIPS 鏈缁堢増鏁版嵁閲囬泦鑴氭湰")
argparser.add_argument('--town', default='Town01', help='鍦板浘鍚嶇О')
- argparser.add_argument('--num_vehicles', default=20, type=int, help='鑳屾櫙杞﹁締鏁')
- argparser.add_argument('--num_walkers', default=30, type=int, help='琛屼汉鏁')
+ argparser.add_argument('--num_vehicles', default=25, type=int, help='鑳屾櫙杞﹁締鏁')
+ argparser.add_argument('--num_walkers', default=40, type=int, help='琛屼汉鏁')
args = argparser.parse_args()
- # 鍒涘缓鐩綍
+ # 1. 鍒涘缓淇濆瓨鐩綍
if ENABLE_SAVING:
os.makedirs(f"{OUTPUT_FOLDER}/ego_rgb", exist_ok=True)
os.makedirs(f"{OUTPUT_FOLDER}/rsu_rgb", exist_ok=True)
- print(f"馃搧 鍥剧墖灏嗕繚瀛樺湪: {os.path.abspath(OUTPUT_FOLDER)}")
-
- client = carla.Client('localhost', 2000)
- client.set_timeout(60.0)
-
- print(f"姝e湪鍔犺浇鍦板浘 {args.town} (鍙兘闇瑕佸嚑绉)...")
- world = client.load_world(args.town)
-
- # 璁剧疆鍚屾妯″紡
+ print(f"馃搧 鏁版嵁淇濆瓨璺緞: {os.path.abspath(OUTPUT_FOLDER)}")
+
+ # 2. 杩炴帴 CARLA (浣跨敤 127.0.0.1 閬垮厤 Windows 闃茬伀澧欓棶棰)
+ try:
+ client = carla.Client('127.0.0.1', 2000)
+ client.set_timeout(60.0)
+ print(f"姝e湪鍔犺浇鍦板浘 {args.town} ...")
+ world = client.load_world(args.town)
+ except RuntimeError as e:
+ print(f"鉂 杩炴帴澶辫触: {e}")
+ print("璇风‘淇 CARLA 妯℃嫙鍣ㄥ凡鍚姩锛")
+ return
+
+ # 3. 璁剧疆楂樼敾璐ㄥぉ姘 (姝e崍鏅村ぉ)
+ world.set_weather(carla.WeatherParameters.ClearNoon)
+
+ # 4. 璁剧疆鍚屾妯″紡
settings = world.get_settings()
settings.synchronous_mode = True
- settings.fixed_delta_seconds = 0.05
+ settings.fixed_delta_seconds = 0.05 # 鍥哄畾 20 FPS
world.apply_settings(settings)
traffic_manager = client.get_trafficmanager(8000)
traffic_manager.set_synchronous_mode(True)
- # 杩欓噷鐨勯槦鍒楃敤浜庢帴鏀朵紶鎰熷櫒鏁版嵁
- sensor_queue = queue.Queue()
+ # 5. 鍒濆鍖栭槦鍒楀拰鍒楄〃
+ sensor_queue = queue.Queue() # 鎺ユ敹鍘熷鏁版嵁
+ save_queue = queue.Queue() # 鍚庡彴淇濆瓨闃熷垪
actor_list = []
+ # 6. 鍚姩鍚庡彴淇濆瓨绾跨▼
+ global writing_thread_running
+ writing_thread_running = True
+ save_thread = threading.Thread(target=save_worker, args=(save_queue,))
+ save_thread.start()
+ print("鉁 鍚庡彴淇濆瓨鏈嶅姟宸插惎鍔")
+
try:
- # --- 1. 鐢熸垚鐜 ---
- print("姝e湪鏋勫缓鍦烘櫙...")
+ # --- 鐢熸垚鐜 ---
+ print("姝e湪鏋勫缓浜ら氬満鏅...")
blueprint_library = world.get_blueprint_library()
spawn_points = world.get_map().get_spawn_points()
+ # 鍒嗙涓昏溅鐐瑰拰NPC鐐癸紝闃叉纰版挒
ego_spawn_point = spawn_points[0]
npc_spawn_points = spawn_points[1:]
@@ -73,7 +95,7 @@ def main():
w = world.try_spawn_actor(walker_bp, carla.Transform(loc))
if w: actor_list.append(w)
- # --- 2. 涓昏溅 (Ego) ---
+ # --- 鐢熸垚涓昏溅 (Ego) ---
print("鐢熸垚涓昏溅...")
ego_bp = blueprint_library.find('vehicle.tesla.model3')
ego_bp.set_attribute('role_name', 'hero')
@@ -81,23 +103,24 @@ def main():
ego_vehicle.set_autopilot(True)
actor_list.append(ego_vehicle)
- # --- 3. RSU (璺晶鍗曞厓) ---
+ # --- 鐢熸垚 RSU (璺晶鍗曞厓) ---
rsu_loc = ego_spawn_point.location
- rsu_loc.z += 8.0
+ rsu_loc.z += 12.0 # 12绫抽珮绌
rsu_loc.x += 5.0
- # 淇 45 搴
- rsu_transform = carla.Transform(rsu_loc, carla.Rotation(pitch=-45, yaw=ego_spawn_point.rotation.yaw))
+ rsu_transform = carla.Transform(rsu_loc, carla.Rotation(pitch=-70, yaw=ego_spawn_point.rotation.yaw))
- # --- 4. 浼犳劅鍣ㄨ缃 (鍏抽敭淇敼) ---
+ # --- 浼犳劅鍣ㄨ缃 (1080P 楂樼敾璐) ---
camera_bp = blueprint_library.find('sensor.camera.rgb')
- camera_bp.set_attribute('image_size_x', '800')
- camera_bp.set_attribute('image_size_y', '600')
- camera_bp.set_attribute('fov', '90') # 瑙嗛噹骞夸竴鐐
-
- # 銆愬叧閿慨鏀癸細寰皟涓昏溅鐩告満浣嶇疆銆
- # 涔嬪墠鐨 x=1.5, z=2.4 鍙兘鍦ㄦ煇浜涜溅鍨嬬殑杞﹂《閲屻
- # 鏀逛负 x=1.0 (闈犲悗涓鐐), z=2.0 (浣庝竴鐐)锛岄氬父鍦ㄦ尅椋庣幓鐠冨唴渚с
- cam_transform = carla.Transform(carla.Location(x=1.0, z=2.0))
+ camera_bp.set_attribute('image_size_x', '1920')
+ camera_bp.set_attribute('image_size_y', '1080')
+ camera_bp.set_attribute('fov', '90')
+ # 浼樺寲鐢昏川灞炴
+ camera_bp.set_attribute('exposure_mode', 'histogram')
+ camera_bp.set_attribute('motion_blur_intensity', '0.2')
+
+ # 涓昏溅鐩告満锛氱涓変汉绉 (杞﹀悗6绫筹紝楂3绫)锛岄槻閬尅
+ cam_transform = carla.Transform(carla.Location(x=-6.0, z=3.0), carla.Rotation(pitch=-20))
+
ego_cam = world.spawn_actor(camera_bp, cam_transform, attach_to=ego_vehicle)
actor_list.append(ego_cam)
@@ -108,86 +131,110 @@ def main():
ego_cam.listen(lambda image: sensor_queue.put((image.frame, 'ego_rgb', image)))
rsu_cam.listen(lambda image: sensor_queue.put((image.frame, 'rsu_rgb', image)))
- print("\n馃敟 姝e湪棰勭儹浠跨湡 (Warm Up) ... 绛夊緟 50 甯ц鐢婚潰绋冲畾")
- # --- 5. 鐑韩闃舵 (涓嶄繚瀛樻暟鎹) ---
+ print("\n馃敟 姝e湪棰勭儹 (Warm Up)... 璇蜂繚鎸 CARLA 绐楀彛鍦ㄥ墠鍙帮紒")
for _ in range(50):
world.tick()
- # 鎶婁骇鐢熺殑鍨冨溇鏁版嵁浠庨槦鍒楅噷娓呯┖
try:
+ # 娓呯┖棰勭儹鏈熺殑鍨冨溇鏁版嵁
for _ in range(2): sensor_queue.get(timeout=1.0)
except: pass
- print("馃殌 浠跨湡姝e紡寮濮嬶紒姝e湪閲囬泦鏁版嵁...")
+ print("馃殌 閲囬泦寮濮嬶紒鎸 Ctrl+C 浼橀泤閫鍑...")
- # --- 6. 姝e紡寰幆 ---
frame_number = 0
spectator = world.get_spectator()
while True:
- # 1. 鎺ㄥ姩涓栫晫涓甯
+ # 1. 鐗╃悊璁$畻涓甯
world.tick()
w_frame = world.get_snapshot().frame
- # 2. 瑙嗚璺熼殢 (淇濇寔 V3 鐨勮窡闅忛昏緫)
- ego_tf = ego_vehicle.get_transform()
- ego_fv = ego_tf.get_forward_vector()
- spectator_loc = ego_tf.location - (ego_fv * 6.0) + carla.Location(z=3.0)
- spectator_rot = ego_tf.rotation
- spectator_rot.pitch = -15.0
- spectator.set_transform(carla.Transform(spectator_loc, spectator_rot))
-
- # 3. 涓ユ牸鐨勬暟鎹幏鍙栭昏緫
- # 鎴戜滑闇瑕佺‘淇濆彇鍑虹殑 2 寮犲浘锛岀‘瀹炲睘浜庡綋鍓嶇殑杩欎竴甯 w_frame
+ # 2. 绉诲姩瑙備紬瑙嗚璺熼殢涓昏溅 (鏂逛究浣犺瀵)
+ spectator.set_transform(ego_cam.get_transform())
+
try:
- current_frame_data = {} # 鐢ㄥ瓧鍏稿瓨锛歿'ego_rgb': img, 'rsu_rgb': img}
-
- # 灏濊瘯浠庨槦鍒楀彇鏁版嵁锛岀洿鍒版妸杩欎竴甯х殑涓や釜鐩告満閮藉彇鍒
- # 璁剧疆瓒呮椂闃叉姝诲惊鐜
+ # 3. 鑾峰彇鏁版嵁
+ current_frame_data = {}
timeout_counter = 0
+ # 灏濊瘯鍑戦綈涓や釜鐩告満鐨勬暟鎹
while len(current_frame_data) < 2 and timeout_counter < 10:
data = sensor_queue.get(timeout=1.0)
frame_id, s_type, img_obj = data
-
- # 鍙湁褰撴暟鎹抚鍙 == 涓栫晫甯у彿锛屾墠绠楁湁鏁堟暟鎹
- # (鍏佽鏈 1 甯х殑璇樊锛屽洜涓篊ARLA鏈夋椂鍊欎細宸1甯)
+ # 鍏佽 1 甯х殑璇樊
if abs(frame_id - w_frame) <= 1:
current_frame_data[s_type] = img_obj
- else:
- # 涓㈠純鏃ф暟鎹
- pass
timeout_counter += 1
- # 4. 淇濆瓨鏁版嵁
+ # 4. 鏀惧叆鍚庡彴闃熷垪
if ENABLE_SAVING and (frame_number % SAVE_INTERVAL == 0):
- # 纭繚涓や釜鐩告満鐨勬暟鎹兘榻愪簡鎵嶄繚瀛
if len(current_frame_data) == 2:
- print(f"馃捑 淇濆瓨甯 [{w_frame}] | Ego & RSU OK", end='\r')
+ print(f"Frame: {w_frame} | 寰呭瓨闃熷垪: {save_queue.qsize()}", end='\r')
+ save_queue.put(current_frame_data)
- # 淇濆瓨 Ego
- fname_ego = f"{OUTPUT_FOLDER}/ego_rgb/{w_frame:06d}.png"
- current_frame_data['ego_rgb'].save_to_disk(fname_ego)
-
- # 淇濆瓨 RSU
- fname_rsu = f"{OUTPUT_FOLDER}/rsu_rgb/{w_frame:06d}.png"
- current_frame_data['rsu_rgb'].save_to_disk(fname_rsu)
- else:
- print(f"鈿狅笍 涓㈠抚: 鏁版嵁涓嶅畬鏁", end='\r')
-
except queue.Empty:
- print("鈿狅笍 浼犳劅鍣ㄦ暟鎹秴鏃")
continue
frame_number += 1
except KeyboardInterrupt:
- print("\n馃洃 鐢ㄦ埛鍋滄")
+ print("\n馃洃 鐢ㄦ埛璇锋眰鍋滄")
+
finally:
- print("\n馃Ч 娓呯悊鐜板満...")
- settings.synchronous_mode = False
- world.apply_settings(settings)
+ print("\n馃Ч 姝e湪鎵ц娓呯悊绋嬪簭...")
+
+ # 1. 鍋滄鍚庡彴绾跨▼
+ writing_thread_running = False
+
+ # 2. 绛夊緟鍓╀綑鐓х墖淇濆瓨瀹屾瘯 (瑙e喅鎶ラ敊鐨勫叧閿)
+ if not save_queue.empty():
+ print(f"鈴 姝e湪淇濆瓨鍓╀綑鐨 {save_queue.qsize()} 寮犵収鐗囷紝璇蜂笉瑕佸叧闂獥鍙...", end='', flush=True)
+ save_thread.join()
+ print(" 淇濆瓨瀹屾瘯锛")
+ else:
+ save_thread.join()
+
+ # 3. 鎭㈠ CARLA 璁剧疆 (闃叉涓嬫鍚姩鍙樺崱)
+ try:
+ if world:
+ settings = world.get_settings()
+ settings.synchronous_mode = False
+ settings.fixed_delta_seconds = None
+ world.apply_settings(settings)
+ except:
+ pass
+
+ # 4. 瀹夊叏閿姣佹墍鏈夊璞
+ print("馃棏锔 閿姣佽溅杈嗗拰浼犳劅鍣...")
for actor in actor_list:
- if actor.is_alive: actor.destroy()
- print("鉁 瀹屾垚銆")
+ try:
+ if actor.is_alive:
+ actor.destroy()
+ except:
+ pass # 蹇界暐閿姣佹椂鐨勯敊璇
+
+ print("鉁 鍏ㄩ儴瀹屾垚锛岀▼搴忓畨鍏ㄩ鍑恒")
+
+# --- 鍚庡彴宸ヤ綔绾跨▼ ---
+def save_worker(q):
+ while writing_thread_running or not q.empty():
+ try:
+ data_dict = q.get(timeout=1.0)
+ ego_img = data_dict['ego_rgb']
+ rsu_img = data_dict['rsu_rgb']
+
+ # 淇濆瓨 Ego
+ path_ego = f"{OUTPUT_FOLDER}/ego_rgb/{ego_img.frame:06d}.png"
+ ego_img.save_to_disk(path_ego)
+
+ # 淇濆瓨 RSU
+ path_rsu = f"{OUTPUT_FOLDER}/rsu_rgb/{rsu_img.frame:06d}.png"
+ rsu_img.save_to_disk(path_rsu)
+
+ q.task_done()
+ except queue.Empty:
+ continue
+ except Exception as e:
+ print(f"淇濆瓨閿欒: {e}")
if __name__ == '__main__':
main()
\ No newline at end of file
From 50f765e34d9b352b7891d9bb75a9516b83dba774 Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Mon, 8 Dec 2025 11:35:12 +0800
Subject: [PATCH 31/32] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=84=9A=E6=9C=AC?=
=?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=8C=E5=87=8F=E5=B0=91=E7=94=BB=E9=9D=A2?=
=?UTF-8?q?=E5=8D=A1=E9=A1=BF=EF=BC=9B=E6=9B=B4=E6=96=B0README.md=EF=BC=9B?=
=?UTF-8?q?=E5=88=A0=E9=99=A4Terminal=5FCommands.txt?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/InterconVis_PedSafety_Enh/README.md | 1 +
src/InterconVis_PedSafety_Enh/Terminal_Commands.txt | 11 -----------
2 files changed, 1 insertion(+), 11 deletions(-)
delete mode 100644 src/InterconVis_PedSafety_Enh/Terminal_Commands.txt
diff --git a/src/InterconVis_PedSafety_Enh/README.md b/src/InterconVis_PedSafety_Enh/README.md
index 885f38496f..d8b2452482 100644
--- a/src/InterconVis_PedSafety_Enh/README.md
+++ b/src/InterconVis_PedSafety_Enh/README.md
@@ -108,6 +108,7 @@ CVIPS (Connected Vision for Increased Pedestrian Safety) 鏄竴涓嚧鍔涗簬閫
鎴戜滑鎻愪緵浜嗗彲瑙嗗寲缁撴灉鏉ュ睍绀烘垜浠暟鎹泦涓殑涓嶅悓瑙嗚:
+
## 鑷磋阿 (Acknowledgement)
鏈」鐩熀浜庝互涓嬪紑婧愰」鐩: BEVerse, Fiery, open-mmlab, 浠ュ強 DeepAccident銆
diff --git a/src/InterconVis_PedSafety_Enh/Terminal_Commands.txt b/src/InterconVis_PedSafety_Enh/Terminal_Commands.txt
deleted file mode 100644
index 56726ea4aa..0000000000
--- a/src/InterconVis_PedSafety_Enh/Terminal_Commands.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-# 娴嬭瘯1锛氬熀纭鍦烘櫙锛圱own04+4宀旇矾鍙+鏅村ぉ+涓崍锛
-python cvips_generation.py --town Town04 --intersection 4way --weather clear --time_of_day noon
-
-# 娴嬭瘯2锛氬鏉傚満鏅紙Town10HD+3宀旇矾鍙+闆ㄥぉ+鏃ヨ惤+楂樿浜哄瘑搴︼級
-python cvips_generation.py --town Town10HD --intersection 3way --weather rainy --time_of_day sunset --crowd_level high --crossing_percentage 0.3
-
-# 娴嬭瘯3锛氬闂村満鏅紙Town07+4宀旇矾鍙+闃村ぉ+澶滈棿+鑷畾涔夐殢鏈虹瀛愶級
-python cvips_generation.py --town Town07 --intersection 4way --weather cloudy --time_of_day night --seed_value 123 --scenario scenario00005
-
-# 娴嬭瘯4锛氭渶绠鍦烘櫙锛圱own04+3宀旇矾鍙+鏅村ぉ+鏃ヨ惤锛
-python cvips_generation.py --town Town04 --intersection 3way --weather clear --time_of_day sunset
\ No newline at end of file
From 3d6ed720b4213d48646fb7af381890022555876b Mon Sep 17 00:00:00 2001
From: haoliuaa <2121765139@qq.com>
Date: Mon, 15 Dec 2025 10:33:30 +0800
Subject: [PATCH 32/32] =?UTF-8?q?=E6=9B=B4=E6=96=B0README.md=E6=96=87?=
=?UTF-8?q?=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/InterconVis_PedSafety_Enh/README.md | 35 ++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/src/InterconVis_PedSafety_Enh/README.md b/src/InterconVis_PedSafety_Enh/README.md
index d8b2452482..518d07a8f2 100644
--- a/src/InterconVis_PedSafety_Enh/README.md
+++ b/src/InterconVis_PedSafety_Enh/README.md
@@ -104,9 +104,42 @@ CVIPS (Connected Vision for Increased Pedestrian Safety) 鏄竴涓嚧鍔涗簬閫
1. Town01 + 15 杈嗚溅 + 80 涓浜 + 闆ㄥぉ + 鏃ヨ惤 + 绉嶅瓙 111
```shell
python cvips_generation.py --town Town01 --num_vehicles 15 --num_pedestrians 80 --weather rainy --time_of_day sunset --seed 111
+## 鏁版嵁闆嗙敓鎴
+鏁版嵁闆嗙敱cvip_collector.py鐢熸垚锛屼繚瀛樺湪out_cvips_v9(涓绘枃浠跺す)
+- 馃搨 ego_rgb/ : 瀛樻斁涓昏溅锛圱esla锛夎瑙掔殑鍥剧墖锛堝懡鍚嶆牸寮忎负 甯у彿.png锛夈
+- 馃搨 rsu_rgb/ : 瀛樻斁璺晶鍗曞厓锛圧SU锛屽畨瑁呭湪楂樺锛夎瑙掔殑鍥剧墖銆
+### 杩愯鍛戒护
+### 鍩虹妯″紡 (榛樿鍙傛暟)
+- 鍦═own01鍦板浘锛岀敓鎴25杈嗚溅鍜40涓浜猴紝鏅存湕涓崍銆
+ ```shell
+ python cvips_collector.py
+ ```
+### 鏇存崲鍦板浘 (渚嬪 Town02, Town10HD)
+浣跨敤 --town 鍙傛暟銆
+- 鍦 Town02 閲囬泦
+ ```shell
+ python cvips_collector.py --town Town02
+ ```
+- 鍦 Town10HD (楂樻竻鍦板浘) 閲囬泦
+ ```shell
+ python cvips_collector.py --town Town10HD
+ ```
+### 璋冩暣浜ら氬瘑搴 (鎷ュ牭/绌烘椃)
+浣跨敤 --num_vehicles 鍜 --num_walkers銆
+- 鎷ュ牭鍦烘櫙 (50杈嗚溅, 80浜):
+ ```shell
+ python cvips_collector.py --num_vehicles 50 --num_walkers 80
+ ```
+- 绌烘椃鍦烘櫙 (5杈嗚溅, 0浜):
+ ```shell
+ python cvips_collector.py --num_vehicles 5 --num_walkers 0
+ ```
### 鏍锋湰鍙鍖 (Sample Visualizations)
-
鎴戜滑鎻愪緵浜嗗彲瑙嗗寲缁撴灉鏉ュ睍绀烘垜浠暟鎹泦涓殑涓嶅悓瑙嗚:
+- 杞﹁締鑷姩琛岄┒锛堣瑙掍负杞﹀悗锛
+-
+- 妯℃嫙鐜
+-
## 鑷磋阿 (Acknowledgement)