Skip to content

copc-lib provides an easy-to-use reader and writer interface for creating and reading Cloud Optimized Point Clouds, with bindings for Python and C++

License

Notifications You must be signed in to change notification settings

RockRobotic/copc-lib

Repository files navigation

copc-lib

copc-lib provides an easy-to-use reader and writer interface for COPC point clouds, with bindings for python and C++.

Installation

The quickest way to get started with copc-lib is with our conda and pip packages.

Conda

Conda includes both the C++ and python bindings:

conda install -c conda-forge copc-lib

Pip

Pip provide only python bindings:

pip install copclib

Building from source

Dependencies

copc-lib has the following dependencies:

  • laz-perf>=3.0.0
  • Catch2 v2.x (test suite only)
  • Pybind11 (python bindings only)

To install all dependencies:

conda install -c conda-forge "laz-perf>=3.0" Catch2=2.13 pybind11

C++

git clone https://github.com/RockRobotic/copc-lib.git
cd copc-lib
mkdir build && cd build
cmake ..
cmake --build .
sudo cmake --install .

Python

git clone https://github.com/RockRobotic/copc-lib.git
pip install ./copc-lib

Example Files & Unit Tests

To build the copc-lib examples and unit tests along with the main library, you must enable them:

mkdir build && cd build
cmake .. -DWITH_TESTS=ON -DWITH_PYTHON=ON
cmake --build .
ctest # All tests should pass

Usage

The Reader and Writer objects provide the primary means of interfacing with your COPC files. For more complex use cases, we also provide additional objects such as LAZ Compressors and Decompressors (see example/example-writer.cpp).

For common use cases, see the example and test folders for full examples.

C++

copc-lib is compatible with CMake. Assuming copc-lib and lazperf are installed on the system, you can link with them in your CMakeLists.txt:

find_package(COPCLIB REQUIRED)
find_package(LAZPERF REQUIRED)

add_executable(funlib fun-main.cpp)
target_link_libraries(funlib COPCLIB::copc-lib LAZPERF::lazperf)

The primary public interface will be your FileReader and FileWriter objects. Check the headers and example files for documentation.

#include <iostream>
#include <copc-lib/io/reader.hpp>

void main()
{
    // Create a reader object
    FileReader reader("autzen-classified.copc.laz");

    // Get the node metadata from the hierarchy
    auto node = reader.FindNode(copc.VoxelKey(0, 0, 0, 0));
    // Fetch the points of a node
    auto points = reader.GetPoints(node);

    // Iterate through each point
    for (const auto &point : points)
        std::cout << "X: " << point.X ", Y: " << point.Y << ", Z: " << point.Z  << std::endl;
}

Python

Example files are also provided for python.

import copclib as copc

# Create a reader object
reader = copc.FileReader("autzen-classified.copc.laz")

# Get the node metadata from the hierarchy
node = reader.FindNode(copc.VoxelKey(0, 0, 0, 0))
# Fetch the points of a node
points = reader.GetPoints(node)

# Iterate through each point
for point in points:
    print(point.x, point.y, point.z)

Note that, in python, dimension names for points follow the laspy naming scheme, with the exception of scan_angle.

Helpful Links

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

Please see LICENSE.md

Credits

copc-lib is created and maintained by Chris Lee, Leo Stanislas and other members of RockRobotic.

The COPC file format is created and maintained by HOBU Inc. Some code has been adopted from PDAL and lazperf, both of which are maintained by HOBU Inc.

About

copc-lib provides an easy-to-use reader and writer interface for creating and reading Cloud Optimized Point Clouds, with bindings for Python and C++

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •