Technical Guide · Machine Vision

Your Vendor Says AI-Powered.
The Question Is: Does Your Line Actually Need It?

📅 May 2026 🕐 9 min read 🏷 Machine Vision · Packaging Inspection · AI

Deep learning has genuinely transformed machine vision for some applications. But for most packaging inspection tasks in pharma, FMCG, and nutraceuticals, rule-based detection is still the more reliable, more maintainable, and more compliant choice. Here's the honest comparison.

Everyone Is Selling AI Now. That Doesn't Mean You Need It.

Go to any packaging trade show or read any vision system brochure from the past three years and you will see the same language: AI-powered, deep learning, neural network, intelligent inspection. It has become the industry's favourite modifier.

The problem is that "AI" now describes everything from genuine convolutional neural networks trained on thousands of defect images — to traditional rule-based systems with a slightly modernised user interface. The term has been so thoroughly marketed that it no longer reliably indicates what a system actually does.

More importantly: even when a system genuinely uses deep learning, that does not make it the right choice for your inspection task. Knowing when AI adds value — and when it introduces unnecessary complexity — is the question worth asking.

First, Define the Terms

Rule-Based Machine Vision

Rule-based (also called algorithm-based or classical) machine vision operates through explicitly programmed logic. The system uses defined image processing algorithms — blob detection, edge detection, template matching, colour histograms, morphological operations — to find specific, predetermined features in an image.

A rule-based cap inspection, for example, checks: is a cap present (blob detection); is the cap diameter within tolerance (measurement); is the cap colour within the expected range (colour histogram); is the liner present (contrast threshold in defined ROI); is the cap at the correct height (edge position).

Every decision point is an explicit rule with a defined pass/fail threshold.

AI / Deep Learning Vision

A deep learning model is trained on a labelled dataset of images — thousands of examples of "pass" and "fail" — and learns to make a classification decision based on learned feature representations rather than programmed rules.

The model does not "know" that it is looking for a missing liner. It has learned to associate a particular pattern of pixel values with the label "defective" — because a human labelled those images as defective during training.

Critical implication: A deep learning model can only detect defect types it has seen during training. A defect class that was not in the training data is indistinguishable from a passing part — no matter how obvious it appears to a human inspector.

Where Each Approach Actually Wins

Inspection Task Rule-Based AI / Deep Learning Recommended
Cap present / absent Excellent Overkill Rule-Based
Cap colour / code verification Excellent Comparable Rule-Based
Liner presence inspection Excellent Comparable Rule-Based
Fill level check Excellent Overkill Rule-Based
Label presence / placement Excellent Comparable Rule-Based
Wrong label / SKU mismatch Excellent (template match) Comparable Rule-Based
Barcode / QR code reading Excellent (OCR/barcode) Not applicable Rule-Based
Label print quality — text/graphics Adequate Better (pattern recognition) Context-dependent
Surface cosmetic defects (cracks, burrs, inclusions) Limited — needs well-defined defect types Significantly better on complex/variable defects AI preferred
Complex bottle shape defects (short moulding, deformation) Adequate for defined types Better for variable/unpredictable defects Context-dependent
Foreign object detection Limited if object type varies widely Better — learns "not belonging" patterns AI preferred (if data available)
Induction seal integrity Excellent (thermal detection logic) Not applicable (thermal signal is primary) Rule-Based + Thermal

The Pharmaceutical Compliance Reality

For pharma manufacturers operating under 21 CFR Part 11, Schedule M, EU GMP, or WHO-GMP, this is not just a technical comparison — it is a compliance question.

A rule-based system is deterministic. Given identical input images, it always produces identical outputs. The decision logic is fully documentable in a validation protocol. You can write a challenge test that definitively proves the system detects a defined defect type.

A deep learning model is probabilistic. Its outputs depend on a trained model that can change with every retrain cycle. Validating a deep learning inspection system under pharma GMP requires:

Practical observation: For most pharma packaging inspection tasks — cap presence, liner check, label placement, fill level — a validated rule-based system passes audits without difficulty. Introducing AI for these tasks adds complexity without adding measurable quality improvement.

What Most People Get Wrong

The most common misconception is that AI equals higher accuracy. This is not a reliable generalisation.

For a well-defined, consistent defect type — a missing cap, a wrong label, an out-of-tolerance fill level — a well-implemented rule-based system routinely achieves >99.5% detection rate with <0.3% false rejection rate. A deep learning system on the same task may perform similarly, slightly better, or worse depending on training data quality and model architecture.

The advantage of deep learning becomes real in three specific situations:

  1. Defects that cannot be fully specified in advance. Surface cosmetic defects on moulded bottles — cracks, delamination, surface inclusions — come in shapes, sizes, and positions that are difficult to enumerate in a rule set. A model trained on thousands of defect examples learns a representation of "damaged surface" that generalises better than a manually constructed rule.
  2. Inspection tasks where product variation is high. If you run 80+ SKUs with significant surface texture, colour, and shape variation, training a product-specific deep learning model can reduce the setup time per SKU change compared to programming explicit rules for each.
  3. Complex multi-feature interactions. If the pass/fail decision requires integrating multiple visual signals simultaneously — not just "is the label present" but "is this label, at this position, on this bottle colour, with this print quality, for this batch code" — AI can handle the combinatorial complexity better than nested rule logic.

The Training Data Problem — Rarely Discussed Honestly

When a vendor says "AI-based detection," the first question to ask is: how many training images were used, and where did they come from?

A production-ready deep learning model for packaging defects requires:

For rare or catastrophic defects — foreign objects, cross-contamination, cap damage from a conveyor failure — the actual defect images may simply not exist in sufficient volume. This is a structural limitation of deep learning for production inspection.

Watch for this vendor pattern: Systems trained on synthetic or augmented defect images (digitally generated faults) may show impressive demo performance that does not hold up in production conditions. Always ask for validation data from a real production installation — not a lab demo.

The Hybrid Approach: Where the Industry Is Actually Heading

The most capable modern vision systems do not choose between AI and rule-based — they use each where it is appropriate within the same inspection sequence.

A hybrid architecture might look like this:

1️⃣
Rule-based checks for defined, binary defect types

Cap present, fill level in range, label present, barcode readable — fast, deterministic, easy to validate.

2️⃣
AI model for surface/cosmetic defect classification

Deep learning model trained on customer-specific defect images, running in parallel for complex visual quality checks.

3️⃣
Structured data layer for audit trail and compliance

All pass/fail decisions — from both rule-based and AI components — logged with image, timestamp, decision rationale, and operator ID.

This architecture gives you the reliability of rule-based detection for defined defects and the adaptability of AI for complex visual defects — without compromising the auditability required for pharma compliance.

Questions to Ask Before You Buy an "AI" Vision System

  1. Is the AI component genuinely used for your inspection task? Ask for documentation of the AI model — input features, training dataset size, defect classes included. If the vendor cannot answer this specifically, the "AI" claim is likely marketing.
  2. What is the training data source? Production images from real lines? Customer-specific data? Synthetic augmentation? Each has different validation implications.
  3. What happens when the model encounters a defect class it was not trained on? An honest vendor will tell you it will likely pass. Ask how they handle this in practice.
  4. How does the change control process work for model updates? If the model can update automatically, this is a compliance risk. You need a defined change control process tied to your validation framework.
  5. Can you provide IQ/OQ/PQ documentation? For pharma, this is non-negotiable. Ask for a sample validation document before purchase.

Practical Takeaway

Do not buy AI inspection because it sounds advanced. Buy it because it solves a specific inspection problem that rule-based detection handles poorly.


For most pharma, FMCG, and nutraceutical packaging inspection tasks — cap and liner inspection, label verification, fill level, induction seal — a well-implemented rule-based system with proper illumination and optics will outperform a poorly trained AI model every day of the week.


Reserve AI for what it is genuinely better at: complex, variable, or incompletely specified visual defect types where rule-based logic breaks down.

Optomech's vision inspection systems use rule-based detection architectures optimised for packaging inspection — achieving >99.5% detection rates in production with false rejection rates below 0.3%. For applications where AI-based detection provides a measurable improvement, our applications team will tell you clearly — not because it justifies a higher price, but because it is the correct technical recommendation.

Frequently Asked Questions

Is AI-based vision inspection better than rule-based for packaging lines?
Not necessarily. Rule-based systems are more reliable and easier to validate for well-defined defect types — missing caps, wrong labels, fill level errors. AI/deep learning outperforms rule-based for complex or unpredictable visual defect types — surface cosmetic defects, printing quality, and situations where the defect class cannot be fully specified in advance. For most pharma and FMCG packaging inspection tasks, rule-based remains the correct engineering choice.
Can AI machine vision systems be validated for 21 CFR Part 11 compliance?
Yes, but the validation effort is substantially higher for AI-based systems. With a rule-based system, the detection logic is deterministic and fully documentable. With a deep learning model, validation must include training data documentation, model versioning, change control procedures for every retrain, and bias validation across full product variation. FDA and EU GMP accept AI-based inspection but require documented, auditable decision-making.
What is the difference between AI and machine vision?
Machine vision is the broader field — using cameras, optics, illumination, and software to inspect parts. AI (deep learning) is one software approach within machine vision. The alternative is rule-based machine vision, which uses defined algorithms and thresholds. Most packaging inspection uses rule-based machine vision. AI is used where defects are visually complex, variable, or cannot be fully characterised in advance.
How many training images does an AI vision inspection system require?
A production-ready AI inspection model requires a minimum of 1,000–5,000 labelled defect images per defect class, covering the full range of lighting conditions, surface variation, and defect severity. Rare defects are particularly difficult to train because real defect examples may not exist in sufficient volume. Always ask vendors for training data documentation and real production validation data — not lab demo performance.

Need the Right Vision System for Your Line?

Not AI for the sake of it — the right technology for your specific inspection problem. Our applications engineers will give you a straight answer.

Speak to a Vision Engineer Request a Live Demo