1 Introduction

Object counting is a fundamental stage in numerous industrial inspection pipelines, in which manufactured items or harvested products are inspected for quality and quantity. While visual counting is a well-studied problem, most of the existing methods in the literature do not apply in this context. These methods are often specialized for specific domains such as biomedical imaging [1], or traffic [2] and wildlife [3] monitoring, and general methods [4,5,6,7,8] only attempt to count objects that are directly visible in the input images, such as apples spread across a table or people in a crowd.

However, industrial inspection often involves objects that are stacked on top of each other, as in Fig. 1. In that case, only a subset of them is visible, making counting much more challenging for computer vision models and humans alike, as demonstrated in our experiments. However, a method to accurately and reliably count these objects from images would have significant applications in industrial and agricultural settings, where precise quantification of items would enhance operational efficiency and logistics.

In order to develop a method that can overcome the above-mentioned challenges, we will need to infer the presence of hidden objects from only limited information. As such, detecting visible object features only is not sufficient and we will also need to reason about hidden ones through contextual understanding of stacking patterns, object orientations, and irregular arrangements, making traditional counting approaches insufficient.

Our method relies on a key insight: the percentage of space occupied by objects within the container, which we will refer to as the occupancy ratio, can be accurately inferred from a depth map computed by a monocular depth estimator from a view in which objects of interest are clearly visible. This view is often one where the container is seen roughly from above, without having to be strictly vertical. To exploit this observation, we break down the problem into two complementary tasks: estimating the 3D geometry of the object and the stack, and estimating the occupancy ratio within this volume, as depicted by Fig. 2. This enables us to estimate the total count through a combination of geometric reconstruction for volume estimation and deep learning-based depth analysis for occupancy prediction.

In our experiments, we evaluate 3DC on a broad set of real-world on a broad set of real-world and synthetic scenes. The real-world benchmark spans a variety of industrial and retail settings, with objects stacked in containers or kept in their original packaging, as illustrated in Fig. 1. To systematically analyze the behavior and limitations of our approach, we further introduce a large-scale synthetic dataset [9] with precisely controlled configurations and ground-truth counts. Both this dataset and implementation are already released and can be found at https://cvlab-epfl.github.io/projects/stacks.html.

Fig. 1
Fig. 1
Full size image

3D Counting (3DC). We estimate both the total volume occupied by the stack and the fraction of this volume taken up by the objects from multiple views of objects to be counted. Combining these estimates yields the total number of objects

Fig. 2
Fig. 2
Full size image

3DC pipeline. We decompose the counting task into estimating the volume of the objects to be counted and then estimating the occupancy ratio within that volume. The first is done on the basis of geometry reconstructed from segmentations in multiple images. The second uses as input a depth-map computed by a monocular depth estimator and regresses an occupancy ratio from it

This paper extends our earlier conference paper [10] to further explore the applicability of our counting method to industrial inspection, a setting in which manufactured objects are often too light or too heavy to be reliably counted using a scale. First, we put our approach on a more solid theoretical footing by defining counts as volumetric integrals, which provides additional theoretical insights on the correctness of our approach and the assumptions we make. Second, we extend our dataset with an additional 858 images from 13 scenes captured in challenging industrial environments, increasing the diversity of our benchmark. Third, we add a more thorough evaluation of the volume estimation component of our pipeline. With this addition, we can now separately assess the effectiveness of our method at volume occupancy estimation, volume measurement, and complete count estimation.

In short, our contributions are as follows:

  • A full end-to-end framework for 3D counting of overlapping, stacked objects, addressing a previously unexplored and challenging computer vision problem.

  • A formula to estimate the count of stacked objects, along with its formal definition and derivation.

  • A network that predicts the occupancy ratio, a key conceptual contribution and serving as a central element of our architecture.

  • A large-scale 3D Counting Dataset with 400,000 images generated from 14,000 physically simulated and rendered scenes, providing accurate ground-truth object counts and programmatically computed volume occupancy.

  • A complementary real-world benchmark comprising 3229 images from 58 scenes, acquired with reliable camera poses and manually verified total counts.

  • A human performance study based on 1,485 annotations on real images, capturing estimates from 33 participants.

  • An in-depth evaluation of our predicted volume measurements, volume occupancy estimations, and total counts.

In particular, the latter demonstrates that this task is intrinsically difficult and that even human performance is limited. This suggests that learning to predict stacked counts directly from images in a single step may be impractical and that our strategy of decomposing the problem into simpler subproblems is key to achieving strong results, as shown in Sect. 4.

2 Related work

Previous works in visual counting seek to estimate how many instances of a particular object are present in a scene. The majority of existing methods focus on visible objects observed in a single image. In contrast, our work addresses the more demanding setting where a substantial fraction of the objects to be counted are fully or partially hidden from view. We review these relevant works below.

Single-View Counting Recent single-view counting techniques often train a model tailored to one target class, for example crowds [11,12,13,14,15,16,17,18], cars [2], or penguins [3]. Such approaches have been successfully applied in a wide range of domains [19], including medical imaging for counting cells or other anatomical structures [20] and remote sensing for trees or buildings [21]. They tackle challenges like scale variation, perspective distortions, and partial occlusions by learning robust feature representations [22], predicting density maps [23], or exploiting multi-scale information [24]. Beyond single-class settings, class-agnostic counting [8, 25,26,27] allows counting arbitrary categories at test time from a few support examples [28], a handful of bounding boxes [6], or even just a class name [5, 29,30,31]. Similar to these class-agnostic approaches, our method is not tied to particular object categories and can generalize across types. However, almost all of these methods assume that the instances are visible. The closest work to ours is [32], which leverages LiDAR to infer counts of occluded objects on retail shelves for a fixed set of beverage categories with known volumes, such as “Coca-Cola 20oz bottle” or “milk carton”. In contrast, our approach does not rely on LiDAR and is applicable to a broader variety of scenes and object types.

Multi-View Counting Methods that operate on multiple views typically aim to improve counting accuracy by aggregating information across camera viewpoints. A common strategy is to project feature maps onto a shared ground plane to obtain accurate density maps for crowd counting [33, 34] or segmentation maps for fruit counting [35]. Despite using multiple views, these approaches still presuppose that each object is visible in at least one camera and usually target a specific object class, which limits their applicability in more complex environments such as industrial inspection. Our work instead focuses on the largely unexplored challenge of estimating counts for heavily occluded objects, while placing no constraints on their category or geometry.

3 Method

Estimating the total number \(\mathcal {N}\) of objects in a container from 2D images alone represents a fundamental challenge in industrial inspection, one that remains difficult even for human operators and has not been addressed by prior computer vision methods. The core principle underlying our method is that, despite our inability to precisely reconstruct the 3D configuration of all occluded objects at the bottom of the container, the occupancy ratio can still be reliably inferred from a single image when a sufficient number of objects are visible. This observation is particularly relevant in industrial settings where containers are typically viewed from above, providing satisfying visibility of the top layers.

This section begins by formalizing the stack counting problem in Sect. 3.1, then we mathematically derive the stack counting formula in Sect. 3.2. We describe our occupancy ratio estimation network in Sect. 3.3, and finally present our volume estimation algorithm in Sect. 3.4.

3.1 Problem statement

Task setting Specifically, the task of multi-view stack counting takes as input a set of images \(\{I_i\}_{i=1}^{N_I}\) and outputs a single scalar \(\mathcal {N}\) representing the total count. We first localize the region of interest by segmenting the objects \(S_{o}\) and their container \(S_{c}\) in an initial frame, and leverage SAM2 [36] to propagate these segmentations as \(S_{o,f}\) and \(S_{c,f}\) across all subsequent frames f, enabling automatic identification of the frame with the best visibility of the objects. Finally, in non-industrial applications where the volume of a single object \(V_o\) may not be known, it is estimated with the method of Sec. 3.4 from a separate set of images.

Assumptions We make two key assumptions: objects are stacked uniformly in bulk and are approximately identical in size and shape. Additionally, we require that a sufficient number of objects remain partially visible, enabling reliable estimation of the occupancy ratio \(\gamma \) from images.

Applicability These assumptions are satisfied in the real-world industrial scenes shown in  Fig. 1 and are sufficiently general to apply across diverse industrial inspection contexts. In retail and logistics, our approach enables automated inventory auditing by accurately counting stacked items without manual intervention, streamlining restocking operations and reducing manual labor. For manufacturing quality assurance, our method ensures that production batches contain the correct number of components before shipping, preventing costly discrepancies and improving supply chain reliability. Beyond counting, the 3D scene understanding provided by our method supports autonomous robotic systems performing pick-and-place operations in industrial environments containing such large quantities of objects.

3.2 Counting as integration

Given a stack of approximately identical objects o (Fig. 3), let the volume of a single one be \(V_o\). Let \(\mathcal {C}\) be a container holding the total volume \(\mathcal {V}\) spanned by all the objects, which we take to be the convex hull formed by the set of all stacked objects. One could try estimating the number of objects as \(\mathcal {N} = \mathcal {V} / V_o\), the ratio of the total volume to the volume of a single object. However, this would be too large in general because the container is rarely completely filled. In most cases, there are substantial gaps between the stacked objects, especially in industrial bulk handling scenarios where items fall from a conveyor belt into a shipping box or truck. Thus, \(\mathcal {V}\) comprises the volumes of all objects plus the gaps between them, and we need a more sophisticated analysis.

Fig. 3
Fig. 3
Full size image

Shape-dependent volume occupancy. We show a slice of the stacked objects for varying shapes. Different shapes yield different configurations and the fraction of space occupied by the gaps between objects varies. This is reflected in the images, where deeper layers remain visible for low \(\gamma \) values

Let \(\mathbbm {1}(x, y, z)\) be the indicator function that denotes the presence or absence of an object at a 3D point (x, y, z). The volume truly occupied by the union of all objects can be written as

$$\begin{aligned} \iiint _{\mathcal {C}} \mathbbm {1}(x,y,z) \, dx\,dy\,dz \le \mathcal {V} \; . \end{aligned}$$
(1)

It is naturally smaller than \( \mathcal {V}\) due to the gaps between objects. The total number of objects \(\mathcal {N}\) can then be obtained by dividing it by \(V_o\), yielding

$$\begin{aligned} \mathcal {N} = \frac{1}{V_o}\iiint _{\mathcal {C}} \mathbbm {1}(x,y,z) \, dx\,dy\,dz \; . \end{aligned}$$
(2)

Unfortunately, there is no easy way to evaluate the volume integral, especially when the objects are stacked and those at the bottom cannot be seen. Instead, we introduce a quantity that can be evaluated from images, the volume occupancy ratio

$$\begin{aligned} \gamma = \frac{1}{\mathcal {V}}\iiint _{\mathcal {C}} \mathbbm {1}(x,y,z) \, dx\,dy\,dz \; , \end{aligned}$$
(3)

which is the ratio of the volume taken up by the objects to the total volume. In this work, we assume \(\gamma \) to be roughly constant across \(\mathcal {V}\). While this is not strictly true, local fluctuations tend to average in sufficiently large containers and our experiments confirm this to be the case. In the remainder of the paper, we will show that under this assumption \(\gamma \), unlike the volume of Eq. 2, can be estimated from the appearance of the top of the stack as seen in the images.

Finally, combining Eq. (2) and eq. (3) yields

$$\begin{aligned} \mathcal {N} = \frac{\gamma \mathcal {V} }{V_o} \; , \end{aligned}$$
(4)

which means that \(\gamma \) and \(\mathcal {V}\) can be estimated independently, as discussed in the following sections.

3.3 Estimating the Volume Occupancy Ratio \(\gamma \)

Central to our approach is estimating the occupancy volume ratio \(\gamma \) of Eq. 4 from a single image where enough target objects are visible. This image is typically taken to be the top-down view, though this is not strictly required.

Concretely, we seek to learn a function \(\Phi : \mathcal {D} \rightarrow \gamma \) that takes as input a depth map and outputs an occupancy ratio \(\gamma \in [0,1]\), i.e., the percentage of occupied volume. \(\Phi \) captures how depth maps correlate with the occupancy ratio: when deeper layers of the stack are still visible, larger gaps exist and the occupied volume fraction is lower. This dependency is agnostic to the precise object shape and should generalize to unseen geometries, as demonstrated in our experiments.

Network Architecture We implement \(\Phi \) with an encoder architecture that first extracts rich image features and then maps them to our target \(\gamma \). For the encoder pretraining, we rely on DinoV2 [37], a foundation model trained on diverse real-world imagery to improve generalization and speed convergence. To collapse feature maps into a single scalar for the whole image, we stack convolutional layers with ReLU activations to progressively reduce resolution, shrinking the encoded feature map to one pixel with 64 channels, and use a final linear layer to predict the scalar output. Further architectural details are provided in the supplementary material.

Fig. 4
Fig. 4
Full size image

Dataset samples. We visualize generated scenes in ascending order of occupancy ratio, with ground-truth depth maps

Training Data For training \(\Phi \), we minimize the squared error between predicted and ground-truth occupancy ratios. Because no suitable dataset exists, we synthesize one comprising 400,000 images across 14,000 scenes with varied objects and containers. Figure 4 depicts some examples from our released dataset.

To generate it, we employed the ABC dataset [38] that features a large variety of computer-assisted design (CAD) models. We discard meshes that are not watertight or have several connected components, and rescale remaining objects to fit into a cube of side 0.05. Then, we initialized a virtual 3D scene with a container, and used a physics-based simulator to drop an initial batch of 100 identical objects in that box. This step was repeated a random number of times or until the box was full and the union of objects reached the space above the box after the physical simulation has converged. In each scene, the container is given a random shape and scale. Some scenes were also generated without any container where objects are directly stacked on the floor, and some scenes were generated with boxes that are partially full, as is often the case in industrial inspection (Fig. 5).

After the physical simulation completed, we analytically computed the occupancy ratio and the total number of objects in the container. For each object and container, we randomly assigned a realistic material that could be metallic, wood, or plastic. Some scenes also assigned a different material for each individual object. In the last stage, we used a ray-tracing engine to render multiple realistic images of the container and objects seen from several different angles to allow 3D reconstruction, as shown in Fig. 6. Importantly, we use ray tracing such that the bottom of the boxes appears darker due to ambient occlusion.

This is repeated for over 14,000 scenes, and we set aside a subset of 100 scenes to use as a test set of shapes unseen during training. We generate a scene with a unit-cube container to reliably measure the ground truth \(\gamma \) for each one of the 4800 shapes used, as well as two additional scenes with random containers. With this dataset, we are able to not only to train \(\Phi \) on the top view, but also to run our complete pipeline on the multi-view images in order to measure the accuracy of our count estimate \(\mathcal {N}_{est}\), as performed in Sect. 4. While our model is trained on depth maps produced by the depth estimator, our dataset also includes ground-truth depth maps, which we employ in an ablation study in our experiments to assess the requirement of accurate depth maps of our method. Additional statistics that highlight the diversity of the proposed dataset are reported in Fig. 14 of our supplementary.

Inference When applying our method on real data, we must pick which image to feed the \(\gamma \)-network, referred to as the key view. To match training conditions, this view should resemble the depth maps seen during training, as illustrated in  Fig. 5. We automatically choose the view with the largest object segmentation, crop to the masked region, and compute depth with Depth Anything V2 [39]. We also train \(\Phi \) on those predicted depth maps instead of synthetic ground-truth depth to further reduce the domain gap, as shown in our experiments.

Fig. 5
Fig. 5
Full size image

Reducing the domain gap. Instead of estimating the occupancy ratio \(\gamma \) from synthetic (top) and real images (bottom) (a), we identify a key view (b) and train a network to predict \(\gamma \) from their depth maps (c), which are indistinguishable. Top row: synthetic, \(\gamma _{gt} = 62.4\%\). Bottom row: chocolates, \(\gamma _{est} = 53.5\%\), \(\mathcal {N}_{est} = 119\), \(\mathcal {N}_{gt} = 131\)

3.4 Estimating the Total Volume \(\mathcal {V}\)

Fig. 6
Fig. 6
Full size image

Multi-view images. We generate 30 views from arbitrary angles for each of the scenes in our large-scale synthetic dataset

After estimating the occupancy ratio \(\gamma \) as described above, we still require the total stack volume \(\mathcal {V}\) to derive the object count from Eq. 4, and the unit volume \(V_o\) if it is unknown. If cameras are uncalibrated, we run COLMAP [40] to recover their poses and rescale them with a real-world reference. In industrial scenarios with fixed camera setups known a priori, simpler methods could be used.

Volume estimation \(\mathcal {V}_{est}\) from multiple images is well understood. In our implementation, we begin with segmented images and retain only the container and objects by adding the mask as an alpha channel. Next, we optimize 3D Gaussian Splats [41] from these images so the reconstruction includes only the container and objects. To measure the volume enclosed by the splats, we adapt the voxel carving algorithm. We initialize a voxel grid from the gaussian bounding box. Given the masks produced earlier and depth maps rendered from 3DGS, a voxel is removed if its projection in any view lies outside the mask or if its projected depth is smaller than the reconstructed depth. This procedure recovers objects and their containers, including partially filled boxes.

To remove the container from the reconstruction, we estimate its thickness t and erode the voxels on all sides except the top by t, thereby refining the estimated volume to represent only the contents. The value of t is predicted by an additional decoder \(\Psi \) that takes the same encoded image features as our previous network \(\Phi \) in Sect. 3.3. To keep this prediction scale independent and predictable from 2D images alone, we express thickness as a ratio of the container’s size. We supervise \(\Psi \) with ground-truth thickness from our dataset and at inference we average the outputs of \(\Psi \) over all images. Combined, these algorithms yield a good estimate of the volume \(\mathcal {V}\) spanned by the stacked objects.

Unit volume v . For the majority of industrial inspection settings, the unit volume v of Eq. 4 is known exactly because the object has been manufactured to a precise specification, v can be computed from the simple geometry of the objects, or v can be obtained from existing reference data, particularly for food items. When the unit volume of an object v is not readily available, we estimate its value using the method described above from a set of images of a template object. This task is made easier by the absence of a container, and this is shape but not scene specific. For a new shape, the object is selected in a single frame and we can then use SAM2 [36] to generate a segmentation on all frames at once. The unit volume v computed this way can then be used across all scenes containing this object.

4 Experiments

We assess our method in three ways: measuring overall 3D counting accuracy in Sect. 4.2, occupancy ratio estimation in Sect. 4.3, and volume estimation in Sect. 4.4. First, we use 100 scenes with physically simulated shapes from the ABC dataset [38]. Those scenes were isolated after generation and were not seen while training the occupancy ratio network. Another dataset consists of 2381 real images covering 45 scenes captured with a regular smartphone RGB camera without extra sensors. These captures provide multiple views around stacks of objects in containers, lying flat on a table, or still enclosed in packaging. Ground-truth counts are obtained manually for scenes below 500, or inferred from weight for larger counts. Finally, Figs. 7, 8 offers intermediate results to build intuition about our method’s behavior, with more qualitative examples in Figs. 7 and 1.

Table 1 Counting evaluation on 100 synthetic scenes
Table 2 Counting evaluation on real-world scenes
Table 3 Occupancy ratio estimation

4.1 Metrics

Several metrics are used to assess the accuracy of object counting and occupancy ratio estimation. Counts vary significantly across scenes, ranging from 19 to 20063. Consequently, the Mean Absolute Error (MAE), defined as \(\text {MAE} = \frac{1}{n} \sum _{i=1}^n |y_i - \hat{y}_i|\) with \( y_i \) the ground truth count and \( \hat{y}_i \) the prediction, tends to emphasize scenes with high counts. To address this, we also report normalized metrics. We report the Normalized Absolute Error (NAE), Squared Relative Error (SRE), and Symmetric Mean Absolute Percentage Error (sMAPE), which scale errors relative to the ground truth. The NAE provides a measure of absolute error normalized by the total ground truth count across scenes, SRE highlights larger errors and penalizes significant deviations in high-count scenes, and sMAPE offers a normalized percentage error.

The exact formulas for the metrics used in Sect. 4 are provided below. The NAE and SRE are defined as:

$$\begin{aligned} \text {NAE}&= \frac{\sum _{i=1}^n |y_i - \hat{y}_i|}{\sum _{i=1}^n y_i}, \hspace{1em} \text {SRE} = \frac{\sum _{i=1}^n (y_i - \hat{y}_i)^2}{\sum _{i=1}^n y_i^2} \; . \end{aligned}$$

The Symmetric Mean Absolute Percentage Error (sMAPE) can be considered a normalized percentage error. It is expressed as follows:

$$ \text {sMAPE} = \frac{100\%}{n} \sum _{i=1}^n \frac{|y_i - \hat{y}_i|}{(y_i + \hat{y}_i) / 2}, $$

The formula of sMAPE ensures that errors are scaled symmetrically between the prediction and ground truth counts. Finally, the coefficient of determination, \( R^2 \), measures the proportion of variance in the ground-truth occupancy ratio \(\gamma \) explained by our predictions

$$ R^2 = 1 - \frac{\sum _{i=1}^n (y_i - \hat{y}_i)^2}{\sum _{i=1}^n (y_i - \overline{y})^2}, $$

where \( \overline{y} \) is the mean of the ground truth counts. High values of \( R^2 \) indicate strong agreement between predictions and ground-truth values.

4.2 Counting Evaluation

Fig. 7
Fig. 7
Full size image

Additional qualitative results

Fig. 8
Fig. 8
Full size image

Intermediate results. From images (a), we find the key viewpoint and compute its depth (b) to estimate the occupancy ratio \(\gamma \). Using the unit shape previously reconstructed from images of a template (c), and the overall reconstruction (d), we deduce the final count. (Pasta: \(\gamma _{est}=30.5\%\), \(N_{est}=509\), \(N_{gt}=588\). Bricks: \(\gamma _{est}=31.8\%\), \(N_{est}=73\), \(N_{gt}=100\). Crosses: \(\gamma _{est}=29.6\%\), \(N_{est}=88\), \(N_{gt}=116\))

To the best of our knowledge, there is no previous work on counting from multiple images that does not either assume all objects are visible or require additional sensors such as LiDARs. Therefore, we compare 3DC against BMNet+ [7]. This method predicts a density map over all pixels of an image and the estimated count is then inferred by summing over all pixels. We also compare against a combination of SAM [42] and CLIP [43], where SAM generates many masks from an input image and CLIP uses negative and positive text prompts to identify masks for the object of interest. Finally, the total count is taken as the number of these masks. We compare these two baselines against our method in Tables 1 and 2.

Early in our study, we attempted to directly predict object count from images. For this, we trained networks coined ViT+H and CNN, and we report their results in Tables 1 and 2. These models perform poorly, especially on the real-world dataset, which prompted us to decompose the problem into occupancy and volume estimation.

Next, we evaluated how well humans perform on this counting task. To do so, we organized a contest and asked participants to guess counts on the 45 real scenes. The contest registered 1485 guesses from 33 participants. We thus define the Human baseline as the average of participant error metrics, and Human-Vote as the error of the average guess across participants. Note that this second baseline should be stronger as participant errors tend to cancel out, which we observe in Tab. 2. However, results remain much worse than our approach. Interestingly, participants who spent more time did not perform better than their peers, highlighting the difficulty of this task. When asked about their method, most participants reported counting objects along each axis and multiplying, which proved ineffective.

We also experimented with LlamaVision 3.2 11B, a Large Language and Vision Model, on our counting task. While it described object appearance and scene composition well, its count estimates were completely off as shown in Tab. 2.

Overall, our approach beats all baselines, providing the first method to estimate stack counts with reasonable accuracy. Still, we note that performance remains better on synthetic data than on our real benchmark, likely due to the greater complexity of real scenes that often contain thousands of objects and are harder for volume estimation.

4.3 Occupancy Ratio Evaluation

In this section, we now focus on evaluation of the occupancy ratio network alone. Since there is little work on occupancy ratio estimation, we implemented additional baselines to gain insights into our approach.

Because we assume that the depth map contains enough information to predict the occupancy ratio, we define a first baseline we call DepthExtrapolated. From the top view of the container, we compute the maximal depth using a monocular depth estimator and use it to normalize the depth map. Finally, we average the resulting values of the K pixels, yielding the volume fraction estimate

$$ \gamma _{est}^{norm} = \frac{1}{K} \sum \frac{d_i}{d_{max}} \;. $$

However, this first baseline tends to predict values lower than expected. Therefore, we defined a second one we dubbed DepthCorrected, which uses linear regression to correct \(\gamma _{est}^{norm}\) into a new estimate \(\gamma _{est}^{corrected}\). This models the observation that depth maps with high variance tend to correspond to low occupancy ratios. We also compare with the mean estimator that predicts a mean percentage of \(32.3\%\) occupancy ratio for all inputs.

As shown in Table 3, our method outperforms these three baselines by a significant margin. DepthCorrected is better than the other two baselines, showing that depth information is indeed useful for this task. However, it still does not fully predict the occupancy ratio. We see this as evidence that the ratio \(\frac{d_i}{d_{max}}\) alone is insufficient to predict \(\gamma \), and our network learns to extract more informative cues from depth maps. We hypothesize that our occupancy ratio network captures additional geometric information, such as the influence of concavities on final volume occupancy.

4.4 Volume Evaluation

Given the novelty of volume computation directly from 3D Gaussian Splatting (3DGS) representations, there are currently no established, publicly released methods available for a direct comparative evaluation. Thus, to quantify the quality of our volume estimation scheme, we compare it to two simple geometric baselines: the Convex Hull and the \(\alpha \)-Concave Hull. The Convex Hull computes the volume of the smallest convex set containing all 3DGS centers, which results in a significant volume overestimation by ignoring concavities and fine structure. The \(\alpha \)-Concave Hull attempts to mitigate this by generating a tighter, non-convex boundary, but its volume calculation is highly sensitive to the parameter \(\alpha \) and struggles to accurately delineate complex, sharp-edged objects.

As shown in Table 4, our method significantly outperforms both baselines across all metrics. The large discrepancy in performance underscores the limitations of relying on simple boundary approximations. These results validate that our technique accurately captures the intricate geometry and boundary of the underlying 3D structure, offering a robust and precise solution for volume calculation directly from the 3DGS scene representation.

Table 4 Evaluation of volume estimation

4.5 Ablation Study

Table 5 Ablation study on 3D counting
Table 6 Ablation study on occupancy ratio estimation

We conducted additional experiments to evaluate how sensitive our approach is to the depth maps produced by the monocular depth estimator.

Because our synthetic dataset has ground-truth depth maps for both training and validation images, we evaluate them as follows. Recall from Sect. 3.3 that, at training time, we use Depth Anything V2 [39] depth maps, a setting we call \(\mathcal {T}-\) for training without ground truth. Alternatively, we can use ground-truth depth maps during training, a setting we denote \(\mathcal {T}+\). Likewise, at inference time, we can use the estimated depth map, which is our default, or the ground-truth one, referred to as \(\mathcal {D}-\) and \(\mathcal {D}+\), respectively. Consequently, the standard configuration of our method is \(\mathcal {T}-,\mathcal {D}-\), and the other combinations are used only for ablation.

Results are reported in Table 5 for counting and in Table 6 for occupancy ratio estimation. Eliminating ground-truth depth maps and relying only on estimated ones, which is our standard procedure, performs best. We hypothesize that slight smoothing in the produced depth maps may prevent the model from overfitting to specific shape features in perfect depth maps.

Although the network is trained on synthetic data, this observation further confirms the generalizability of 3DC to real data, since in practical scenarios such as the real data of Table 2, ground-truth depth maps are not available.

Lastly, we also report in Table 2 an ablated method Ours (Color) where the \(\gamma \)-network takes an RGB image as input instead of a depth map. While this method still outperforms humans, it suffers from a significant performance drop and justifies the use of depth maps in our final approach.

4.6 Validating the Counting Equation

The counting equation eq. (4) relies on minor assumptions detailed in Sect. 3.2, namely that the value of gamma is approximately constant within the container and accurately measured in training samples. We validate these assumptions empirically using our synthetic dataset, which provides the ideal conditions necessary to isolate the formula’s performance from external estimation errors.

To perform this validation, we utilize ground-truth parameters derived directly from the simulation. The individual object volume v is computed from the mesh, \(\gamma \) is measured at the end of physical simulation, and the total volume \(\mathcal {V}\) is measured as the convex hull of the objects in the stack. Since these inputs are precisely known, any observed deviation stems solely from the inherent approximations of the counting equation itself or the definitions of \(\gamma \) and \(\mathcal {V}\).

Fig. 9
Fig. 9
Full size image

Counting approximation. In an ideal setting where \(\gamma \), v and V are know, comparing the estimated counts with eq. (4) and ground-truth values demonstrates that this equation is a good approximation of the real count of objects in our released dataset, with a slight tendency to overestimate at larger counts

Figure 9 confirms the robust performance of the proposed formula. The comparison between the estimated count \(\mathcal {N}_{est}\) and the ground-truth count \(\mathcal {N}\) yields a Coefficient of Determination (\(R^2\)) of 0.9328. We observe a Mean Absolute Error of 49.21, which is relatively low given the scale of the stacks. While the correlation is strong, a slight tendency to overestimate is visible at larger counts. This is likely due to the convex hull volume \(\mathcal {V}\) capturing small amounts of interstitial empty space at the stack boundaries, as well as minor local fluctuations in \(\gamma \). Nevertheless, these results justify the use of our counting equation as a reliable proxy for object count, offering a more generalizable alternative to direct count estimation methods, which often struggle with high-density scenarios as demonstrated in Sect. 4.2.

4.7 Additional Discussion on Border Effects

Fig. 10
Fig. 10
Full size image

Border effects. Measuring the ground-truth \(\gamma \) over the complete box or over only a smaller section makes little difference, indicating that our assumption of uniform \(\gamma \) across the volume is justified

Our approach assumes that the occupancy ratio, \(\gamma \), is approximately uniform throughout the container. Generally, this assumption holds as the number of stacked objects increases. Yet, it neglects the influence of container borders, where objects tend to occupy less volume due to the boundary.

Quantitatively evaluating the impact of border effects and verifying the validity of our uniform \(\gamma \) assumption, we analyze the ground-truth volume ratio in two distinct ways using our large-scale synthetic dataset. Initially, we compute \(\gamma _{\text {with\_edges}}\) for the entire unit box, as described in the main paper. We also compute \(\gamma _{\text {no\_edges}}\) by measuring the volume ratio in a smaller sub-box of side length 0.5, centered within the unit box. The difference between \(\gamma _{\text {with\_edges}}\) and \(\gamma _{\text {no\_edges}}\) intuitively reflects the influence of border effects, allowing us to evaluate whether this assumption is justifiable for practical industrial applications.

Two histograms comparing the distributions of \(\gamma _{\text {with\_edges}}\) and \(\gamma _{\text {no\_edges}}\) are presented in Fig. 10. Results indicate that both metrics follow highly similar distributions, with their mean values differing by less than 5%. The mean value of \(\gamma _{\text {no\_edges}}\) is notably slightly higher than that of \(\gamma _{\text {with\_edges}}\), consistent with the intuition that density decreases near borders.

Further investigating the relationship between these two values, we provide a scatter plot of \(\gamma _{\text {with\_edges}}\) versus \(\gamma _{\text {no\_edges}}\) in Fig. 10. This plot demonstrates a strong correlation between the two measures, particularly for objects with small volume ratios. Objects with high values of both \(\gamma _{\text {with\_edges}}\) and \(\gamma _{\text {no\_edges}}\) show minor discrepancies. We can attribute these differences to the relatively large size of these objects compared to the measurement box, which introduces noise in the estimation of \(\gamma \).

Collectively, these analyses confirm that \(\gamma _{\text {with\_edges}}\) and \(\gamma _{\text {no\_edges}}\) are highly consistent and can be used interchangeably without significant loss of accuracy. Our experiments rely on \(\gamma _{\text {with\_edges}}\) to train our occupancy ratio estimation network.

4.8 Limitations and Future Work

Fig. 11
Fig. 11
Full size image

Complexity Analysis. Each point represents the \(\gamma \) occupancy ratio error for a shape in the validation set

In order to evaluate the robustness of our method to complex shapes, we visualize in Fig. 11 the error in occupancy ratio estimation as a function of shape complexity. Here, complexity is measured by summing a curvature term with the ratio of the shape’s volume to the volume of its convex hull:

$$ C = \frac{\kappa }{\Vert x_{max} - x_{min}\Vert _2 \kappa _0} + \frac{V_{hull}-V}{V_{hull}} $$

where \(\kappa \) is the integrated mean curvature of the shape, \(\Vert x_{max} - x_{min}\Vert _2\) is a scaling factor and \(\kappa _0\) is the maximum scaled \(\kappa \) observed in the dataset. We observe only a slight error increase as shapes become more complex. Many earlier methods attempt to localize the objects being counted, unlike ours, thus increasing the interpretability and usability of the results. However, these localizations are often erroneous when objects are stacked together, as illustrated in Fig. 12, greatly limiting their applicability. Another possible direction for further enhancements lies in integrating a robust localization of visible instances and an estimation of a plausible configuration of invisible instances.

Fig. 12
Fig. 12
Full size image

Instance localization. Previous methods also produce interpretable results, representing a promising direction for future work

5 Conclusion

We presented a new method to count sets of stacked, nearly identical objects, which are particularly common in industrial inspection where objects are often placed in bulk in large containers. Occlusions and irregular arrangements make accurate counting difficult in this setting. By decomposing the counting task into complementary subproblems, separately estimating the 3D volume of the stacks and the fraction of that volume occupied by objects, we proposed an effective solution that is easy to implement and significantly outperforms humans on this challenging task.

Our experiments indicate that performance can decline with increased geometric complexity or visually complex scenes. For future work, we will focus on training the volume occupancy estimator to overcome these challenges. Overall, we believe our method and proposed datasets will open new applications and encourage future efforts centered on stacks of 3D objects, including 3D reconstruction, counting, and 3D scene understanding. These new methods will have the potential to fundamentally reshape our current industrial inspection pipelines, enabling automated quality control, reducing manual labor costs, and improving accuracy in inventory management.