Please clarify what is "cell" and how you define porosity on it.
It is a Voronoi cell around the capsule. I define porosity as the fraction of the cell occupied by the fluid.
I have more or less the same problem reported in this discussion of two years ago:
I want to evaluate the radial porosity profile of a cylindrical packed bed of capsules.
You can try with woo.triangulated.porosity which works on box-shaped domain. The inernal code is here: https://github.com/woodem/woo/blob/master/pkg/dem/Funcs.cpp#L702 . It ignores orientation of Capsules (or Ellipsoids). Another approach would be to use some other tool to analyze the VTK (or STL) file, since the triangulation defines solid/void areas.