# Point Cloud Library in UE4

**URL:** <https://forums.unrealengine.com/t/point-cloud-library-in-ue4/46713>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [November 5, 2015, 3:12pm UTC](https://forums.unrealengine.com/t/point-cloud-library-in-ue4/46713 "2015-11-05T15:12:31Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Cyxx](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Cyxx](https://forums.unrealengine.com/u/Cyxx)\
**Post date:** [November 7, 2015, 7:16pm UTC](https://forums.unrealengine.com/t/point-cloud-library-in-ue4/46713/2 "2015-11-07T19:16:13Z")

</div>

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:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

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:

```auto

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

---

_[View the full topic](https://forums.unrealengine.com/t/point-cloud-library-in-ue4/46713)._
