I tried to include PCL into my project. I need some methods to process my point cloud like filtering, smoothing, downsampling and triangulation.
Unfortunately I always get the same error when using some function of PCL. For example at the following filter method:
When I debug the method everything works fine (The Writer writes the file and saves the estimated points). But at the end of the method before jumping to the next method I always get an error at MallocTB::Free().
First-chance exception at 0x00007FFB2AB60080 (UE4Editor-Core.dll) in UE4Editor.exe: 0xC0000005: Access violation writing location 0x000000293E868050
Unhandled exception at 0x00007FFB2AB60080 (UE4Editor-Core.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x000000293E868050
I really tried a lot but I don’t know why this error occurs… . It seems that there are some problems between memory handling in UE4 and memory handling in the PCL framework? I would be grateful if someone can help me.
Is it possible that there is a problem with using boost::shared_ptr in UE4? “Ptr” is of this type.
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.
thank you very much for your answer and sorry for my late reply.
Yes, my class derives from AActor and yes, this class is always available. I use UE4.9, VS2013, Boost 1.57 and PCL 1.7.2 (I used the all-in-one-installer from http://unanancyowen.com/?p=1255&lang=en for VS2013, Win64).
And yes I tried to use a reference instead of boost::shared_ptr but that didn’t work. Which problems did appear with your RoR filter? Is it too slow?
If I comment the filter method out my code works well too. Otherwise the filter method works well but at the end of my function I suddenly get that error. I tried other filters too (e.g Voxelgrid) but it’s always the same error.
thanks for your additional infos. I just wanted to let you know that I switched to your Boost and PCL version,
activated the ROR filter again and now I get a similiar exception as you: Unhandled exception at 0x000007FEE757D983 (UE4Editor-Core.dll) in UE4Editor.exe: 0xC0000005: Access violation writing location 0x0000000000000010.
Debugger stops at the end of FMallocTBB::Free method.
In the stack frame I see that the destructor of class Filter and then the dispose method of Boost class sp_counted_impl_p is called before.
I will now try to debug deeper.
As a quick dirty workaround you can declare Ror as global.
Just move the line outside the function:
yes the error arises after the sp_counted_impl.hpp. I just tried to uncomment the “delete x” in the file boost/core/checked_delete.hpp (… dangerous(!) haha…).
So that works but what does it mean for the problem? Unreal wants to delete the pointer again after Boost does it and that’s why we get the access violation error? I can prevent Unreal from doing this only if I declare Ror as a global?
Not so pretty but it works! Thank you very very much! I really spend a lot of time to understand what’s going on here…
Is anyone still interested in cpu based pointcloud ? I can make a basic plugin for you guys.
I was testing the possibilities after reading this thread and it is not too hard to create, draw and update points in ue4
Hi plangton. I’m also interesting using PCL library in UE4. Is it possible to get point cloud data from depth sensor like Kinect v2 and draw and display in UE4 realtime?
If It can be, Can you share your idea or plugin code? thanks you~
I have done that with Kinect but for that it’s the best if you do it with GPU particles or in materials with worldpositionoffset. the reason I am telling this is that Kinect v2 will send you 30 fps and each frame consists of 512424 pixel data this is a massive amount of information to be process all in cpu and better to be shared between cpu and gpu.
So, here are my suggestions
1 - have a plane with 512424 vertices, get each frame as a depth texture, send it to a material that apply the depth value to worldpositionoffset z position and apply that material as a dynamic material to your plane. ( this will set the Z but not the exact x&y for that you need more calculation to get world (x,y,z) from depth texture which is in (u,v,z) basically you will need to calculate x,y using u,v and camera intrinsics
2 - it is mostly like solution one except that you will set everything to a gpu particle. you can adjust it to have exactly 512*424 number of particle and set the position of each separately using the texture. I once saw another thread explaining this solution extensively