1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
| """ 使用 Isaac Sim IRA 生成 DMS 疲劳检测训练数据
场景类型: - 打哈欠(Yawn) - 闭眼(CloseEyes) - 头部下垂(HeadDrop) - 眼神涣散(GazeAversion) """
import os from isaacsim import SimulationApp
simulation_app = SimulationApp({"headless": True})
from isaacsim.core.utils.extensions import enable_extension
enable_extension("isaacsim.replicator.agent.core") simulation_app.update()
from isaacsim.replicator.agent.core import api as IRA
fatigue_config = { "environment": { "usd_path": "/path/to/cabin_interior.usd" }, "character": [ { "name": "driver_fatigue", "group": "fatigue_test", "seed": 42, "behaviors": [ { "type": "Idle", "weight": 0.3, "params": {"duration_range": [2.0, 5.0]} }, { "type": "Yawn", "weight": 0.2, "params": {"intensity": "medium"} }, { "type": "CloseEyes", "weight": 0.15, "params": {"duration_range": [1.0, 3.0]} }, { "type": "HeadDrop", "weight": 0.1, "params": {"angle_range": [15.0, 30.0]} }, { "type": "Blink", "weight": 0.15, "params": {"rate_range": [10, 20]} } ] } ], "sensor": [ { "name": "dms_rgb_ir", "type": "Camera", "position": [0.0, -0.5, 1.2], "rotation": [0.0, 15.0, 0.0], "resolution": [1920, 1080], "fps": 30, "modalities": ["rgb", "infrared"] } ], "replicator": { "output_dir": "~/dms_fatigue_dataset", "duration": 120.0, "writers": [ { "type": "IRABasicWriter", "annotators": [ "rgb", "instance_segmentation", "object_detection", "skeleton_2d", "skeleton_3d" ] } ] } }
async def generate_fatigue_dataset(): """生成疲劳检测训练数据集""" IRA.set_config(fatigue_config) await IRA.setup_simulation() await IRA.start_data_generation_async(will_wait_until_complete=True) print("疲劳数据集生成完成!") print(f"输出位置: {fatigue_config['replicator']['output_dir']}")
import omni.kit.app simulation_app.run_coroutine(generate_fatigue_dataset()) simulation_app.close()
|