Skip to main content

copc-lib provides an easy-to-use interface for reading and creating Cloud Optimized Point Clouds

Project description

copc-lib

copc-lib is a library which provides an easy-to-use reader and writer interface for COPC point clouds. This project provides a complete interface for handling COPC files, so that no additional LAZ or LAS libraries are required.

Build from source

Dependencies

copc-lib has the following dependencies:

  • laz-perf>=3.0.0
  • Catch2
  • Pybind11

To install dependencies:

conda install -c conda-forge "laz-perf>=3.0" Catch2 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

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)

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
cmake --build .

Then, you can run the unit tests and the examples:

ctest # All tests should pass

cd bin
./example_reader
./example_writer

Alternatively, you can build the test and example files from their respective CMakeLists, assuming copc-lib is already installed.

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.Get():
    print(point)

Coming Soon

  • [x] Basic C++ Reader Interface
  • [x] Return Point structures from the reader rather than raw char* arrays, to support a more familiar laspy-like interface.
  • [x] Add writer for COPC data
  • [x] Python bindings
  • [x] JavaScript bindings (not planned, see below)
  • [x] Spatial querying for nodes (given spatial coordinates, retrieve the appropriate Entry object)
  • [ ] Conda and pip packages

Conformity to Spec

This version of copc-lib is pinned to a draft version of COPC respective of the state at COPC.io.

extended stats VLR

User ID Record ID
rock_robotic 10001

We additionally add an extended stats extents VLR to store mean and (population) variance values for each dimension. This VLR can be parsed in the same way as the extents VLR defined by the COPC spec.

struct CopcExtentExtended
{
    double mean; // replaces minimum
    double var; // replaces maximum
}

This VLR is optional to process existing COPC files. If present, mean/variance are set appropriately for each dimension in CopcExtents; if not, CopcExtents will have default values of mean=0 and var=1.

This VLR is only written by the Writer if the flag has_extended_stats is true in CopcConfigWriter::CopcExtents.

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.

Naming Convention

C++

We mostly use Google's Style Guide.

namespace name
{
class ClassName
{
public:
// Default constructor
ClassName() = default;
ClassName(int public_variable, int private_variable, bool private_read_only)
: public_variable(public_variable), private_variable_(private_variable),
private_read_only_(private_read_only){};

int public_variable{};

// Getters and Setters
void PrivateVariable(int private_variable) { private_variable_ = private_variable; }
int PrivateVariable() const { return private_variable_; }
bool PrivateReadOnly() const { return private_read_only_; }

// Any other function
int PrivateVariablePlusOne() const { return private_variable_ + 1; }
int SumPublicAndPrivate() const { return public_variable + private_variable_; }
static std::string ReturnEmptyString() { return {}; }

private:
int private_variable_{};
bool private_read_only_{false};
};
} // namespace name

Python

test_class = ClassName(public_variable=1,private_variable=2,private_read_only=True)

# using pybind .def_readwrite
test_class.public_variable = 4
assert test_class.public_variable == 4

# using pybind .def_property
test_class.private_variable = 5
assert test_class.private_variable == 5

# using pybind .def_property_readonly
assert test_class.private_read_only == True

# using pybind .def
assert test_class.PrivateVariablePlusOne() == 6
assert test_class.SumPublicAndPrivate() == 9

# using pybind .def_static
assert test_class.ReturnEmptyString == ""

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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

copclib-2.2.3.tar.gz (127.3 kB view hashes)

Uploaded Source

Built Distributions

copclib-2.2.3-pp38-pypy38_pp73-win_amd64.whl (903.5 kB view hashes)

Uploaded PyPy Windows x86-64

copclib-2.2.3-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

copclib-2.2.3-pp38-pypy38_pp73-manylinux_2_17_i686.manylinux2014_i686.whl (1.3 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686

copclib-2.2.3-pp38-pypy38_pp73-macosx_10_9_x86_64.whl (837.3 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

copclib-2.2.3-pp37-pypy37_pp73-win_amd64.whl (901.5 kB view hashes)

Uploaded PyPy Windows x86-64

copclib-2.2.3-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

copclib-2.2.3-pp37-pypy37_pp73-manylinux_2_17_i686.manylinux2014_i686.whl (1.3 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686

copclib-2.2.3-pp37-pypy37_pp73-macosx_10_9_x86_64.whl (830.1 kB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

copclib-2.2.3-cp310-cp310-musllinux_1_1_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

copclib-2.2.3-cp310-cp310-musllinux_1_1_i686.whl (1.3 MB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ i686

copclib-2.2.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (725.5 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

copclib-2.2.3-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl (773.1 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686

copclib-2.2.3-cp310-cp310-macosx_10_9_x86_64.whl (474.9 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

copclib-2.2.3-cp39-cp39-win_amd64.whl (592.4 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

copclib-2.2.3-cp39-cp39-win32.whl (545.7 kB view hashes)

Uploaded CPython 3.9 Windows x86

copclib-2.2.3-cp39-cp39-musllinux_1_1_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

copclib-2.2.3-cp39-cp39-musllinux_1_1_i686.whl (1.3 MB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ i686

copclib-2.2.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (725.7 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

copclib-2.2.3-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl (773.7 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686

copclib-2.2.3-cp39-cp39-macosx_10_9_x86_64.whl (474.9 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

copclib-2.2.3-cp38-cp38-win_amd64.whl (603.8 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

copclib-2.2.3-cp38-cp38-win32.whl (545.6 kB view hashes)

Uploaded CPython 3.8 Windows x86

copclib-2.2.3-cp38-cp38-musllinux_1_1_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

copclib-2.2.3-cp38-cp38-musllinux_1_1_i686.whl (1.3 MB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ i686

copclib-2.2.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (725.1 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

copclib-2.2.3-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl (773.1 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686

copclib-2.2.3-cp38-cp38-macosx_10_9_x86_64.whl (475.1 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

copclib-2.2.3-cp37-cp37m-win_amd64.whl (601.8 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

copclib-2.2.3-cp37-cp37m-win32.whl (545.1 kB view hashes)

Uploaded CPython 3.7m Windows x86

copclib-2.2.3-cp37-cp37m-musllinux_1_1_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ x86-64

copclib-2.2.3-cp37-cp37m-musllinux_1_1_i686.whl (1.3 MB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.1+ i686

copclib-2.2.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (733.9 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

copclib-2.2.3-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl (785.4 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ i686

copclib-2.2.3-cp37-cp37m-macosx_10_9_x86_64.whl (468.0 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

copclib-2.2.3-cp36-cp36m-win_amd64.whl (601.8 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

copclib-2.2.3-cp36-cp36m-win32.whl (545.0 kB view hashes)

Uploaded CPython 3.6m Windows x86

copclib-2.2.3-cp36-cp36m-musllinux_1_1_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.6m musllinux: musl 1.1+ x86-64

copclib-2.2.3-cp36-cp36m-musllinux_1_1_i686.whl (1.3 MB view hashes)

Uploaded CPython 3.6m musllinux: musl 1.1+ i686

copclib-2.2.3-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (734.2 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

copclib-2.2.3-cp36-cp36m-manylinux_2_17_i686.manylinux2014_i686.whl (785.4 kB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ i686

copclib-2.2.3-cp36-cp36m-macosx_10_9_x86_64.whl (467.8 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page