Hi Mell_D
I setup a small PCL plugin project and tried your code.
Except the Ror filter everything works fine here without exception and the pcd file is written.
From the name “AVoxelGenerator” I guess that you derive from AActor, or?
Is this actor always available? Because all UObjects can be garbage collected:
Which version of PCL, Boost and VStudio do you use?
I used UE4.9, VS2013, Boost 1.59 and the actual PCL code from the repository.
Attached the code from my test class:
PCLFilter.h:
#pragma once
#include "Engine.h"
#include "GameFramework/Actor.h"
#include "PCLFilter.generated.h"
UCLASS()
class AVoxelGenerator : public AActor
{
GENERATED_BODY()
public:
AVoxelGenerator();
void GeneratePointCloud(TArray<FVector4> Voxels);
};
---
PCLFilter.cpp:
#include "PCLPrivatePCH.h"
#include "PCLFilter.h"
#include "AllowWindowsPlatformTypes.h"
#include "pcl/point_types.h"
#include "pcl/filters/radius_outlier_removal.h"
#include "pcl/filters/conditional_removal.h"
#include "pcl/io/pcd_io.h"
#include "HideWindowsPlatformTypes.h"
AVoxelGenerator::AVoxelGenerator()
{
}
void AVoxelGenerator::GeneratePointCloud(TArray<FVector4> Voxels)
{
pcl::PointCloud<pcl::PointXYZI>::Ptr Cloud(new pcl::PointCloud<pcl::PointXYZI>());
pcl::PointCloud<pcl::PointXYZI>::Ptr Cloud_filtered(new pcl::PointCloud<pcl::PointXYZI>());
Cloud->width = Voxels.Num();
Cloud->height = 1;
Cloud->is_dense = false;
Cloud->points.resize(Voxels.Num());
for (int i = 0; i < Voxels.Num(); i++)
{
Cloud->points*.x = Voxels*.X;
Cloud->points*.y = Voxels*.Y;
Cloud->points*.z = Voxels*.Z;
Cloud->points*.intensity = Voxels*.W;
}
// ...
pcl::PCDWriter Writer;
Writer.write<pcl::PointXYZI>("d:/Table_inliers.pcd", *Cloud, false);
//Writer.write<pcl::PointXYZI>("d:/Table_inliers.pcd", *Cloud_filtered, false);
}
Regarding your boost::shared_ptr:
Did you try using a reference instead? Like:
pcl::PointCloud<pcl::PointXYZI> Cloud;
Best regards
Heiko