Here’s an example of voxel carving to create 3D point cloud from a set of photographs.
Based on Nghia Ho’s implementation of voxel carving  , I decided to port the voxel carving code, so that I can test out whether my three.cpp could show point cloud correctly.
The 3D photography dataset is obtained from , it provides photographs of a model from numerous point of views, along with camera projection matrices and other intrinsic parameters.
Basically we start by initialising a 3D voxel grids, and start carving by checking if the projected pixels from each camera viewpoint is valid, if it’s valid, we store it, else discard it. Repeat for the entire image set, and the program will output a PLY model file, which you can use a 3D viewer to show the point cloud.
I used my own three.cpp as the viewer.
You can check out the code for Voxel Carving in C++ and OpenCV here: https://github.com/subokita/Sandbox/tree/master/VoxelCarving/VoxelCarving
And the code for my three.cpp viewer can be seen here: https://github.com/subokita/Three.cpp-Rev-2/blob/master/Three.cpp%20Rev.2/examples/Ex_007_PointCloudTest.cpp