Estimating box size from the contents
This is known as "3D Bin Packing Problem" in literature.

https://en.wikipedia.org/wiki/Bin_packing_problem

Since this is NP-Hard; Some of the approaches  are :


Heuristics : https://www.researchgate.net/publication/226249396_A_New_Heuristic_Algorithm_for_the_3D_Bin_Packing_Problem
Deep Reinforcement Learning : https://arxiv.org/abs/1708.05930
Ensemble : https://medium.com/@alitech_2017/alibabas-ai-solution-for-the-3d-bin-packing-problem-3ce66d730ecc