Live point cloud visualization plugin

(Jared Madison) #1

I am writing a ParaView version 5.1.2 plugin in C++ to visualize point cloud data produced by a LiDAR sensor. I noticed that Velodyne has an open source ParaView custom application to visualize their LiDAR data called Veloview. I tweaked some of their code to start but I am stuck now.

So far I wrote a reader that takes a pcap file and renders a point cloud that can be played back frame by frame. I also wrote a ParaView source that listens on a port and captures udp packets and after they are captured uses the reader to split them into frames and visualize the PC.

Now I would like to take live udp packets and render the point cloud in real time as each frame is completed.

I am having trouble accomplishing this because of the ParaView plugin structure. Currently, my reader displays a frame when the method RequestData is called. My method looks something like this.

int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector){

vtkPolyData* output = vtkPolyData::GetData(outputVector);
  vtkInformation* info = outputVector->GetInformationObject(0);

  int timestep = 0;

  if (info->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()))
  {
    double timeRequest = info->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
    int length = info->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
  
    timestep = static_cast<int>(floor(timeRequest + 0.5));
  }
  
  this->Open();
  
  // GetFrame returns a vtkSmartPointer<vtkPolyData> that is the frame
  output->ShallowCopy(this->GetFrame(timestep));

  this->Close();

  return 1;
}

The RequestData method is called every time the timestep is updated in the ParaView gui. Then the frame from that timestep is copied into the outputVector.

I am not sure how to implement this with live data because in that circumstance the RequestData method is not called because no timesteps are requested. I saw there is a way to keep RequestData executing by using CONTINUE_EXECUTING() in this way.

request->Set(vtkStreamingDemandDrivenPipeline::CONTINUE_EXECUTING(), 1);

But I do not know if that is supposed to be used to visualize live data.

For now I am interested in simply reading live packets and throwing them away as soon as their frame is rendered. Does anyone know how to achieve this?

(Bastien JACQUET) #2

Hi,

In the code of VeloView (which basically is a bundled ParaView+LidarPlugin), the timesteps of ParaView is changed by the main code, not the Lidar Plugin.
We advice you to start from VeloView code, which is much closer to your goal.
If you really want to start from scratch within ParaView, you need to increment this requested timestep yourself.

Newest version of VeloView (unreleased) uses the same mechanism as ParaView “LiveSource” plugin (available in 5.6+), where the plugin tells ParaView to set a QtTimer that will automatically increment the available and requested timesteps.

request->Set(vtkStreamingDemandDrivenPipeline::CONTINUE_EXECUTING(), 1); relates to another mechanism that will run request Data multiple time, but won’t take care of updating the requested timestep.

Best,
Bastien Jacquet
VeloView project leader