LINGBANG · VisionAgent Capsule Appearance Inspection · Few-shot Segmentation · ~6 min read 中文
FIELD DEPLOYMENT RECORD

Capsule Appearance
Defect Inspection

From dents and depressions to scratches, dark streaks, pitting and bubbles — and under-fill revealed by backlight — turning “which capsule is defective” into rules you can segment, judge and reject. A single dented cap or a short-filled body has to be pulled before it leaves the line, without over-rejecting good ones.

Dent / depression Scratch / streak Pitting / bubble Backlight under-fill Few-shot segmentation
Capsule cap depression segmentation mask
On-site capture
Capsule appearance · AI segmentation mask · dent / depression

Capsule appearance inspection is hard not because photographing one capsule is hard, but because in a fast discharge stream every dent, depression, scratch, pit and — under backlight — every under-fill has to be caught reliably: good ones not over-rejected, NG ones not let through.

This article is based on the real segmentation renders from the Renhe Pharmaceutical capsule inspection, laid out as target → defect families → imaging & lighting → operator chain / judgment / parameter dictionary → live dashboard. The mask colours match the field: magenta marks dents / depressions, orange marks scratches / dark streaks, and cyan marks the light-transmitting fill band under backlight. UI screenshots are drawn to the product's real controls and wording.

01

The target: which faces of a capsule matter

The target is a grey, semi-translucent hard capsule with a cap and a body telescoped together. The difficulty: a capsule is a curved, semi-translucent, easily rolling small part; its defects are small and low-contrast, and even good capsules carry natural texture and specular variation. The system uses semantic segmentation masks to carve the defect region out of the shell — not just draw a box — so a dent's boundary and an under-fill's shape become measurable.

Magenta · dent / depression Orange · scratch / dark streak Cyan · backlight fill band
Capsule cap dent and depression

▲ Defect: two depressions at the cap end, dents outlined by the magenta mask

Good capsule

▲ Good: cap and body fully telescoped, surface clean, no mask

02

Defect families: five NG classes to pull out

From field samples and segmentation results, capsule appearance NGs fall into five families, each mapping one-to-one to the defect dictionary later:

D1Dent / depression
D2Scratch / streak
D3Pitting / bubble
D4Under-fill (backlight)
D5Good / OK
Cap dent with bubble

▲ D1 dent + D3 bubble: magenta on the cap depression, a bright bubble inside

Capsule surface scratch streak

▲ D2 scratch / streak: orange outlines the thin dark streaks on the body

Capsule multiple defects

▲ D2 + D1 mixed: several scratches and depressions on one capsule

Under-fill is deadlier than a surface blemish

Dents and scratches affect appearance and sealing; but under-fill / hollow directly affects dosage and is nearly impossible to see through with front light. It must be revealed by backlight transmission before judging. The two defect types need two kinds of light.

03

Imaging & lighting: front diffuse + backlight, two stations

One kind of light cannot show every defect. The solution splits the work across two imaging stations:

Front diffuse
Even, shadow-free light on the capsule surface suppresses glare and lifts contrast, targeting dents, depressions, scratches, streaks and pits.
Backlight
The capsule sits over a light panel and is imaged against it; the filled shell band transmits as a bright zone, while short-fill / hollow / under-fill appears as a dark notch — obvious at a glance.
Sampling spec
Fix the light shape, exposure and magnification of both stations first, then talk about the model — each capsule yields one image per light, each fed to its matching segmentation operator.
Single capsule under backlight

▲ Backlight station: cyan outlines the light-transmitting fill band

Under-fill under backlight

▲ Backlight station: a dark notch in the mask band = under-fill

Fix the light first, then the model — solve “seeing through the fill with front light” by changing light, not by force-tuning the algorithm.
04

Workflow: a few-shot segmentation operator chain

FLOW

Drag-and-drop the inspection chain

Operator library · no-code

Create the project “Capsule appearance inspection”, drag operators from the left library and connect them (matching the real canvas):

Industrial camera Preprocessing Few-shot segmentation Defect detection Grading
Camera
Front and backlight channels capture separately, covering a single- or multi-capsule field; multi-channel trigger supported.
Preprocessing
De-glare, flatten and enhance to stabilise the low-contrast texture of the semi-translucent shell.
Few-shot seg.
A few labelled samples segment dents / scratches / pits / fill band, replacing per-class tuning of traditional AOI.
Defect detect
Convert masks into metrics — area / length / notch ratio — and check against thresholds.
Grading
Take the strictest across defects, output the capsule's OK / NG and NG type, driving the reject.
VisionAgent · Tensor-flow canvas — Capsule appearance inspection5 operators linked
OPERATORS
Industrial camera
Preprocessing
Few-shot segmentation
Defect detection
Grading
Data archive
CAM
Camerafront/back
PRE
Preprocessflatten
SEG
Few-shot seg.dent/scratch/fill
DET
Detectarea/notch
JDG
GradingOK / NG

▲ Tensor-flow canvas: camera → preprocess → few-shot segmentation → defect detection → grading (real UI style)

Process engineers can read the flow; adding a new defect class only needs more samples, not new code.
05

Judgment: turning masks into defect events

EVENT

Turn “cap depression” into a standard judgment

Primitives · area threshold

Open the “GPU event orchestrator”; the top reads “Configuring defect: dent / depression”. Drag in the primitive “region area > threshold”:

  • The defect list on the right: D1 dent/depression, D2 scratch/streak, D3 pitting/bubble, D4 under-fill, D5 colour/soil… unconfigured ones read “pending”;
  • Under-fill uses a “backlight mask notch ratio > threshold” primitive; scratches use an “elongated region length / aspect ratio” primitive;
  • Each class binds an area / length / count threshold; crossing it fires the matching NG and drives the reject valve.
GPU event orchestrator — Configuring defect: dent / depressionPrimitive · region area
PRIMITIVES
region area > th.
notch ratio > th.
aspect / length
grey contrast
count = N
DEFECT JUDGMENT LIST
D1Dent / depressionconfiguring…
D2Scratch / streakconfigured
D3Pitting / bubbleconfigured
D4Under-fill (backlight)configured
D5Colour / soilingpending

▲ GPU event orchestrator: configuring “dent / depression” = primitive “region area > threshold” (real UI style)

Thresholds decouple from perception — tighten or loosen grading by tuning thresholds, no retraining.
06

Camera & page parameters

PARAMS

Defect dictionary / display parameters

Parameters · page params

Open “Parameters” and switch to the page parameters tab. The left “defect statistics” align with the defect families for per-batch NG reporting:

  • Columns: defect type (NG0…NG4), defect name (dent/depression, scratch/streak, pitting/bubble, under-fill, colour/soil), count;
  • “Add / remove defect type” is supported; edit name and threshold on the right, click “Save parameters” to apply;
  • Result display: mask overlay on, defect name on, font size 40, line width 2 — matching the field mask look;
  • On the camera side, the “Industrial camera” node configures front / backlight channels, exposure and ROI so a single capsule is fully framed.
Parameters · page parametersSave parameters
TypeDefect nameCount
NG0Dent / depression3
NG1Scratch / streak2
NG2Pitting / bubble1
NG3Under-fill2
NG4Colour / soiling0
Mask overlay
Show defect name
Font size40
Line width2
Camera channelFront + Back
ROISingle-capsule

▲ Parameters · page params: defect dictionary and display settings (real UI style)

Defect name, NG code, threshold and overlay are set once; the live dashboard and batch report share one dictionary.
07

Live run: a real-time grading dashboard

RUN

Monitoring and verdict on one screen

Edge runtime
  • Left: live view + segmentation mask, marking the current capsule's dent / scratch / fill band;
  • Right: a five-class defect checklist — dent/depression, scratch/streak, pitting/bubble, under-fill, colour/soil; hits marked red;
  • Verdict: any class over threshold → NG, counted by class and reject driven; only a full miss lets the capsule pass.
Live monitor — Camera 01 · Capsule appearance stationEdge running
Live monitoring view
Live · backlight fill judgment
D3Pitting / bubble · miss
D2Scratch / streak · miss
!D1Dent / depression · hit
!D4Under-fill · hit
D5Colour / soiling · miss
Verdict NG · hit D1 dent + D4 under-fill → reject

▲ Live monitor: live segmentation on the left, five-class verdict on the right

Configuration, recognition, grading and reject verdict live on one screen; the line can be accepted the same day.
08

Comparison table & takeaways

AspectManual sorting / traditional AOIVisionAgent capsule inspection
SurfaceVisual check under lamp, fatigue & missesFew-shot segmentation outlines dents / scratches / pits live
FillFront light can't see through; weighing spot-checksBacklight mask notch ratio judged per capsule
StandardBy the master's experience, person to personArea / length / notch-ratio thresholds grade uniformly
ChangeoverTraditional AOI retunes per classJust add a few samples; thresholds decouple from perception
RecordsPaper spot-checks filled in laterPer-capsule result and defect type auto-logged into reports

Four questions run throughout: what the system looks at, what counts as good, when to reject, and how results reach the report.

Closing note

Capsule appearance inspection is hard not because of photographing one capsule, but because of chaining capture → few-shot segmentation → defect metrics → grading & reject → batch logging into a link the floor is willing to use and quality can re-audit.

In one line: changing the light decides whether it can be seen, few-shot segmentation decides whether it can be recognised, threshold primitives decide whether it can be judged — no-code turns capsule sorting from “eyeballing” into “system grading, capsule by capsule”.
b
blue
PhD in computer vision · VisionAgent solutions and delivery

Works on few-shot segmentation and industrial scene understanding; argues for moving appearance QC from “one long training run per defect” to “few-shot segmentation + event composition + state-machine aggregation”, so thresholds decouple from perception and a grade change needs no retraining.

Currently focused on edge GPU inference, cross-domain generalisation and closing the data loop on site. This piece records the family grouping, sampling derivation and platform configuration path behind a battery tab inspection plan.