weigao95 / surfelwarp

SurfelWarp: Efficient Non-Volumetric Dynamic Reconstruction
https://sites.google.com/view/surfelwarp/home
BSD 3-Clause "New" or "Revised" License
276 stars 71 forks source link

Running multiple instances at the same time #71

Closed mihaibujanca closed 3 years ago

mihaibujanca commented 3 years ago

Hi @weigao95,

I am trying to reconstruct multiple objects at the same time by running multiple instances of surfelwarp.

I've encountered two problems so far. Simply creating another instace of surfelwarp will cause a failure upon trying to process a frame in the instance I first declared (e.g adding a SurfelWarpSerial fusion2 in main.cpp will cause this). Perhaps this has to do with the cuda streams being coded in explicitly?

Simplified code:

SurfelWarpSerial fusion fusion2; // No failure when just declaring
// fusion.ProcessFirstFrame();  // This fails
fusion2.ProcessFirstFrame(); //This doesn't fail

Stack:

/surfelwarp/core/warp_solver/DensityForegroundJacobianResidual.cu:192: There is no foreground pixel
/surfelwarp/core/warp_solver/DensityForegroundJacobianResidual.cu:192: There is no foreground pixel
/surfelwarp/core/warp_solver/DensityForegroundJacobianResidual.cu:192: There is no foreground pixel
/surfelwarp/core/warp_solver/DensityForegroundJacobianResidual.cu:192: There is no foreground pixel
/surfelwarp/core/geometry/SurfelFusionHandler.cpp:91: Check failed: !containsNaN(m_fusion_geometry.live_vertex_confid.ArrayView()) 

The second issue has to do with threading. Suppose I were able to run the two systems sequentially and the above issue were solved. Calling Process on each of the systems would presumably be blocking due to CPU-bound code in the middle - so ideally since the two systems would be processing separate objects I'd them to work in parallel. Here I am getting an OpenGL error, presumably because the OpenGL context is bound to the thread.

Any suggestions on how I might get around these problems would be hugely appreciated.

Thanks

weigao95 commented 3 years ago

Sorry that I am working on my thesis these days. I believe only one instance can be constructed simultaneously due to the __share__ memory.