Capsule Defect Detection Hero Background
Case Study | Pharmaceutical Manufacturing

Capsule Defect Detection & Rejection System

When a filling machine outputs 60,000 to 120,000 capsules per hour, a single microscopic crack or loose cap isn't just a cosmetic flaw — it is a patient safety threat, a contamination risk, and an imminent batch recall. Discover how Techasoft built a real-time computer vision system that inspects every capsule across 360 degrees and autonomously ejects defects without slowing production.

The Plant Background

Our client, a high-volume pharmaceutical formulation manufacturer, operates round-the-clock lines for hard gelatin and HPMC capsules. For years, quality assurance relied on spot-sampling and manual visual inspection tables. But as production quotas scaled, human visual limits created an unsustainable operational trade-off between line speed and audit compliance.

The Human Bottleneck

Staring at thousands of glossy, vibrating capsules under fluorescent lights causes severe eye fatigue within 20 minutes. Minor variations between shift operators led to subjective decisions, borderline units slipping through, and pallets held in QA quarantine for days awaiting manual re-checks.

Services Delivered

End-to-End Product Engineering, Computer Vision Metrology, Edge Hardware Retrofit, High-Speed PLC Actuation, Real-Time Telemetry Analytics, and GMP / 21 CFR Part 11 Validation Support

Engineering Tech Stack
PythonOpenCVPyTorchTensorRTJavaKafkaRedisReactMS AzureCosmos DBGigE VisionIndustrial PLC
The Engineering Challenge

Small, Curved, Glossy & Moving at Line Speed

Gelatin and HPMC capsules act like miniature curved mirrors. Standard cleanroom lighting generates harsh glare spots that blind standard vision cameras or trigger false alarms on good units.

Techasoft's engineering team engineered a dual-intelligence optical architecture that solves the physical and mathematical hurdles of high-speed inline inspection:

1. Deep Learning Surface Classification

Convolutional neural networks were trained on over 250,000 real production images to distinguish harmless optical reflections from genuine hairline fractures, shell dents, discoloration, and partial print degradation.

2. Sub-Pixel Geometric Metrology

Edge algorithms measure exact outer boundaries within $\pm 0.05\text{ mm}$ tolerance, calculating length, diameter, and cap-to-body joint positioning to catch locked, short, or telescoped units in real time.

SCAN_INSPECTION_MODE CONTINUOUS_INLINE_360
CAMERA_EXPOSURE_SYNC SYNCHRONIZED (2000 FPS)
CLASSIFICATION_CONFIDENCE 99.4%
INSPECTED_UNIT PASS (BATCH_A418)
PNEUMATIC_EJECT_ACTUATOR REJECT (HAIRLINE_FRACTURE)
Comprehensive Defect Taxonomy

Zero Tolerances for Real-World Defects

Every defect type carries direct consequences for patient health, formulation integrity, and packaging equipment uptime. Our AI identifies and classifies each flaw within milliseconds.

Shell Integrity & Mechanical Defects

Hairline Cracks, Splits & Pinholes

Prevents atmospheric moisture and oxygen from leaking into the shell and degrading the active pharmaceutical ingredients (API).

Loose, Telescoped & Split Caps

Stops powder leakage that contaminates blister machines and downstream cleanroom machinery.

Deformed, Crushed & Double Caps

Eliminates mechanical feeder jams that bring high-speed bottle-filling and blister packaging lines to an abrupt halt.

Foreign Particulates & Surface Powder

Detects stray debris or residual formulation powder adhered to the shell before secondary packaging.

Dosage, Color & Serialization Verification

Under-Filled & Short Capsules

Combines geometric volume estimation and density metrology to ensure exact therapeutic dosage delivery to every patient.

Cap & Body Color Mismatch

Catches subtle hue shifts between cap and body parts that signify batch cross-contamination or formulation blending errors.

Missing, Faint or Misaligned Printing

Verifies product brand names, dosage strengths, and logos against GMP serialization readability standards.

360-Degree Multi-Size Geometry

Automated calibration handles all standard gelatin and plant-based HPMC sizes (from Size 000 down to Size 5).

Architecture & Delivery

Cleanroom Edge Intelligence

A robust, modular edge-to-cloud architecture guarantees microsecond inference on the factory floor while streaming tamper-evident batch telemetry for compliance auditing.

Representative Solution Architecture
  • Optical Acquisition: High-speed IP69K GigE area-scan cameras with custom strobed diffuse dome lighting and optical triggers.
  • Real-Time AI Pipeline: TensorRT-optimized PyTorch convolutional models running multi-class classification and sub-pixel edge metrology.
  • PLC Actuation & Ejection: Microsecond hardware pulse signaling driving high-velocity pneumatic air-jet ejectors into isolated quarantine bins.
  • Audit Telemetry: 21 CFR Part 11 compliant event logging, ALCOA+ data integrity, and real-time shift analytics.
The Collaborative Journey

From Plant Assessment to Live Production

We worked side-by-side with plant operations, quality assurance, and maintenance engineers to deliver a non-disruptive, plug-and-play installation.

Real-World Dataset Harvesting & Annotation
01

Real-World Dataset Harvesting & Annotation

Instead of relying on synthetic or idealized lab data, we collected over 250,000 raw production images directly on the client's operational line. Working alongside senior QA inspectors, every image was rigorously tagged with precise defect categories across varying shell opacities, sizes, and lighting conditions.

02

AI Training & Threshold Fine-Tuning

We trained deep learning models to identify microscopic anomalies while avoiding false alarms on harmless glare reflections. The models were iteratively validated against unseen production batches until meeting strict QA threshold criteria for zero false acceptance and ultra-low false scrap rates.

AI Training & Threshold Fine-Tuning
Non-Intrusive Cleanroom Retrofit
03

Non-Intrusive Cleanroom Retrofit

Compact, IP69K-rated optical stations were integrated directly downstream of the filling and deduster stages without requiring mechanical redesign of the existing conveyor. High-speed GigE cameras capture 360-degree views in milliseconds without interrupting throughput.

04

Deterministic Fail-Safe Ejection

Upon high-confidence defect detection, the system commands the line PLC to fire a targeted, microsecond air-jet pulse that effortlessly diverts the defective capsule into a locked quarantine bin, while good product continues unobstructed to packaging.

Deterministic Fail-Safe Ejection
Extending the Platform

One Vision Foundation, Eight Pharma Applications

The same underlying edge-vision technology adapts seamlessly across all dosage, primary packaging, and serialization checkpoints across the pharmaceutical plant.

1. Capsule & Tablet

High-speed checks for chipping, splits, thickness variation, and color shading at maximum continuous line speed.

2. Blister Pack QC

Verifies completeness of every blister cavity, detects crushed pills, and verifies foil seal integrity in a single snapshot.

3. Vials & Infusions

Inspects cap crimping, rubber stopper seating, glass fissures, fill heights, and floating particulates inside liquid solutions.

4. Track & Trace

Instantaneous verification of 1D/2D GS1 Data Matrix codes and human-readable serialization text up to 40,000 units/hr.

5. Bulk Aggregation

Multi-unit parent-child verification during bundle aggregation, case packing, and automated palletizing.

6. Tamper Evidence

Automated verification of tamper-evident seals, hologram stickers, and tuck-flap glued closures to prevent adulteration.

7. Label Presence

Confirms that the correct label, language, and clinical literature insert are present and aligned before carton dispatch.

8. Batch OCR & OCV

Advanced Optical Character Recognition and Verification reading lot codes, expiry dates, and MRPs on fast-moving packs.

Hardware for the Pharma Floor

Built for Cleanroom Rigor & Daily Washdowns

Pharmaceutical production floors undergo aggressive daily sterilization using vaporized hydrogen peroxide and pressurized chemical washdowns. Our hardware is engineered to endure harsh cleanroom sanitization without optical calibration loss.

IP69K Washdown Protection

Hermetically sealed 316L stainless steel enclosures withstand high-pressure, high-temperature chemical sanitization cycles.

Hygienic EHEDG Design

Crevice-free contours and mirror-finish surface roughness below 0.8 µm eliminate bacterial niches and powder accumulation.

Modular Quick-Swap Optics

Interchangeable C-mount lenses with integrated illumination controllers snap into place for fast changeovers between capsule sizes.

Thermal Zone Resilience

Passive heatsink thermal engineering ensures sensor stability in both air-conditioned cleanrooms and high-humidity processing areas.

Regulated by Design

Compliance That Gives QA Directors Peace of Mind

In regulated life sciences, accuracy without auditability is useless. We designed every layer to exceed FDA, EMA, and WHO cGMP requirements.

Tamper-Evident Audit Trails

Every single inspection decision, rejected frame, parameter tweak, and operator login is encrypted and digitally signed to batch records.

21 CFR Part 11 & ALCOA+

Electronic record governance ensures data is Attributable, Legible, Contemporaneous, Original, and Accurate at every stage.

Validation Ready (IQ/OQ/PQ)

Turnkey validation documentation packages aligned with GAMP 5 principles to accelerate qualification and regulatory sign-offs.

Controlled AI Versioning

Neural network model iterations are version-locked, benchmarked against historical validation datasets, and formally approved prior to release.

Real-Time QA Telemetry

Quality directors can view defect frequency trends by shift, machine, and capsule batch in real time, catching mechanical issues early.

Role-Based Access Control

Strict multi-tiered authentication ensures only authorized plant QA managers can alter sensitivity thresholds or export batch records.

Tangible Operational Impact

Real-World Results That Speak for Themselves

The automated vision system transformed quality control from a slow, stressful sampling bottleneck into an autonomous, 100% inline guarantee of excellence.

99.4

Defect Detection Accuracy (%)

85

Reduction in Manual Inspection Hours (%)

92

Fewer Defect-Related Batch Holds (%)

Flawless 100% Inline Quality

Every single capsule is inspected rather than a small statistical batch sample. Decisions remain 100% consistent with zero operator fatigue or shift bias.

Full Production Speed Unleashed

Eliminated manual sorting bottlenecks, empowering encapsulation machines and packaging lines to run at full rated capacity with zero inspection delays.

Recall Risk & Cost Reduction

Catching defects immediately prevents expensive batch scrappage, market recalls, customer complaints, and catastrophic brand damage.

Stress-Free Audit Readiness

Complete digital audit trails and defect analytics give QA leaders transparent, traceable proof for regulatory agencies and customer quality audits.

Ready to Modernize Your Pharmaceutical Quality Control?

Whether you're looking to automate capsule inspection, blister verification, or end-to-end serialization, Techasoft delivers high-speed, GMP-validated AI vision solutions tailored to your production lines.

360° Optical Inspection  |  21 CFR Part 11 Compliant  |  Zero Line Disruption
Schedule an Engineering Consultation

Speak directly with our computer vision engineers. A brief discussion is all it takes to get started.

×