google / google/draco

I Can not make Encoding Point Cloud to Buffer to work

Open
#1,003 0 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
C++
Stars
7.5k
Forks
1.1k
Avg merge
47m
Merged PRs (30d)
1

Description

I was checking code of the coded test so I made a very simple test project triyng to encode a point cloud, but when I print the number of encoded points I allways get zero, i don´t know what am I doing wreong or if there is another way to test if the encoding is going well.

here is my code:

#include
#include

#include "draco/compression/encode.h"
#include "draco/point_cloud/point_cloud.h"
#include "draco/io/point_cloud_io.h" //to encode to buffer
#include "draco/point_cloud/point_cloud_builder.h"

int main(int argc, char** argv) {

//Create Point Cloud
draco::PointCloudBuilder pc_builder;

constexpr int kNumPoints = 1000;
pc_builder.Start(kNumPoints);

// Add position attribute.
const int32_t pos_att_id = pc_builder.AddAttribute(
draco::GeometryAttribute::POSITION, 3, draco::DT_FLOAT32);

// Initialize the attribute values.
for (draco::PointIndex i(0); i < kNumPoints; ++i) {
const float pos_coord = static_cast(i.value());
pc_builder.SetAttributeValueForPoint(
pos_att_id, i,
draco::Vector3f(pos_coord, -pos_coord, pos_coord).data());
}

std::unique_ptr geometry = pc_builder.Finalize(true);



// Ensure the logged number of encoded points and faces matches the number
// we get from the decoder.
int32_t encoding_method = draco::POINT_CLOUD_KD_TREE_ENCODING;

draco::Encoder encoder;

encoder.SetAttributeQuantization(draco::GeometryAttribute::POSITION, 10);

encoder.SetEncodingMethod(encoding_method);

encoder.SetTrackEncodedProperties(true);
encoder.SetSpeedOptions(4,4);

draco::EncoderBuffer buffer;
draco::Status status = encoder.EncodePointCloudToBuffer(*geometry, &buffer);

std::cout << "Number of points in the cloud: " << geometry->num_points();
std::cout <<" - Encoded points: "<< encoder.num_encoded_points();
std::cout << " buffer.data " << buffer.data() << "buffer.size" << buffer.size();


return 0;
}

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.