An anomaly detection model learns what a normal part looks like. If normal parts are imaged at a different angle every time, the range of normal the model must learn grows to include every rotated view. The wider that range, the more small defects get buried inside it. Alignment removes this problem right after capture.
Round Parts: Ring Alignment
Round parts such as bands, rings and bearings are aligned in this order. The Multi-Inspector rotation-fix mode works this way.
- Find the center — Get the part center with circle detection (Hough Circle) or by fitting a circle to the contour (circle fitting).
- Find the direction — A circle looks the same when rotated, so find the angle of a feature that exists in only one place, such as a tab or ear.
- Rotate and shift — Move the center to the image center and the feature to the 12 o'clock direction.
Arbitrary Shapes: Shape (PCA) Alignment
A non-round part such as a seat belt buckle has no circle to find. Instead, get its pose from the image moments of the part region.
- First moment (centroid) — The position of the part.
- Second moment (principal axis) — The direction in which the part extends longest. This is the same calculation as principal component analysis (PCA).
- Third moment (asymmetry) — The principal axis alone cannot tell front from back when the part is flipped 180°. Define the side with more mass as the front to remove this ambiguity.
The technical note How to Align Non-Round Parts gives the details of the calculation and settings. If you need only position and not orientation, use Center-Only alignment.
Judging After Alignment: yolo_align
The Multi-Inspector EB line build supports the yolo_align mode from v2.2. It aligns and centers the part, then finds defects with YOLO. Defects always appear at similar positions and orientations, so detection is more stable even with the same amount of data. For setup details, see the yolo_align mode note.
Training and Inspection Must Use the Same Alignment
Alignment runs once at training time and again at inspection time in the field. If the two differ even slightly, the model receives images unlike those it trained on. So Multi-Inspector reuses as is the alignment settings made in fineAi Image Processing Tool. The alignment that prepared the data and the alignment that runs on the line give the same result.
Preparing for Failure
Alignment finds features in an image, so it can fail. Examples are a part captured half cut off or a momentary lighting flicker. When alignment fails, Multi-Inspector continues judging on the original image and writes a log. An alignment error does not stop the line, and you can collect the failed images later to analyze the cause.
When Not to Use Alignment
- If the part is fixed in a jig and always imaged in the same place, you do not need alignment.
- For targets with no consistent shape (food, produce, etc.), it is hard to define an alignment reference. Use a model that tolerates position change (such as AnomalyDINO) or YOLO without alignment. See the lesson Choosing an Anomaly Detection Algorithm.