# Compression-PCL-Cpp  (70%)

```cpp
#include <pcl/io/pcd_io.h>
#include <pcl/compression/octree_pointcloud_compression.h>
#include <boost/thread/thread.hpp>
#include <pcl/visualization/pcl_visualizer.h>

int
main (int argc, char** argv)
{
    // Objects for storing the point clouds.
    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
    pcl::PointCloud<pcl::PointXYZ>::Ptr decompressedCloud(new pcl::PointCloud<pcl::PointXYZ>);

    // Read a PCD file from disk.
    pcl::io::loadPCDFile<pcl::PointXYZ> ("lobby.pcd", *cloud);



    // Octree compressor object.
    // Check /usr/include/pcl-<version>/pcl/compression/compression_profiles.h for more profiles.
    // The second parameter enables the output of information.
    pcl::io::OctreePointCloudCompression<pcl::PointXYZ> octreeCompression(pcl::io::MED_RES_ONLINE_COMPRESSION_WITHOUT_COLOR, true);
    // Stringstream that will hold the compressed cloud.
    std::stringstream compressedData;

    // Compress the cloud (you would save the stream to disk).
    octreeCompression.encodePointCloud(cloud, compressedData);

    // Decompress the cloud.
    octreeCompression.decodePointCloud(compressedData, decompressedCloud);



}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pcl.gitbook.io/tutorial/part-2/part02-chapter02/part02-chapter02-compression-pcl-cpp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
