MVTEC HALCON

Vision system checks pharmaceutical products - Machine Vision Technology

Machine Vision Technology Ltd. developed an automated inspection system using MVTec HALCON to check tablets and capsules for broken pieces, shape errors, and color deviations. Three Basler cameras and a dark-field lighting setup ensure precise detection and reliable rejection of defective products.
HALCON
Medical Supplies & Pharmaceutical
Inspection
Matching
Measuring
Morphology

In the pharmaceutical industry, it is critically important to count tablets and gel capsules prior to filling them into containers. To meet those demands, Pharma Packaging Systems (Worcestershire, England; www.pharmaps.com) has developed a range of electronic counting and packaging systems that can be deployed either as stand-alone units or as part of an integrated packaging line. To enhance the capability of their existing product range, the company recently joined forces with Machine Vision Technology (Warwickshire, England; www.machine-vision-technology.co.uk) to create a vision-based inspection system that can detect partially formed and broken tablets and capsules and determine whether any cross contamination had occurred. Counting and packaging In a typical counting and packaging machine, tablets or capsules are placed into a hopper at the rear of the machine, either manually or automatically. From the hopper they are fed onto a vibratory feed system divided into three sets of three stainless steel cascading feed trays, each having six tracks. The grooved vibrating sections of the feed trays separate the products from one another as they move along tracks. When the tablets or capsules leave the end of the last of the three feed trays, they pass through high speed infrared optical sensors that count the products in free fall before they are guided into individual bottles through chutes and filling nozzles (Figure 1). To determine whether a container has been filled correctly, the data from the sensors is fed to an embedded PC which counts the number of tablets that have been deposited into each bottle.

Figure 1: Tablets or capsules are placed into a hopper at the rear of the machine. From the hopper, they are fed onto a vibratory feed system that separates the products from one another. When the tablets or capsules leave the vibratory feed system, they pass through high speed infrared optical sensors that count the products in free fall after which they are guided into separate containers through chutes and filling nozzles.

Once one of the bottles in the machine has been filled, the PC then closes a flap and eventually halts the vibratory feed system associated with it until the other bottles have been filled. The bottles are then indexed through the system and either accepted or rejected, depending on whether they have been filled correctly. Vision enhancement To enable the machine to check for broken or partially formed tablets, Machine Vision Technology mounted three Scout 1300 32gc 1250 x 1000 pixel cameras from Basler (Ahrensburg, Germany; www.baslerweb.com/en fitted with 12mm lenses from Computar (Cary, North Carolina, USA; www.computar.com ) above each one of the final three vibrating feed trays of the counting and bottling machine. To illuminate the trays, a dark field lighting system was developed that comprises a bank of four LED line lights which project light at an angle down onto the trays. The dark field lighting technique ensures that the light incident on the mirrored surface of the stainless steel feed trays is reflected away from-rather than directly at-the cameras, enabling images of the matt surface of the tablets or capsules to be imaged effectively. Images of the tablets or capsules on the trays are transferred to a dedicated PC over GigE interfaces where they are processed using HALCON image processing software from MVTec (Munich, Germany). The primary purpose of the inspection is to identify small particles or half tablets that might be present and to determine whether the tablets are of the correct color. To do so, the HALCON software analyzes the images of the tablets to determine the length, width, area, completeness, and verifies their color. The PC-based vision inspection system is interfaced to the embedded PC performing the counting function to which it communicates in real time. If a tablet is identified as defective by the vision system, it will still be bottled by the machine. However, the PC running the vision system software will then flag the tablet as defective and send a fail signal to the embedded PC performing the counting function. The embedded PC then decides which container contains the incorrect tablet depending upon when the fail signal was received from the vision system. Having done so, the container will then be rejected from the line after it leaves the bottling machine. Sophisticated software The LED lighting used in the system is mounted in an enclosure above the trays together with the three cameras. Because the lighting is positioned around all four sides of the enclosure illuminating each of the three trays at an angle, illumination consistency varies across the three cascading feed trays beneath the system. Hence it was important to ensure that the images of the tablets or capsules could be segmented from the background image of the trays no matter which tray they were on. To do so, the vision system employs an image thresholding algorithm that segments the images based on the intensity values of the pixels in the image.

Rather than choose a fixed threshold value, however, the system uses a local adaptive thresholding technique to separate desirable foreground image objects from the background. Individually tuning the threshold values for each lane of feed trays provides a more robust solution to accommodate changes in illumination across the trays. Because many tablets or capsules may be touching as they move down the trays, a means was needed to digitally separate them prior to making measurements on their size and color. To do so, the vision software makes use of erosion and dilation operators found in the HALCON toolset. In use, the erosion operation removes a given number of pixels from around the outer perimeter of the objects identified in the image. If the product has been eroded correctly, touching products are then separated into separate objects. What is more, smaller objects in the image, such as dust, the thin reflections from the grooves in the tray or the small regions due to the reflections of the product in the sides of the grooves in the trays disappear.

Next, the images are dilated to their original size by adding pixels around their edges. The vision system can then perform measurements to determine their width, length and area. In some instances, capsules may have a pharmaceutical manufacturer's logo printed onto them. If the printed logo is on the very perimeter of the tablet when an image of the tablet is captured by the camera, the capsule may appear to have an occlusion on one side. Hence measuring the width of the tablet would be compromised. To overcome this issue, a HALCON convex hull operation is performed on the images of a tablet to eliminate the impact of concaved areas in the image, enabling an accurate measurement of its width to be made. Setup and training Prior to use, the vision system fitted to the counting and bottling machine must be taught the characteristics of a new product. To do so, an operator allocates a name to the product on an HMI and places the new tablets or capsules to be inspected over each track of the trays. The camera aperture or exposure time of each of the cameras can then be modified to ensure that the tablets can be appropriately imaged by the system (Figure 2).

Figure 2: While in supervisor mode, an operator names a new product to be inspected, and places several products over each track of each tray. The camera aperture or exposure time of each of the cameras can then be modified to ensure that the tablets can be appropriately imaged by the system.

Once an image has been captured of products on a tray, threshold levels can be set on the images to highlight all of the tablets in the image, while eliminating the background of the tray and any reflections of the product from the sides of the grooves in the tray. Having done so, an operator can highlight each of the tablets on the tray by assigning a single color to all of them (Figure 3).

The operator then sets the levels of erosion and dilation necessary to separate touching products. If the product has been eroded correctly, the operator will immediately visualize this on screen, as the touching products will appear as separate objects. The image can then be dilated to make all the tablets appear their normal size, so that the vision system can calculate their length, width and area (Figure 4). Once the appropriate levels of erosion and dilation have been set, the system can be trained to recognize the color of the tablet. Here, the operator highlights the tablet which best represents the true tablet color. The system then takes the red, green and blue components of the pixel plus the pixels immediately surrounding it, averages them and obtains a value for red, green and blue. This then becomes the value for the color of the new tablet. Tablet tracking As the tablets or capsules move down the trays, they are vibrating, touching and often bouncing. This presented a challenge for the vision system, which was required to identify the tablets or capsules despite the fact that they could be presented to the cameras in the system in various orientations. Compounding the inspection challenge was the fact that the vibratory feeders start and stop several times a minute and can feed the tablets into the containers at varying rates. To resolve this, Machine Vision Technology spent over one year developing tablet tracking software. When the system is running, the cameras capture ten or more images of each tablet in each of the trays at a rate of 20fps as they pass from top to bottom through the cameras' fields of view. Once the vision system has found a tablet or capsule in each image, it then predicts where it will be in the next image. Then, it matches its new position and orientation in the new image with its position and orientation in the previous image to identify it as the same tablet. Once the inspection returns a 'good' result for a tablet it is 'locked-in' as good, even if it then bounces onto an edge and so appears to be 'bad' in subsequent inspections.

As the tablet leaves the tray and gets counted into a bottle, the vision system outputs the tablet inspection result. The tablet must be deemed 'good' in at least one image, otherwise it is 'bad' and the bottle it goes into automatically gets segregated to a reject area. As the system inspects the tablets or capsules, an operator can immediately visualize the total number of tablets inspected by the machine on the HMI, as well as the total number that have passed or failed the inspection (Figure 5). Looking ahead Although the machines described above are the standard Pharma Packaging Systems' machines retrofitted with machine vision, the latest machine jointly developed by Pharma Packaging Systems and Machine Vision Technology also ensures that only good product is discharged for further processing. In the new design, products are transferred from a vibratory system onto a flat belt where they are inspected by the vision system for width, length, area and color. Should the vision system detect any products that do not fall within specification, it triggers a series of electromechanical reject chutes positioned at the end of the belt into which the faulty products are dropped. The new system-which was recently installed at a large UK tablet manufacturer-can inspect up to 10,000 tablets per minute. The products used in the design of the system were supplied and supported by Multipix Imaging (Petersfield, England; www.multipix.com).

Author: Brian Castelino Machine Vision Technology Ltd. (MVT) is a MVTec Certified Integration Partner.

Article kindly provided by Vision Systems Design. All product names, trademarks and images of the products/trademarks are copyright by their holders.
All rights reserved.

Fig. 3: The threshold levels of the images can be adjusted so that the tablets are all detected by the imaging system but the random noise in the images are minimized.

Published on: July 01, 2016

Further News

MVTec MERLIC 26.03 is available now
With MERLIC 26.03, developing and operating machine vision applications becomes more consistent and scalable. The release introduces the unified MVTec versioning format (YY.MM) and a simplified, package-based licensing model with flexible add-ons.
Read more
MERLIC
New version of the Deep Learning Tool significantly boosts Deep OCR performance
With Deep OCR Alignment and other improvements, Deep Learning Tool 26.03 enhances speed and efficiency for OCR applications. New models, optimized training, and CUDA 12.8 support bring higher performance with lower memory usage.
Read more
Deep Learning Tool
New MVTec Academy course: Mosaicking – stitching images with HALCON
This basic training introduces you to the mosaicking technologies in HALCON. The course shows you how to combine several images into one large mosaic image. Thus, this technology enables you to create a large image of an object or scene that would ot…
Read more
Academy
HALCON
New MVTec Academy course: Parallel programming with HALCON
This advanced training introduces you to the concept of parallel programming with HALCON. The application of parallel programming allows you to optimize the performance of your HALCON program and take full advantage of multicore or multiprocessor ha…
Read more
Academy
HALCON
Opticum d.o.o. becomes a MVTec Certified Integration Partner
The company based in Vojnik, Slovenia, specializes in industrial printing, machine vision, weighing, labeling, and traceability, serving primarily the pharmaceutical industry.
Read more
Certified Integration Partner
VST Taiwan becomes a new member of MVTec’s partner network
The automated optical inspection (AOI) specialist VST Taiwan has joined the MVTec Certified Integration Partner Program and offers services in optical system design, mechanical structure planning, and key vision components.
Read more
Certified Integration Partner
New version 1.6.5 of the MVTec Software Manager
The latest version of the MVTec Software Manager is now available and brings several enhancements to improve usability and performance.
Read more
MVTec
New MVTec Academy course "Develop a custom tool for MERLIC"
This advanced training introduces you to the development of custom tools for MERLIC to extend the existing MERLIC tool library.
Read more
Academy
MERLIC
New version 25.12 of the MVTec License Server released
With MVTec License Server Cloud-Ready 25.12, HALCON licenses can be borrowed, enabling operation during network failures and offline.
Read more
MVTec
MVTec Deep Learning Tool 25.12 is out now
On December 4, 2025, we released the new version 25.12 of the MVTec Deep Learning Tool and thus consistently further developed our portfolio for AI-based machine vision.
Read more
Deep Learning Tool
MVTec welcomes new partner Micro-Epsilon
We are pleased to welcome Micro-Epsilon, a globally operating specialist in high-precision sensor and measurement technology, to our Technology Partner Program.
Read more
Technology Partner
New MVTec Academy course "Image acquisition: The interface for modern camera technology"
This training course will introduce you to the new image acquisition operators. Through practical exercises, you will learn the necessary technical terms and concepts, and deepen your knowledge.
Read more
Academy
HALCON
HALCON 25.11 is available now
The new version of MVTec HALCON is now available for download. This version again brings some improvements as well as new features, such as Continual Learning – Classification, a new technology that makes training and maintaining classification model…
Read more
HALCON
DISYS joins MVTec Partner Network with expertise in advanced vision systems
The company from Schio, Italy, develops fully customized AI-powered solutions for diverse industries, from manufacturing to pharma, automotive, packaging, and food & beverage.
Read more
Certified Integration Partner
New MVTec Academy course "Code integration with language interfaces"
This advanced training course covers the integration and use of the HALCON library in software projects written in C, C++, C#, Visual Basic .NET, and Python.
Read more
Academy
HALCON
New MVTec Academy course "Image acquisition with GigE Vision"
This advanced course provides in-depth information on using GigE Vision cameras with HALCON.
Read more
Academy
HALCON
VRAiA CORP S.L. joins the MVTec Partner Network
The company from Aspe (Alicante, Spain) applies robotics and machine vision in tire production, focusing on final inspection and quality assurance.
Read more
Certified Integration Partner
robomotion strengthens the MVTec Partner Network
The German company specializes in customized automation solutions for demanding applications in food, medical technology, packaging, and plastics industries.
Read more
Certified Integration Partner
Halley Informatica strengthens the MVTec Partner Network
The division Halley Machine Vision specializes in 3D vision and robot guidance solutions for industrial automation and quality control.
Read more
Certified Integration Partner
Trifid Automation s.r.o. joins the MVTec Partner Network
The company from Slovakia provides advanced machine vision solutions for quality control and inspection across automotive, rubber, engineering, and wood industries.
Read more
Certified Integration Partner
MVTec MERLIC 5.8 is available now
MVTec MERLIC 5.8 makes developing and operating vision applications easier than ever, with improved error handling, centralized recipe management, and faster, more flexible deployment.
Read more
MERLIC
GosTech Kft. joins the MVTec Partner Network
With expertise in machine vision, optical and electrical measurement, and automation, GosTech Kft. delivers high-value solutions across multiple industries.
Read more
Certified Integration Partner
Digiinov SA adds industrial software and machine vision know-how to the MVTec Partner Network
The Swiss company supports machine builders with industrial software development and customized machine vision solutions based on HALCON.
Read more
Certified Integration Partner
New MVTec Academy course "Hand-eye calibration"
In this advanced course, you will learn how to perform hand-eye calibration using HALCON.
Read more
Academy
HALCON
SIGA Vision Ltd joins the MVTec Partner Network
Backed by the Mpac group, SIGA Vision delivers seamless vision systems and turnkey solutions for food and beverage, consumer goods, and healthcare industries.
Read more
Certified Integration Partner
VISOR – AOI and automation specialist joins the MVTec Partner Network
Founded in 2007, VISOR develops customized AOI and automation solutions and is today a leading provider of industrial vision systems in Southeastern Europe.
Read more
Certified Integration Partner
Smart Services becomes a new member of MVTec’s partner network
Smart Services has joined the MVTec Certified Integration Partner Program, offering machine vision solutions for identification, measurement, object and position detection, and quality inspection.
Read more
Certified Integration Partner
Herzog VSA becomes a certified integration partner of MVTec
The Herzog VSA specialises in challenging machine vision projects, with a strong focus on 3D data processing, line scan camera applications, and hybrid 2D/3D systems.
Read more
Certified Integration Partner
Agmanic Vision becomes a new member of MVTec’s partner network
Computer vision specialist Agmanic Vision has joined the MVTec Certified Integration Partner Program and delivers AI-driven solutions for quality control, robotics, and embedded applications.
Read more
Certified Integration Partner
New version 25.08 of the MVTec License Server released
The update makes it easier to run the License Server as a Windows system service and provides improved access to documentation.
Read more
MVTec
MVTec welcomes Optotune as new partner
MVTec is pleased to welcome Optotune Switzerland AG as the latest company to join its Technology Partner Program. Through this collaboration, MVTec’s powerful machine vision software is complemented by Optotune’s cutting-edge focus-tunable lenses and…
Read more
Technology Partner
Certified Integration Partner Autolab becomes a new member of MVTec’s partner network
Autolab GmbH is the latest addition to MVTec's Certified Integration Partner Program, delivering advanced solutions for visual quality inspection and inline measurement using deep learning and classical machine vision.
Read more
Certified Integration Partner
New MVTec Academy course "Inspect the print quality of bar and 2D data codes"
In this advanced training course, you will learn how to perform print quality inspection for bar and data codes using HALCON and MERLIC.
Read more
Academy
HALCON
MERLIC
Preview version of HDevelopEVO: new update now available
Faster, more intuitive, and interactive programming: All HALCON users can now download the new IDE preview version.
Read more
HALCON
New MVTec Academy course "Defect detection"
This basic training introduces you to defect detection with MVTec HALCON. In this training, you learn different approaches and what to consider when developing a defect detection application. Then, you solve some challenging applications with differe…
Read more
Academy
HALCON
Visione Artificiale srl becomes a new member of MVTec’s partner network
Visione Artificiale srl has joined the MVTec Certified Integration Partner Program, offering turnkey vision solutions for quality control, defect detection, robot guidance, and process optimization.
Read more
Certified Integration Partner
Bertram Elektrotechnik becomes a new member of MVTec's partner network
Automation specialist Bertram Elektrotechnik adds its expertise in robotics, test engineering, and image processing to the MVTec Certified Integration Partner Program.
Read more
Certified Integration Partner
New MVTec Academy course "Working with regions"
This basic training introduces you to the concept of regions in HALCON. You learn how to create regions manually as well as by different segmentation approaches, process regions, and access different features of regions.
Read more
Academy
HALCON
New MVTec Academy course "Speed up deep learning with AI²"
his advanced training shows you how to optimize your deep learning applications in terms of inference runtime and memory requirements using MVTec’s AI Accelerator Interface (AI²).
Read more
Academy
HALCON
MERLIC
MVTec HALCON software box with surfer – new version
HALCON 25.05 is available now
The new version of MVTec HALCON is now available for download. With this release, MVTec focuses on improving HALCON’s ease-of-use and rule-based machine vision.
Read more
HALCON
Advancing Anomaly Detection: VAND 2025 Challenge at CVPR 2025
We’re thrilled to announce the Visual Anomaly and Novelty Detection (VAND) 2025 challenge, a premier event at CVPR 2025. Sponsored by Voxel51, Intel, and MVTec, this challenge aims to push the boundaries of anomaly detection in industrial application…
Read more
MVTec
MVTec Deep Learning Tool 25.04 is out now
On April 30, 2025, we released the new version 25.04 of the MVTec Deep Learning Tool and thus consistently further developed our portfolio for AI-based machine vision.
Read more
Deep Learning Tool
MVTec on Campus celebrates 5 years with Vision Hero campaign
MVTec Software GmbH is proud to announce the 5-year anniversary of its successful educational initiative MVTec on Campus. To mark this special milestone, MVTec is launching a unique and engaging campaign: Vision Heroes – Saving Yogurt Village.
Read more
MVTec
MVTec MERLIC 5.7 is available now
With the new version MERLIC 5.7, MVTec continues their established path with MERLIC – easy process integration combined with powerful machine vision methods. The new version improves the usability of MERLIC Runtime Environment (RTE) and optimizes the…
Read more
MERLIC
New MVTec Academy course "Read bar codes"
This basic training teaches you how to read bar codes with HALCON and MERLIC.
Read more
Academy
HALCON
MERLIC
Mission Accomplished: MVTec's Christmas Quiz
As we wrap up our Christmas quiz, we’re excited to share the fantastic results.
Read more
MVTec
MVTec Software