> For the complete documentation index, see [llms.txt](https://testindata.gitbook.io/dataset/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://testindata.gitbook.io/dataset/python-sdk/tian-jia-ke-shi-hua-shu-ju.md).

# 添加可视化数据

在使用TDA对象添加文件的时候，我们得到了用于操作这个文件的File对象，上传数据时，我们可以携带可视化数据同步到数据集管理系统，系统在收到可视化数据后会对数据做对应的可视化展示。

### File对象添加2D矩形框

```bash
box = {
    "x": 10,
    "y": 10,
    "width": 100,
    "height": 100,
}

label = "myTestLabelName"

attr = {
    "attrKey1":"attrVal1",
    "attrKey2":"attrVal2",
    "attrKey3":"attrVal3",
}

file.AddBox2D(box, label=label, attrs=attr)
```

| 参数    | 类型     | 必填 | 说明                                                                      |
| ----- | ------ | -- | ----------------------------------------------------------------------- |
| box   | dict   | 是  | 该2D矩形的数据，x，y代表2D框的左上点，width表示离开左上点向x方向延展的像素个数，height表示离开左上点向y方向延展的像素个数. |
| label | string | 是  | 该2D矩形标记的目标对象类别信息，如：车辆，行人。                                               |
| attr  | dict   | 否  | 改2D矩形对应的属性，如颜色，方向，遮挡，截断等等。                                              |

该函数无返回值。

### File对象添加(椭)圆

```bash
ellipse = {
    "x": 10,
    "y": 10,
    "width": 100,
    "height": 100,
}

label = "myTestLabelName"

attr = {
    "attrKey1":"attrVal1",
    "attrKey2":"attrVal2",
    "attrKey3":"attrVal3",
}

file.AddEllipse(ellipse, label=label, attrs=attr)
```

| 参数      | 类型     | 必填 | 说明                                                         |
| ------- | ------ | -- | ---------------------------------------------------------- |
| ellipse | dict   | 是  | x，y表示该椭圆的中心点，width，height分别表示椭圆的长轴和短轴，当width和height相等时表示正圆 |
| label   | string | 是  | 该椭圆矩形标记的目标对象类别信息，如：车辆，行人。                                  |
| attr    | dict   | 否  | 该椭圆标记目标对应的属性，如颜色，方向，遮挡，截断等等。                               |

该函数无返回值。

### File对象添加多边形

```bash
polygon = [
    {"x":10, "y":10},
    {"x":20, "y":20},
    {"x":30, "y":30},
    {"x":10, "y":50},
]

label = "myTestLabelName"

attr = {
    "attrKey1":"attrVal1",
    "attrKey2":"attrVal2",
    "attrKey3":"attrVal3",
}

file.AddPolygon(polygon, label=label, attrs=attr, index=0)
```

| 参数      | 类型     | 必填 | 说明                                                     |
| ------- | ------ | -- | ------------------------------------------------------ |
| polygon | list   | 是  | 多边形的所有点坐标                                              |
| label   | string | 是  | 标记的目标对象类别信息，如：车辆，行人。                                   |
| attr    | dict   | 否  | 标记目标对应的属性，如颜色，方向，遮挡，截断等等。                              |
| index   | int    | 否  | 当两个多边形存在覆盖或者包含关系时，该字段将说明多边行之间将以何种方式进行展示，index值大的会覆盖小的。 |

该函数无返回值。

### File对象添加线段

```bash
line = [
    {"x":10, "y":10},
    {"x":20, "y":20},
    {"x":30, "y":30},
    {"x":10, "y":50},
]

label = "myTestLabelName"

attr = {
    "attrKey1":"attrVal1",
    "attrKey2":"attrVal2",
    "attrKey3":"attrVal3",
}

file.AddLine(line, label=label, attrs=attr)
```

| 参数    | 类型     | 必填 | 说明                        |
| ----- | ------ | -- | ------------------------- |
| line  | list   | 是  | 所有点坐标                     |
| label | string | 是  | 标记的目标对象类别信息，如：车辆，行人。      |
| attr  | dict   | 否  | 标记目标对应的属性，如颜色，方向，遮挡，截断等等。 |

该函数无返回值。

### File对象添加二阶贝塞尔曲线

关于贝塞尔曲线可以查看【[贝塞尔曲线](https://www.zhihu.com/question/29565629)】

```bash
curve = [
    {"x":10, "y":10},
    {"x":20, "y":20},
    {"x":30, "y":30},
    {"x":10, "y":50},
]

label = "myTestLabelName"

attr = {
    "attrKey1":"attrVal1",
    "attrKey2":"attrVal2",
    "attrKey3":"attrVal3",
}

file.AddCurve(curve, label=label, attrs=attr)
```

| 参数    | 类型     | 必填 | 说明                        |
| ----- | ------ | -- | ------------------------- |
| curve | list   | 是  | 所有点坐标                     |
| label | string | 是  | 标记的目标对象类别信息，如：车辆，行人。      |
| attr  | dict   | 否  | 标记目标对应的属性，如颜色，方向，遮挡，截断等等。 |

该函数无返回值。

### File对象添加特征点

```bash
point = {"x":10, "y":10}

label = "myTestLabelName"

attr = {
    "attrKey1":"attrVal1",
    "attrKey2":"attrVal2",
    "attrKey3":"attrVal3",
}

file.AddPoint(point, label=label, attrs=attr)
```

| 参数    | 类型     | 必填 | 说明                        |
| ----- | ------ | -- | ------------------------- |
| point | dict   | 是  | 特征点坐标                     |
| label | string | 是  | 标记的目标对象类别信息，如：车辆，行人。      |
| attr  | dict   | 否  | 标记目标对应的属性，如颜色，方向，遮挡，截断等等。 |

该函数无返回值。

### File对象添加平行四边形

```bash
parallel = [
    {"x":10, "y":10},
    {"x":20, "y":20},
    {"x":30, "y":30},
    {"x":10, "y":50},
]

label = "myTestLabelName"

attr = {
    "attrKey1":"attrVal1",
    "attrKey2":"attrVal2",
    "attrKey3":"attrVal3",
}

file.AddParallel(parallel, label=label, attrs=attr)
```

| 参数       | 类型     | 必填 | 说明                            |
| -------- | ------ | -- | ----------------------------- |
| parallel | list   | 是  | 必须是4个点，按顺序传入所有点，顺时针或者逆时针，统一即可 |
| label    | string | 是  | 标记的目标对象类别信息，如：车辆，行人。          |
| attr     | dict   | 否  | 标记目标对应的属性，如颜色，方向，遮挡，截断等等。     |

该函数无返回值。

### File对象添加3D立体框

3D立体框是点云数据专有的数据格式。

```bash
box3d = {
    "position": {
        "x": 10,
        "y": 10,
        "z": 10,
    },
    "scale": {
        "x": 10,
        "y": 10,
        "z": 10,
    },
    "rotation": {
        "x": 0,
        "y": 0,
        "z": 1.57,
    }
}

label = "myTestLabelName"

attr = {
    "attrKey1":"attrVal1",
    "attrKey2":"attrVal2",
    "attrKey3":"attrVal3",
}

file.AddBbox3d(box3d, label=label, attrs=attr)
```

| 参数    | 类型     | 必填 | 说明                        |
| ----- | ------ | -- | ------------------------- |
| box3d | list   | 是  | 点云3D立体框的信息。               |
| label | string | 是  | 标记的目标对象类别信息，如：车辆，行人。      |
| attr  | dict   | 否  | 标记目标对应的属性，如颜色，方向，遮挡，截断等等。 |

该函数无返回值。

### File对象添加平面伪3D框

```bash
cuboid = {
    "back":[
        {"x":10, "y":50},
        {"x":10, "y":50},
        {"x":10, "y":50},
        {"x":10, "y":50},
    ],
    "front":[
        {"x":10, "y":50},
        {"x":10, "y":50},
        {"x":10, "y":50},
        {"x":10, "y":50},
    ]
}
attr = {
    "type": mark["property"][0][0]["ptitle"],
    "pname": mark["property"][0][0]["pname"],
    "pselect": mark["pselect"],
}

label = "myTestLabelName"

attr = {
    "attrKey1":"attrVal1",
    "attrKey2":"attrVal2",
    "attrKey3":"attrVal3",
}

file.AddCuboid(cuboid, label=label, attrs=attr)
```

| 参数     | 类型     | 必填 | 说明                                        |
| ------ | ------ | -- | ----------------------------------------- |
| cuboid | dict   | 是  | front和back分别表示该伪3D框的前面和后面的每个点，每个面的点数必须等于4 |
| label  | string | 是  | 标记的目标对象类别信息，如：车辆，行人。                      |
| attr   | dict   | 否  | 标记目标对应的属性，如颜色，方向，遮挡，截断等等。                 |

该函数无返回值。

### File对象添加平面日形框

```bash
sideCuboid = {
    "back":[
        {"x":10, "y":50},
        {"x":10, "y":50},
    ],
    "front":[
        {"x":10, "y":50},
        {"x":10, "y":50},
        {"x":10, "y":50},
        {"x":10, "y":50},
    ]
}
attr = {
    "type": mark["property"][0][0]["ptitle"],
    "pname": mark["property"][0][0]["pname"],
    "pselect": mark["pselect"],
}

label = "myTestLabelName"

attr = {
    "attrKey1":"attrVal1",
    "attrKey2":"attrVal2",
    "attrKey3":"attrVal3",
}

file.AddSideCuboid(sideCuboid, label=label, attrs=attr)
```

| 参数         | 类型     | 必填 | 说明                                                     |
| ---------- | ------ | -- | ------------------------------------------------------ |
| sideCuboid | dict   | 是  | front和back分别表示该日形框框的前面和后面的每个点，front的点数必须为4，back的点数必须为2 |
| label      | string | 是  | 标记的目标对象类别信息，如：车辆，行人。                                   |
| attr       | dict   | 否  | 标记目标对应的属性，如颜色，方向，遮挡，截断等等。                              |

该函数无返回值。
