I render a triangulated mesh (polydata) using VTK renderer. I want to get a 3D point cloud of the rendered scene (with respect to the camera).
I found a similar snippet where do the similar thing in the PCL library which uses VTK as its visualisation tool.
I implement the PCL function in my code and I managed to get same results (3D point cloud). However, I found an issue that I don't know where to start to solve:
- For a point that should have valid depth value in the z-buffer, 1 (I believe it is a default set value means NOT a valid point) is returned.
I tried to play with the clippingplane (also known as nearz/farz), but nothing improved.
UPDATE: Issue solved, it was because I forget VTK defined image coordinate differently than the traditional one. In VTK, origin is bottom-left instead of top-left.