From b95a3579fc57f0cb67f826d1d882e6f5dc151a62 Mon Sep 17 00:00:00 2001 From: Ying-Li Niu <64801511@qq.com> Date: Fri, 12 Jun 2026 08:08:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20move=5Fcamera.txt=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=20all=20=E5=85=B3=E9=94=AE=E8=AF=8D=E8=A1=A8=E7=A4=BA=E5=85=A8?= =?UTF-8?q?=E7=A8=8B=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在帧位置写 all 表示该段对所有帧生效: all vx=0.1 ry=0.5 # 全程缓慢平移 + 旋转 等同于 start=0, end=INF,与普通区间段一样支持时间交叠。 --- compute.py | 13 ++++++++----- draw.py | 12 ++++++++---- dynamics.py | 12 ++++++++---- examples/case06/input/move_camera.txt | 4 ++-- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/compute.py b/compute.py index e410988..f639e35 100644 --- a/compute.py +++ b/compute.py @@ -108,11 +108,14 @@ def _load_camera_motion(path): line = line.strip() if not line or line.startswith("#"): continue - # 解析帧范围 - m = re.match(r'(\d+)\s*-\s*(\d+)', line) - if not m: - continue - start, end = int(m.group(1)), int(m.group(2)) + # 解析帧范围:支持 "all"(全程)或 "N-M"(区间) + if line.lower().startswith("all") or re.match(r'^\s*all\s', line, re.IGNORECASE): + start, end = 0, 10**9 + else: + m = re.match(r'(\d+)\s*-\s*(\d+)', line) + if not m: + continue + start, end = int(m.group(1)), int(m.group(2)) v = [0.0, 0.0, 0.0] r = [0.0, 0.0, 0.0] # 解析 vx=, vy=, vz= diff --git a/draw.py b/draw.py index f22ba9b..574712d 100644 --- a/draw.py +++ b/draw.py @@ -570,10 +570,14 @@ def _load_move_camera_txt(): line = line.strip() if not line or line.startswith("#"): continue - m = _re.match(r'(\d+)\s*-\s*(\d+)', line) - if not m: - continue - start, end = int(m.group(1)), int(m.group(2)) + # 解析帧范围:支持 "all"(全程)或 "N-M"(区间) + if line.lower().startswith("all") or _re.match(r'^\s*all\s', line, _re.IGNORECASE): + start, end = 0, 10**9 # 用极大值表示全程 + else: + m = _re.match(r'(\d+)\s*-\s*(\d+)', line) + if not m: + continue + start, end = int(m.group(1)), int(m.group(2)) v, r = [0.0, 0.0, 0.0], [0.0, 0.0, 0.0] for i, axis in enumerate(['x', 'y', 'z']): m2 = _re.search(r'v' + axis + r'\s*=\s*([-\d.]+)', line) diff --git a/dynamics.py b/dynamics.py index 6abbcc1..030092b 100644 --- a/dynamics.py +++ b/dynamics.py @@ -50,10 +50,14 @@ def _load_camera_kf(config, runtime_base): line = line.strip() if not line or line.startswith("#"): continue - m = re.match(r'(\d+)\s*-\s*(\d+)', line) - if not m: - continue - start, end = int(m.group(1)), int(m.group(2)) + # 解析帧范围:支持 "all"(全程)或 "N-M"(区间) + if line.lower().startswith("all") or re.match(r'^\s*all\s', line, re.IGNORECASE): + start, end = 0, 10**9 + else: + m = re.match(r'(\d+)\s*-\s*(\d+)', line) + if not m: + continue + start, end = int(m.group(1)), int(m.group(2)) v, r = [0.0, 0.0, 0.0], [0.0, 0.0, 0.0] for i, axis in enumerate(['x', 'y', 'z']): m2 = re.search(r'v' + axis + r'\s*=\s*([-\d.]+)', line) diff --git a/examples/case06/input/move_camera.txt b/examples/case06/input/move_camera.txt index a3063c7..37d5c88 100644 --- a/examples/case06/input/move_camera.txt +++ b/examples/case06/input/move_camera.txt @@ -5,5 +5,5 @@ # rx → elevation(俯仰), ry → azimuth(方位), rz → (预留) # # 示例:前60帧向右平移+绕x旋转,30-90帧向上平移+绕y绕z旋转 -1-60 vx=0.02 rx=1 -30-90 vy=0.02 ry=1 rz=1 +all vx=0.02 +# 30-90 vy=0.02 ry=1 rz=1