Caesarrr commited on
Commit
3eacd49
·
1 Parent(s): 50585c5

feat: add action_state task description

Browse files
action_state/gen_task1.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ 给定一张物体在初始视角的图片,camera将围绕该静止物体进行水平移动。旋转的方向(顺时针或逆时针)是基于从物体正上方俯视(鸟瞰视角)的平面来定义的。模型需要根据给定的旋转方向和角度,推断出新视角下的物体图像,并从四个图像中选出正确的一项。
3
+
4
+ 注:{angle}就是 xx degrees, {direction} 就是 clockwise / anticlockwise
5
+
6
+ 1.
7
+ The object in the image <image_start>[image_1]<image_end> remains **static**. Imagine a camera rotating around this object. The direction of rotation is defined from a **top-down bird's-eye view**.
8
+
9
+ Please identify the view of the object after the camera rotates {angle} {direction} based on this top-down perspective, and select the correct answer.
10
+
11
+ A. <image_start>[image_A]<image_end>
12
+ B. <image_start>[image_B]<image_end>
13
+ C. <image_start>[image_C]<image_end>
14
+ D. <image_start>[image_D]<image_end>
15
+
16
+
17
+ 2.
18
+ Given the initial view of a static object: <image_start>[image_1]<image_end>.
19
+
20
+ Imagine looking at the setup from a bird's-eye view (from directly above) to determine the direction. Now, move the camera {angle} {direction} around the object.
21
+
22
+ Which of the following images shows what the object looks like from this new position?
23
+
24
+ A. <image_start>[image_A]<image_end>
25
+ B. <image_start>[image_B]<image_end>
26
+ C. <image_start>[image_C]<image_end>
27
+ D. <image_start>[image_D]<image_end>
28
+
29
+ """
action_state/gen_task2.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ 物体保持静止。摄像机围绕物体进行水平轨道运动。这里的“旋转”是指摄像机在水平面上绕物体中心移动,其方向定义参考鸟瞰视角下的时钟方向(即从上往下看,顺时针或逆时针移动)
3
+
4
+ 给定一张物体的初始视角图片,以及一系列旋转指令,模型需要计算这些指令叠加后的最终位置,并从A、B、C、D四个选项中选出该视角对应的图片。
5
+
6
+
7
+ 1.
8
+ The object in the image <image_start>[image_1]<image_end> remains **static**.
9
+
10
+ Imagine a camera rotating around this object. The direction of rotation is defined from a **top-down bird's-eye view**.
11
+
12
+ Please identify the view of the object after the camera follows this sequence of rotations: {instruction_sequence}. Based on this top-down perspective, select the correct answer.
13
+
14
+ A. <image_start>[image_A]<image_end>
15
+ B. <image_start>[image_B]<image_end>
16
+ C. <image_start>[image_C]<image_end>
17
+ D. <image_start>[image_D]<image_end>
18
+
19
+
20
+ 2.
21
+ Given the initial view of a static object: <image_start>[image_1]<image_end>.
22
+
23
+ Imagine looking at the setup from a bird's-eye view (from directly above) to determine the direction. Now, move the camera according to the following instructions: {instruction_sequence}.
24
+
25
+ Which of the following images shows what the object looks like from this new position?
26
+
27
+ A. <image_start>[image_A]<image_end>
28
+ B. <image_start>[image_B]<image_end>
29
+ C. <image_start>[image_C]<image_end>
30
+ D. <image_start>[image_D]<image_end>
31
+
32
+ """
action_state/gen_task3.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ **任务名称:** 围绕静止物体的相机视角排序(Camera View Ordering around Static Objects)
3
+
4
+ **任务设定:**
5
+ 本任务模拟一个静止物体被移动相机拍摄的场景。相机围绕物体进行平滑的轨道旋转(Orbital Rotation)。
6
+ 1. **数据来源:** 所有图像均从一段连续的视频中抽帧获得,因此具备内在的时空连贯性。
7
+ 2. **运动约束:** 从给定的初始参考帧(Reference Frame)到序列的最后一帧,相机的总旋转角度严格限制在半个圆周(<180度)以内,保证视角的单向性和连续性。
8
+
9
+ **输入数据:**
10
+ * 一张**初始参考图(Reference Image)**,作为序列的起点(t=0)。
11
+ * 四张**候选图片(Candidate Images)**,编号为 1、2、3、4。这四张图片是参考图之后的后续帧,但顺序已被打乱。
12
+
13
+ **任务目标:**
14
+ 模型需要分析参考图与候选图片之间的几何关系,将四张候选图片按照真实的时间/空间顺序重新排列,使其构成一个连贯的相机运动轨迹。
15
+
16
+ **输出格式:**
17
+ 提供 A、B、C、D 四个选项,每个选项代表一种排序组合(例如 B: 2-1-4-3)。模型需选择能够恢复正确时空顺序的选项。
18
+
19
+
20
+
21
+ 1.
22
+ The object in the initial view <image_start>[image_ref]<image_end> remains **static**. Imagine a camera rotating around this object along a continuous path. The total rotation from the start to the end is less than 180 degrees.
23
+
24
+ Below are four images captured during this rotation, labeled 1, 2, 3 and 4. They're currently shuffled.
25
+
26
+ 1. <image_start>[image_1]<image_end>
27
+ 2. <image_start>[image_2]<image_end>
28
+ 3. <image_start>[image_3]<image_end>
29
+ 4. <image_start>[image_4]<image_end>
30
+
31
+ Please analyze the change in perspective and determine the correct chronological order of these four images following the initial view. Select the corret sequence.
32
+
33
+ A. [sequence_A]
34
+ B. [sequence_B]
35
+ C. [sequence_C]
36
+ D. [sequence_D]
37
+
38
+
39
+ 2.
40
+ Given the initial view of the static object: <image_start>[image_ref]<image_end>.
41
+
42
+ Imagine a camera rotating around this object to capture a video sequence. The rotation covers an anlge of less than 180 degrees. We have extracted four frames from the sequence, labeled 1 to 4, but their order is jumbled.
43
+
44
+ 1. <image_start>[image_1]<image_end>
45
+ 2. <image_start>[image_2]<image_end>
46
+ 3. <image_start>[image_3]<image_end>
47
+ 4. <image_start>[image_4]<image_end>
48
+
49
+ Which of the following four options correctly sorts these images into a coherent spatio-temporal starting after the initial view?
50
+
51
+ A. [sequence_A]
52
+ B. [sequence_B]
53
+ C. [sequence_C]
54
+ D. [sequence_D]
55
+
56
+
57
+ """
action_state/gen_task4.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ **任务名称:** 跨视角目标点匹配 / 旋转视角下的关键点对应
3
+
4
+ **场景设定:**
5
+ 在一个静态场景中,保持物体位置固定,摄像机围绕物体进行旋转拍摄。
6
+
7
+ **输入数据:**
8
+ 1. **源视图(Source View):** 摄像机在初始视角拍摄的物体图像,图像上标注了一个特定的关键点 $A$(Target Point)。
9
+ 2. **目标视图(Target View):** 摄像机旋转到新视角后拍摄的同一物体图像。该图像上标注了若干个候选点(例如:1, 2, 3, 4)。
10
+
11
+ **任务目标:**
12
+ 模型需要分析两张图像的几何与纹理特征,从目标视图的候选点集合中,识别出哪一个点与源视图中的点 $A$ 对应于物体表面的同一物理位置(例如,如果点 2 与点 $A$ 是同一点,模型应输出 2)。
13
+
14
+
15
+ 1.
16
+ The object in the initial view <image_start>[image_1]<image_end> remains **static**, with a specific point marked as **A**.
17
+
18
+ Imagine a camera rotating around this object to a new position. The final view captured from this new angle is shown below, with four candidate points marked as **1, 2, 3 and 4**.
19
+
20
+ Based on the visual features and geometry, which of the numbered points in the final view corresponds to the **same physical location** as point **A** in the inital view?
21
+
22
+ **Final view**:<image_start>[image_2]<image_end>
23
+
24
+ A. Point 1
25
+ B. Point 2
26
+ C. Point 3
27
+ D. Point 4
28
+
29
+
30
+ """
action_state/utils.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import os
3
+ import numpy as np
4
+ from scipy.spatial.transform import Rotation as SciRotation
5
+
6
+ def get_relative_horizontal_rotation(root_path, category, sequence_number, frame_idx_1, frame_idx_2):
7
+ """
8
+ 计算 frame_2 相对于 frame_1 在水平方向上的旋转角度 (Yaw)。
9
+
10
+ Args:
11
+ root_path (str): 数据集根目录 (包含 data/original/...)
12
+ category (str): 类别名称 (例如 'motorcycle')
13
+ sequence_number (str): 序列号 (例如 '613_98146_195503')
14
+ frame_idx_1 (int): 起始帧号 (例如 6)
15
+ frame_idx_2 (int): 目标帧号 (例如 7)
16
+
17
+ Returns:
18
+ float: 相对旋转角度(单位:度 Degree),正值通常表示向右/逆时针旋转,取决于坐标系定义。
19
+ 如果找不到文件或帧,返回 None。
20
+ """
21
+ json_path = os.path.join(root_path, 'data', 'original', category, 'frame_annotations.json')
22
+
23
+ # 2. 读取 JSON 数据
24
+ with open(json_path, 'r') as f:
25
+ annotations = json.load(f)
26
+
27
+ # 3. 查找对应帧的 R 矩阵
28
+ R1 = None
29
+ R2 = None
30
+
31
+ # 这里的 annotations 可能是一个大列表,包含该 category 下所有 sequence 的帧
32
+ # 或者如果 json 在 sequence 目录下,它只包含该 sequence 的帧
33
+ for item in annotations:
34
+ # 过滤 sequence (如果 json 包含多个 sequence)
35
+ if item.get('sequence_name') != sequence_number:
36
+ continue
37
+
38
+ if item['frame_number'] == frame_idx_1:
39
+ R1 = np.array(item['viewpoint']['R'])
40
+ elif item['frame_number'] == frame_idx_2:
41
+ R2 = np.array(item['viewpoint']['R'])
42
+
43
+ if R1 is not None and R2 is not None:
44
+ break
45
+
46
+ if R1 is None or R2 is None:
47
+ print(f"Error: Could not find frame {frame_idx_1} or {frame_idx_2} in sequence {sequence_number}")
48
+ return None
49
+
50
+ # 4. 计算相对旋转
51
+ # 假设 R 是 World-to-Camera 矩阵 (常见于 NeRF/PyTorch3D 数据)
52
+ # 我们想要计算 Camera 1 到 Camera 2 的变换。
53
+ # R_rel = R2 @ R1.T
54
+ # 解释: R1.T 将 Cam1 转回 World,R2 将 World 转去 Cam2
55
+ R_rel = R2 @ R1.T
56
+
57
+ # 5. 转换为欧拉角提取水平分量
58
+ # 使用 scipy 的 Rotation 库处理,避免万向节死锁和复杂的数学公式
59
+ r = SciRotation.from_matrix(R_rel)
60
+
61
+ # 这里的顺序 'y' 代表水平轴旋转 (Yaw)。
62
+ # 常见的顺序是 'xyz', 'zyx' 等。
63
+ # 对于大多数 3D 视觉任务(Y-up 坐标系),Y 轴旋转即为水平旋转。
64
+ # 如果是 Z-up 坐标系,则需要取 'z' 分量。
65
+ # CO3D / PyTorch3D 通常是 Y-up, X-left, Z-in (NDC) 或者类似的右手系。
66
+ # 我们提取 'y' 分量作为水平角。
67
+
68
+ # as_euler 返回的是 [x_angle, y_angle, z_angle] (对应 'xyz' 顺序)
69
+ # degrees=True 直接返回角度
70
+ euler_angles = r.as_euler('xyz', degrees=True)
71
+
72
+ # 提取 Y 轴分量 (索引 1)
73
+ horizontal_rotation = euler_angles[1]
74
+
75
+ return horizontal_rotation
76
+
77
+ # --- 测试代码 ---
78
+ if __name__ == "__main__":
79
+ yaw = get_relative_horizontal_rotation(
80
+ root_path="/run/determined/NAS1/public/lixinyuan/interleaved-co3d",
81
+ category="motorcycle",
82
+ sequence_number="216_22798_47409",
83
+ frame_idx_1=90,
84
+ frame_idx_2=74,
85
+ )
86
+
87
+ print(f"Calculated Relative Yaw: {yaw:.4f} degrees")