martinruenz / co-fusion

Co-Fusion: Real-time Segmentation, Tracking and Fusion of Multiple Objects
http://visual.cs.ucl.ac.uk/pubs/cofusion/index.html
GNU General Public License v3.0
501 stars 131 forks source link

Extract only valid surfels from GPU to CPU #5

Closed BruceCanovas closed 6 years ago

BruceCanovas commented 6 years ago

Hi,

I am actually using your solution as part of ROS node and was wondering if there was a way to get directly from the GPU only the valid surfels. Because model->downloadMap() extracts even the invalid surfels and so as to publish a point cloud it would be faster to loop only through valid ones. Or do you have a hint about what can I change in the source code to make it possible?

Thank you

martinruenz commented 6 years ago

You are right, at the moment the easiest solution is to use downloadMap and then to filter on the CPU, see: https://github.com/martinruenz/co-fusion/blob/457c3a0c0c0fb1b40194790d8814f001397e3130/Core/CoFusion.cpp#L703

Alternatively you could write an OpenGL-based filter using Transform Feedback or similar.

BruceCanovas commented 6 years ago

Thank you, I ended up using transform feedback and an atomic counter to get the number of valid points. It is maybe not the smartest way but it seems to make the trick.

martinruenz commented 6 years ago

Cool, if this works nicely a pull request would be welcome! :)

BruceCanovas commented 6 years ago

Ok I will just take time to see how it works as I am quit new with github and clean a bit what I've added before.