Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[readers.ept] resolution option strange behaviour #3139

Closed
gui2dev opened this issue Jun 19, 2020 · 8 comments · Fixed by #3140
Closed

[readers.ept] resolution option strange behaviour #3139

gui2dev opened this issue Jun 19, 2020 · 8 comments · Fixed by #3140

Comments

@gui2dev
Copy link
Contributor

gui2dev commented Jun 19, 2020

Hi,

The resolution option for readers.ept seems to behave in a strange way :

This program :

main.cpp

#include <pdal/PointTable.hpp>
#include <pdal/PointView.hpp>
#include <pdal/StageFactory.hpp>
#include <pdal/PluginManager.hpp>
#include <pdal/io/BufferReader.hpp>
#include <pdal/Options.hpp>
#include <pdal/filters/StreamCallbackFilter.hpp>

  using namespace pdal;

int main(int argc, char* argv[])
{
  std::unique_ptr<StageFactory> factory(new StageFactory);
  
Options readOpts;
  readOpts.add(Option("filename", "path/to/my/ept.json"));
  readOpts.add(Option("resolution", 4.0));
  readOpts.add(Option("threads", 64));

  Stage* reader(factory->createStage("readers.ept"));
  reader->addOptions(readOpts);

  StreamCallbackFilter f;

  point_count_t count(0);

  auto convertOne = [&](PointRef& point) {
    count++;
    return true;
  };

  f.setCallback(convertOne);
  f.setInput(*reader);

  Options writeOpts;
  writeOpts.add(Option("filename", "output.laz"));

  Stage* writer(factory->createStage("writers.las"));
  writer->addOptions(writeOpts);
  writer->setInput(f);

  FixedPointTable table(100);
  writer->prepare(table);
  writer->execute(table);

  cout << count << endl;
  return 0;
}

Returns 196 929 for a 112 774 395 points point cloud (and outputfile.laz has 196 929 points).
Returns 1 071 500 117 for a 17 642 072 775 points point cloud (and outputfile.laz has 1 071 500 117 points).

Using a pipeline :
pipeline.json

[
    {
        "type": "readers.ept",
        "filename": "some/url/to/ept.json",
        "resolution": 4.0
    },
    {
        "type": "writers.las",
        "filename": "outputfile.laz"
    }
]

pdal pipeline pipeline.json

outputfile.laz has 44 734 points for a 112 774 395 points point cloud.
outputfile.laz has 359 268 for a 17 642 072 775 points point cloud.

@abellgithub
Copy link
Contributor

You're not reading the full resolution, so you wouldn't expect the count to be the same.

@gui2dev
Copy link
Contributor Author

gui2dev commented Jun 19, 2020

@abellgithub, my issue is that when trying not to read the full resolution using C++ API by setting the right option, it does nonetheless.

@gui2dev
Copy link
Contributor Author

gui2dev commented Jun 19, 2020

@abellgithub, the qi.m_pointCount is always the total number of point, regardless of the resolution option value.
To dig deeper, my C++ example seems to work on a small point cloud (112 million points) but not on a larger point cloud (17 billion).
Could it be a 32bits issue ? (#3121)

@abellgithub
Copy link
Contributor

abellgithub commented Jun 19, 2020 via email

@gui2dev
Copy link
Contributor Author

gui2dev commented Jun 19, 2020

@abellgithub, it's not the issue.
The issue is that the resolution option is not taken into account in my C++ example if the point cloud size is larger than 32 bits.

@abellgithub
Copy link
Contributor

abellgithub commented Jun 19, 2020 via email

@gui2dev
Copy link
Contributor Author

gui2dev commented Jun 19, 2020

@abellgithub, I updated my issue.

@gui2dev gui2dev changed the title Using readers.ept with filters.streamcallback does not accept "resolution" option [readers.ept] resolution option strange behaviour Jun 19, 2020
@gui2dev
Copy link
Contributor Author

gui2dev commented Jun 20, 2020

@abellgithub, @connormanning, I found the issue.
It's related with how m_depthEnd is managed in ìnitialize()
If you do a preview() it'll go through initialize() and if you query a resolution, m_depthEnd will be incremented.
Then if you execute the same reader stage, it'll got through initialize() once again and m_depthEnd will be incremented again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants