# Computer-Vision-Based Product Quality Inspection and Novel Counting System
## 3 Methods and Result
### Product Counting Algorithm Using Camera-Based Skeleton Tracking and Body Part Detection
#### 3.2.3 Unit Weight Calculation and Counting Method Using Image Differencing Technique  
As presented in Figure 9, image difference techniques are employed to determine the unit weight of a product [46; 47; 48]. The image differencing method detects the number of products placed on the load cell and calculates the unit weight based on the total weight of the products. During the initial setup, a certain number of products are placed on the load cell, and the unit weight is calculated by using the number of products detected through image differencing and the total weight measured by the load cell. This technique enables accurate detection of the number of products, minimizing weight measurement errors caused by product placement. To enhance the reliability of the image differencing  
Figure 7: This figure shows the case-based operation in the load cell counting system using a body detection algorithm. method, adjustments were made to compensate for external factors such as camera angle, lighting, and background noise. This ensures minimal impact from environmental changes on product detection, improving the accuracy of the product counting process. \[\text{W}_{\text{unit}}=\frac{\text{W}_{\text{Total}}}{\text{N}_{\text{product}}} \tag{10}\]  
Here, \(\text{W}_{\text{unit}}\) represents the unit weight of the product, \(\text{W}_{\text{Total}}\) is the total weight measured by the load cell, and \(\text{N}_{\text{product}}\) is the number of products detected using the image differencing technique. Once the initial unit weight is established, the number of products is calculated based on the change in weight measured by the load cell, following these steps:  
* Weight Change Calculation: When products are added or removed, the weight change is calculated by determining the difference between the current and previous weights measured by the load cell. The weight change must exceed a certain percentage of the unit weight (e.g., 0.5) to be considered valid. This prevents counting errors caused by minor weight fluctuations. \[\Delta\text{W}=\text{W}_{\text{current}}-\text{W}_{\text{previous}}\] (11)
* Stabilization Process: To improve counting accuracy, the system detects the point at which the weight change stabilizes. Based on the number of data points received per second, \(\text{N}_{\text{DATA}}\), if the same weight change is detected over a certain number  
Figure 8: This figure shows the step-by-step process flow of a product counting system. Figure 9: This figure shows the process of unit weight calculation using the image differencing technique. of consecutive readings, the weight is considered stabilized, and the counting is performed. This helps to reduce errors caused by temporary weight fluctuations or noise. * Precise Decimal Handling: The weight change is calculated with precision to the first decimal places, and rounding or truncation is applied only at the time of counting. This minimizes counting errors that may occur when multiple products are loaded simultaneously. For example, if the weight change appears in increments of 0.5, it is rounded up and reflected in the final count. * Counting Execution: Once the stabilization process is complete, the number of products is calculated by dividing the weight change by the unit weight. During this process, decimal values are carefully handled, and if the first decimal place is 0.5, rounding up or down is applied to ensure the accuracy of the count. * Stabilization Process: To enhance counting accuracy, the system detects when the weight change stabilizes. Based on the number of data points received per second, \(\mathrm{N_{DATA}}\), if the same weight change is detected consistently over a certain number of readings, the weight is considered stabilized, and counting is performed. This helps reduce errors caused by temporary weight fluctuations or noise. Here, \(\mathrm{C_{product}}\) represents the number of products, \(\mathrm{\Delta W}\) is the weight change, and \(\mathrm{W_{unit}}\) is the unit weight.