copc-lib provides an easy-to-use reader and writer interface for COPC point clouds, with bindings for python and C++.
The quickest way to get started with copc-lib is with our conda and pip packages.
Conda includes both the C++ and python bindings:
conda install -c conda-forge copc-lib
Pip provide only python bindings:
pip install copclib
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
git clone https://github.com/RockRobotic/copc-lib.git
cd copc-lib
mkdir build && cd build
cmake ..
cmake --build .
sudo cmake --install .
git clone https://github.com/RockRobotic/copc-lib.git
pip install ./copc-lib
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
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.
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;
}
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
.
- COPC Spec
- copc.js - TypeScript library for reading COPC files
- copc.js for browser - Webpacked version of copc.js for the browser
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.
Please see LICENSE.md
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.