Comac new technology for keg inspection, in collaboration with Consorzio Intellimech

CoMac mission is to design and manufacture automatic and semi-automatic plants for processing and packaging drinks in containers of various sizes, customizing them according to specific technical and production requirements.

The milestones of our vision, which in more than 30 years of experience have enabled us to be recognized as one of the most important international players in this field, are the technological innovation and great attention to customer requirements.

These principles are concretely applied through lean, flexible, and intelligent industrial projects and processes, aimed at minimizing waste and giving value to time and available resources. For this reason, CoMac is always open to new solutions for the ongoing improvement of its systems, by relying also on the collaboration and know-how of consolidated companies in the Bergamo area, where the company roots are proudly embedded.

This is the case of Intellimech, a private consortium of large, medium and small companies focused on interdisciplinary research in mechatronics, which includes CoMac as a member since 2019.

From the synergy between the two companies, a project dedicated to implementing a new methodology of inspecting the kegs has been engineered, aimed at including it in future lines designed and built by the company.

Project overview

Kegs are among the containers processed by our plants, classified by various sizes in terms of diameter and height, and specifically by their different type of fitting (i.e. the product inlet section).

In fully-automated filling lines, where no intervention or visual control by the operator is required, inspection systems are needed to ensure that empty kegs are in the correct position (with the spear facing upwards) and that there is no capsule (cap) on the keg’s neck. The technology used so far by these devices is based on the physical principle of induction.

Inductive sensors comply with detecting the keg orientation and, if necessary, the presence of the capsule on its fitting, while revealing any metal components, if present.

However, this technology is a solution that requires “contact” and, mainly, it is not able to detect the type of keg fitting. This means that the customer must physically inspect there is only one fitting type per keg used on the line.

Such CoMac project is dedicated to a new way of inspecting the keg, with the aim of overcoming this drawback. Artificial intelligence was implemented to recognize the fitting, as well as the presence of the cap and the collar, in a totally automatic and autonomous way.

More specifically, computer vision algorithms were developed to make predictions on images acquired during production. The inductive sensor has therefore been replaced by a camera capturing an image every time the keg is conveyed on the line.

Approach to the problem

An acquisition campaign was conducted to collect a diverse dataset of images containing kegs with and without fittings, with and without collars, for each type of keg.

Furthermore, synthetic data (2D color images) was used to train a convolutional neural network using domain randomization methodology.

Domain randomization proved to be an effective technique for training the neural network with simulated images. The object, a keg in this case, is shown to the model as just another variant, making the dataset richer in terms of images. As a result, the model accuracy becomes higher.

Using the Grad-CAM (Gradient-weighted Class Activation Mapping) algorithm, it was possible to generate a “visual explanation” (activation map) of the internal functioning of the neural network. This approach allowed to figure out which region of the image contributes the most to determine the prediction, thus validating the final result.

An additional control, used to identify the keg orientation, was performed through a deterministic approach. In particular, a laser profilometer was used, designed to make precise profile measurements during dynamic processes.

Working at high frequency, the sensor detects the distance of each point on the keg’s metal surface, intercepted by the laser at every discrete instant.

This makes it possible to reconstruct the cross-section by linearly interpolating the detected points.

The profile variation in the central area is the discriminating element between the two profiles (upright versus downright).

The prediction is performed based on a differential calculation of the two profiles. In the case of fitting down, the derivative never exceeds a predetermined threshold value. When the keg is positioned upright, the derivative peaks at the fitting match, hence exceeding the threshold value.


The total accuracy of the model exceeds 97%. The identification errors concerned in almost all cases “false positives”, i.e. the kegs oriented correctly are classified as “to be overturned”. However, in practical terms, a false positive has less impact than a false negative: a misclassification where the keg is oriented upright but classified as “to be discarded” is certainly more acceptable than letting a downright keg classified as “correct orientation” (upright) passing along the line.

The use of artificial intelligence algorithms in combination with the profilometer proved to be a technologically valid solution, considering that the inspection takes place ” contactless”, as no object physically interacts with the keg while the keg maintains its motion unchanged, without being stopped for control.


This innovative keg inspection system developed by CoMac’s R&D department after a long design project in collaboration with Intellimech, is now almost ready to be installed in our production lines.

It is designed to be used in the most performing lines, in which a very high degree of precision is required during the inspection phase.

The new year opens with a technological innovation and sees CoMac creating a new solution that meets the needs of a demanding, global and constantly evolving beverage market.