Machine Vision Automates Inspection at Multinational Margarine Producer

Feb. 15, 2023
The automated system inspects tubs after they are filled with margarine, a second time after a film seal is added, and a third time after a top is affixed to the tub.

Inspecting margarine containers before they leave a manufacturing plant can be a slippery undertaking. At least that’s the experience of a large margarine producer with sites throughout Northern Europe. It contends with about 400 combinations of packaging and margarine recipes.

Each product comprises a base filled with margarine, a film seal, and a lid. Labeling in different languages and branding artwork are added directly to the plastic containers. The containers—including the labeling and artwork—are created by suppliers, and they ship these pieces to the margarine manufacturer in stacks of lids, tubs, or film. When operators in the plant add a stack of packaging to the machines that assemble the finished margarine products, they can only see the top and bottom of the stack, meaning there is no easy way for them to ensure that all products in the stack have the same labeling and artwork.

And, of course, there also are many variations of margarine. For example, the spread can be made with oil from olives, safflowers, soybeans, or other sources.

Spot-Check Manual Inspection Process

Historically, the manufacturer used a manual spot-check process in which operators in the plant would take products off the line to inspect them at two points in the process: after the film was affixed to the tub filled with margarine and then after the lid was added. “They would take a product off every 15 minutes and record all the details,” explains John Dunlop, CTO of Bytronic Vision Automation (Bromsgrove, Worcestershire, UK;, a  machine vision systems integrator specializing in manufacturing.  

This manual process was an imperfect system in which mismatched products could be sent to a retailer accidentally because operators were not checking every product. “Let’s say, for example, they had Swedish lids on Russian bases,” Dunlop says.

Once the manufacturer’s managers decided to invest in an automated process, they contacted Cognex (Natick, MA, USA;, and the vendor recommended Bytronic, which has a longstanding relationship with Cognex as an integration partner.

The project involved a total of 51 manufacturing lines at five manufacturing plants in numerous countries in Northern Europe.

How Automated Inspection Works

Bytronic built rugged enclosures—stainless steel with acrylic lens covers—to hold the cameras. The enclosures were then installed on metal tracks, making it convenient for operators at the plants to remove the camera enclosures each time they clean the margarine production machinery. 

The automated margarine inspection system replaced a spot-check manual process.Courtesy of Bytronic Vision Automation

The cameras are installed near the beginning of the production process, with two enclosures per line—one installed on the bottom of the line and one on the top. The bottom cameras are positioned before the tubs are filled with margarine, and they take images of the tubs before and after they are filled with margarine. The top cameras are positioned after the lids are affixed to the tubs, and they take images of the product first with the film and then with the lid.

There is a set of cameras enclosures for each production line. The number of cameras within each enclosure varies, depending on how many lanes there are within a production line, with the largest lines comprising seven lanes.

Each enclosure is about 10 in. wide and 6 in. high.

For each item on the production line, the smart cameras take and process images and communicate “pass” or “fail” to a PLC integrated with the automated machinery filling the tubs and assembling the products. If a “fail” message occurs, the production process stops, and operators take the failed product off the line. The smart cameras transmit the images to a separate PC for a permanent record.

Smart Camera System

The system uses the In-Sight 5605 from Cognex (which the vendor has since replaced with later-generation In-Sight products). The C-mount camera with 2/3-in. CCD sensor has a resolution of 2448 × 2048 and frame rate of 16 fps.  

Bytronic used a proprietary vision programming language, Cognex In-Sight Spreadsheet, to create specific pattern- and image-recognition algorithms that determine whether each product passes or fails the inspection. The algorithms compare the image to the correct characteristics of each SKU.

The software within the camera transmits images to a central PLC using File Transfer Protocol (FTP) and communicates pass or fail signals to the manufacturing machinery using Open Platform Communications (OPC) protocol.


To illuminate the inspecting process, Bytronic selected RGB LED bar lights: IP69K Washdown Backlight Bars from TPL Vision UK Ltd (Perth, UK;

This “meant that for different products, we could light it with different lighting. If we knew were expecting a product that looked better under the red lighting, then we turned the red light on,” Dunlop explains. For example, images of a tub or lid with primarily red Christmas decorations printed on it would not come out well using a red light.

Since the lights are IP69K-rated, plant staff does not have to remove them to clean the production machinery.

The automated inspection system includes smart cameras housed in an enclosure and LED bar lights.Courtesy of Bytronic Vision Automation

Implementation Challenges

Bytronic engineers overcame three primary challenges to complete the project.

One was the frequency with which the margarine manufacturer introduces changes to the packaging or labeling. “At one site, they were dealing with one change every day,” Dunlop says. For each change, personnel at the plant need to decide what color light and camera exposure to use to capture the best images of the product and enable the automated inspection.  

To help them make these modifications to the inspection system, Bytronic’s engineers wrote a test routine that creates images using different lighting and exposure combinations, allowing plant personnel to select the combination that produces the best images.

A second issue was the age of the production machines at the plants, which were originally installed in the 1980s, making it difficult for the Bytronic team to find the right spot to install the camera enclosures.   

“We had to do some quite careful mechanical design such that the enclosures would fit within the existing machines,” Dunlop explains. “You had to find space for it, and you also have to make sure that you would be able to see what you needed to see,” he adds.

A third challenge was “they wanted to be able to remove the cameras so that they could clean the filling machines. Obviously, they need cleaning quite frequently,” Dunlop says. “They clean these machines with boiling caustic soda. So, it’s fairly abrasive on a camera enclosure,” Dunlop explains.

This is why Bytronic’s engineers designed camera enclosures and a track system, so removing and reinstalling them would be an easy task for plant personnel.


The margarine manufacturer has not received any complaints or returned products from supermarkets since the automated inspection system was installed. In fact, the risk of sending a retailer the wrong product is nearly impossible because every single product is inspected, according to Dunlop. 

About the Author

Linda Wilson | Editor in Chief

Linda Wilson joined the team at Vision Systems Design in 2022. She has more than 25 years of experience in B2B publishing and has written for numerous publications, including Modern Healthcare, InformationWeek, Computerworld, Health Data Management, and many others. Before joining VSD, she was the senior editor at Medical Laboratory Observer, a sister publication to VSD.         

Voice Your Opinion

To join the conversation, and become an exclusive member of Vision Systems Design, create an account today!