[pdal] data type conversion

Andrew Bell andrew.bell.ia at gmail.com
Fri Jul 17 08:41:55 PDT 2015


On Fri, Jul 17, 2015 at 9:56 AM, Clarke, Trevor <tclarke at ball.com> wrote:

> Trying to convert some las to pcd for use with PCL. "pdal translate
> foo.las foo.pcd" yields:
> "PDAL: Unable to fetch data and convert as requested: Red:uint16_t(27136)
> -> unsigned char"
>
> I'm guessing there's some 16-bit data points and PCL can only work on
> 8-bit? Can I create a filter to compress this down to 8-bit?
>

Yes.  You just need to make sure that your values for RGB will fit into an
unsigned char (since that's what's supported on PCL).  Let's say you want
to scale data from uint16_t to uint8_t (unsigned char).  A very simple
filter would essentially look like:

// Not compiled or tested...
void filter(PointView& view)
{
    for (PointId idx = 0; idx < view.size(); ++idx)
    {
        uint16_t r = view.getFieldAs<uint16_t>(Dimension::Id::Red, idx);
        view.setField(Dimension::Id::Red, idx, (r >> 8));
        // Repeat for Green and Blue.
    }
}

You can make a pipeline with your filter that has a LAS reader, your filter
and a PCD writer.  Of course, you can do fancier things than this example.

As an alternative, you can write python and use the programmable filter (
http://www.pdal.io/stages/filters.programmable.html).

Write back if you have more questions.

-- 
Andrew Bell
andrew.bell.ia at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pdal/attachments/20150717/7c303e5c/attachment.html>


More information about the pdal mailing list