google / draco

Draco is a library for compressing and decompressing 3D geometric meshes and point clouds. It is intended to improve the storage and transmission of 3D graphics.
https://google.github.io/draco/
Apache License 2.0
6.51k stars 966 forks source link

how to understand draco::EncoderOptions #925

Open leviskim17 opened 2 years ago

leviskim17 commented 2 years ago

Can somebody help me understand the below function?

I am struggling to understand draco::EncoderOptions This is the function implemented by the former worker. After getting this draco process, the intensity values seem to be different with original value. May I know how to get the original value in cesium side?

        draco::PointCloudBuilder builder;
        draco::EncoderBuffer encoder_buffer;
        draco::PointCloudSequentialEncoder encoder;
        draco::EncoderOptions options = draco::EncoderOptions::CreateDefaultOptions();
    void DPNTSGenerator::finalizePoints()
    {
        const auto point_cloud = builder.Finalize(false);

        options.SetAttributeFloat(point_cloud->GetNamedAttributeId(draco::GeometryAttribute::POSITION), "quantization_bits", 14);
        options.SetAttributeFloat(point_cloud->GetNamedAttributeId(draco::GeometryAttribute::NORMAL), "quantization_bits", 14);
        options.SetAttributeInt(point_cloud->GetNamedAttributeId(draco::GeometryAttribute::COLOR), "quantization_bits", 8);
        options.SetAttributeFloat(intensity_id, "quantization_bits", 14);

        encoder.SetPointCloud(*point_cloud);

        encoder_buffer.Clear();
        const auto status = encoder.Encode(options, &encoder_buffer);
        if (!status.ok())
        {
            // failed to encode
            std::cerr << status << std::endl;
            return;
        }

        const auto& buffer = encoder_buffer;
        writeFeatureTableBinary(buffer.data(), buffer.size());
    }

I have tried to adjust there parameters

        options.SetAttributeFloat(point_cloud->GetNamedAttributeId(draco::GeometryAttribute::POSITION), "quantization_bits", 14);
        options.SetAttributeFloat(point_cloud->GetNamedAttributeId(draco::GeometryAttribute::NORMAL), "quantization_bits", 14);
        options.SetAttributeInt(point_cloud->GetNamedAttributeId(draco::GeometryAttribute::COLOR), "quantization_bits", 8);
        options.SetAttributeFloat(intensity_id, "quantization_bits", 14);

But I can't get satisfactory results.

Is there any mention of the API's comment of SetAttributeFloat?

ondys commented 2 years ago

Can you share the code where you initialize and set the intensity attribute? Btw, quantization bits should be set using SetAttributeInt() method (but it shouldn't really make a difference in this case).