Machine vision in the pharmaceutical industry: inspection and traceability in regulated environments

How machine vision is applied in the pharmaceutical industry: automated visual inspection, serialisation, system validation and auditable records.

Por Oscar Serrano, CEO de i-mas 5 min de lectura

machine vision

In any industrial plant, a machine vision system has to detect what must not get through. In a pharmaceutical plant it has to do that and, on top of it, prove it: leave a record of what it saw, when, against which criteria and under which software version.

That difference changes everything. Machine vision in the pharmaceutical industry is not judged on detection capability alone, but on its traceability and on the ability to reconstruct, months later, why a particular container was rejected or accepted.

This is why an inspection project in a regulated environment bears little resemblance to a conventional one: the acceptance criteria, the documentation, the change control and the way the system is validated before it goes into production are all different.

What gets inspected on a pharmaceutical line

The usual applications are split between the product and the packaging. On the product: visible particles, colour and appearance of the solution, fill level, integrity of the lyophilised cake and condition of the seal. On the packaging: placement of the stopper and the cap, position and legibility of the label, batch and expiry printing, and verification that the leaflet is inside the carton.

To these you have to add code reading and unit-level traceability, which in pharma is not an optional improvement but a distribution requirement.

Automated visual inspection of injectables

The automated visual inspection of visible particles in injectables is the most demanding case and also the most heavily regulated. The pharmacopoeias set the conditions under which it must be carried out: USP <790>, harmonised with chapter 2.9.20 of the European Pharmacopoeia, specifies illumination between 2,000 and 3,750 lux, observation against a white and a black background, and no magnification.

The standard scheme combines 100 % inspection of the units with subsequent AQL sampling in accordance with ISO 2859-1. In other words, the automated system does not replace statistical control: it feeds it.

For coloured or opalescent solutions and for lyophilised products, the pharmacopoeias themselves allow longer observation times and higher light intensities, because the limit is set by the physics of the product, not by the camera.

Serialisation and packaging traceability

Since 9 February 2019, Delegated Regulation (EU) 2016/161 has required prescription medicines to carry two safety features: a unique identifier, encoded in a two-dimensional Data Matrix, and an anti-tampering device.

For the line, that means printing, reading and verifying a different code on every pack, linking it to the batch and to the corresponding aggregate, and handling rejects without breaking the sequence. Medicine serialisation supported by machine vision comes in at the reading stage and at the verification of print quality, which is where most incidents arise.

Validating the system before production

In a conventional industrial project, the system is accepted once it works. In pharma you have to demonstrate that it works repeatably and in a documented way: validation of the vision system is organised as a staged qualification process using sets of known samples that include both good units and representative defects.

That sample set is the most laborious part of the project and the one that most determines the outcome. It defines what counts as a defect, it allows the real detection capability to be measured, and it serves as the reference every time the system is modified. It is also where the most common implementation mistakes are concentrated.

Records, audit trail and access control

A vision system in a GMP environment is part of the plant’s computerised systems, with everything that entails: identified users, permissions by role, an unalterable record of parameter changes, and retention of inspection results for whatever period the procedure sets out.

This drives technical decisions that would be minor in another sector: where the images are stored, for how long, at what resolution, how they are linked to the batch and who is allowed to change a threshold. It is best resolved in the system architecture rather than at the end of the project.

Change control: you do not just tweak a parameter

The most striking difference for anyone coming from another sector is that adjusting the system is not immediate. Changing a threshold, updating the software or retraining a model means assessing the impact, documenting it and, depending on the scope, repeating part of the qualification.

That penalises solutions that need continuous tuning and favours those that are stable and explainable. It is a criterion worth keeping in mind when choosing between a classical approach and one based on deep learning: in a regulated environment, being able to justify why the system rejected a unit is worth as much as getting it right, and how the model is trained and validated becomes part of the file.

Machine vision for regulated environments at I-MAS

At I-MAS we approach machine vision projects by integrating optics, lighting, sensors, software and communication with the line, and by adapting the documentation and the validation to the requirements of each sector. In pharmaceutical quality control that means working from the outset with agreed acceptance criteria, reference samples and records ready for audit.

If you need to automate an inspection in your plant and prove it, tell us about your project and we will look at it with you.