# PointCloudConfig

PointCloudConfig 是一个配置类，用于调整 DepthAI 生态系统中点云生成的设置。它允许用户配置稀疏性和变换矩阵等属性，这些属性对于根据特定应用需求定制点云数据至关重要。

## 配置选项

 * 稀疏性：决定生成的点云是否应为稀疏点云。稀疏点云可根据某些条件（如深度值阈值）省略点，以减少数据量和处理需求。
 * 变换矩阵：对点云数据应用变换矩阵，实现旋转、平移和缩放，以将点云对齐到世界或应用特定的坐标系。

## 使用方法

配置 PointCloudConfig 可以精确控制点云数据的生成。以下是如何在 DepthAI 应用中配置和应用 PointCloudConfig 的示例：

#### Python

```python
import depthai as dai

# 创建管道
pipeline = dai.Pipeline()

# 创建 PointCloud 节点
pointCloud = pipeline.create(dai.node.PointCloud)

pointCloud.initialConfig.setSparse(True) # 启用稀疏点云生成

# 定义变换矩阵
transformationMatrix = [
    [1.0, 0.0, 0.0, 0.0],
    [0.0, 1.0, 0.0, 0.0],
    [0.0, 0.0, 1.0, 0.0],
    [0.0, 0.0, 0.0, 1.0]
]
pointCloud.initialConfig.setTransformationMatrix(transformationMatrix) # 应用变换矩阵

# 进一步的管道设置和执行...
```

#### C++

```cpp
#include "depthai/depthai.hpp"

int main() {
    // 创建管道
    dai::Pipeline pipeline;

    // 创建 PointCloud 节点
    auto pointCloud = pipeline.create<dai::node::PointCloud>();

    pointCloud->initialConfig.setSparse(true); // 启用稀疏点云生成

    // 定义变换矩阵
    std::vector<std::vector<float>> transformationMatrix = {
        {1.0, 0.0, 0.0, 0.0},
        {0.0, 1.0, 0.0, 0.0},
        {0.0, 0.0, 1.0, 0.0},
        {0.0, 0.0, 0.0, 1.0}
    };
    pointCloud->initialConfig.setTransformationMatrix(transformationMatrix); // 应用变换矩阵

    // 进一步的管道设置和执行...

    return 0;
}
```

此示例展示了如何初始化 PointCloudConfig，设置为生成稀疏点云，并应用变换矩阵。然后将此配置应用于 DepthAI 管道中的 PointCloud 节点。

## 功能示例

 * 3D 物体定位：调整变换矩阵，将点云与已知坐标系对齐，以实现精确的物体放置。
 * 场景优化：利用稀疏点云提高大规模或复杂场景中的处理效率。
 * 数据对齐：应用变换矩阵，将点云数据与其他传感器数据或现有 3D 模型无缝集成。

## 参考

#### Python

### depthai.PointCloudConfig(depthai.Buffer)

Kind: Class

PointCloudConfig message. Carries ROI (region of interest) and threshold for
depth calculation

#### __init__()

Kind: Method

#### get(self) -> RawPointCloudConfig: RawPointCloudConfig

Kind: Method

Retrieve configuration data for SpatialLocationCalculator.

Returns:
config for SpatialLocationCalculator

#### getSparse(self) -> bool: bool

Kind: Method

Retrieve sparse point cloud calculation status.

Returns:
true if sparse point cloud calculation is enabled, false otherwise

#### getTransformationMatrix(self) -> typing.Annotated[list[typing.Annotated[list[float], FixedSize(4)]], FixedSize(4)]:
typing.Annotated[list[typing.Annotated[list[float], FixedSize(4)]], FixedSize(4)]

Kind: Method

Retrieve transformation matrix for point cloud calculation.

Returns:
4x4 transformation matrix

#### set(self, config: RawPointCloudConfig) -> PointCloudConfig: PointCloudConfig

Kind: Method

Set explicit configuration.

Parameter ``config``:
Explicit configuration

#### setSparse(self, arg0: bool) -> PointCloudConfig: PointCloudConfig

Kind: Method

Enable or disable sparse point cloud calculation.

Parameter ``enable``:

#### setTransformationMatrix()

Kind: Method

#### C++

### dai::PointCloudConfig

Kind: class

PointCloudConfig message. Carries ROI (region of interest) and threshold for depth calculation

#### PointCloudConfig()

Kind: function

Construct PointCloudConfig message.

#### PointCloudConfig(std::shared_ptr< RawPointCloudConfig > ptr)

Kind: function

#### ~PointCloudConfig()

Kind: function

#### PointCloudConfig & set(dai::RawPointCloudConfig config)

Kind: function

Set explicit configuration. parameters: config: Explicit configuration

#### dai::RawPointCloudConfig get()

Kind: function

Retrieve configuration data for SpatialLocationCalculator. return: config for SpatialLocationCalculator

#### bool getSparse()

Kind: function

Retrieve sparse point cloud calculation status. return: true if sparse point cloud calculation is enabled, false otherwise

#### std::array< std::array< float, 4 >, 4 > getTransformationMatrix()

Kind: function

Retrieve transformation matrix for point cloud calculation. return: 4x4 transformation matrix

#### PointCloudConfig & setSparse(bool enable)

Kind: function

Enable or disable sparse point cloud calculation. parameters: enable:

#### PointCloudConfig & setTransformationMatrix(const std::array< std::array< float, 4 >, 4 > & transformationMatrix)

Kind: function

Set 4x4 transformation matrix for point cloud calculation. Default is an identity matrix. parameters: transformationMatrix:

#### PointCloudConfig & setTransformationMatrix(const std::array< std::array< float, 3 >, 3 > & transformationMatrix)

Kind: function

Set 3x3 transformation matrix for point cloud calculation. Default is an identity matrix. parameters: transformationMatrix:

### 需要帮助？

请前往 [OAKChina 官网](https://www.oakchina.cn/) 获取技术支持或解答您的任何疑问。
