Inspection task
A counting mask must preserve each component without turning tray ribs into parts. Compare backlight for opaque silhouettes with diffuse overhead light when the tray cannot transmit light. Place the ROI beyond every valid component outline but decide explicitly what happens when a component crosses its boundary. An arbitrary crop can change the count without changing the physical contents.
Prerequisites and sample controls
State the expected number and what constitutes one physical component. Prepare correctly filled, short-filled and touching-part samples, with independently counted answers. The baseline counts separated connected regions, not hidden objects. A connected region can contain several touching parts, while a single shiny part can break into several regions. Keep these limitations in the sample definition before choosing a counting threshold.
Choose the camera route
Use an area-scan camera when the full tray fits in one triggered frame. Choose monochrome for silhouette contrast and color only for an actual color requirement. Motion during feeding calls for verified global-shutter timing or a settled capture position. A line-scan route needs motion reconstruction; it is not an automatic improvement for a stationary tray.
Run the controlled procedure
Use the same original parts when comparing light arrangements, and keep the camera, exposure and lens position fixed. Establish the region of interest in original-image coordinates and include every allowed loading position. A crop removes irrelevant background but cannot recover an invisible target. Check the full image before accepting a smaller ROI, especially when the fixture or part can move.
- Capture the same tray under two accessible light geometries.
- Inspect bright holes and dark bridges in the binary mask.
- Place a component across each ROI border as a failure control.
- Freeze light and ROI before adjusting component area filters.
Process map
Full-image inspection precedes ROI and area filtering. Light should preserve visible separation before regions are counted.
- Full image
- Light control
- ROI
- Visible target
Record the evidence
For each arrangement, record eligible regions, excluded tray regions and border-crossing flags. In the stated 3-part example, keep the physical expected count at 3. A mask count of 3 is insufficient if a rib was counted and one part was missed.
Build a mask audit from physical part identity rather than final totals. Label the actual parts in the raw image using a separate annotation layer, then associate each eligible mask region with one of those parts. Where a region spans more than one label, record a merge; where several regions map to one part, record a split. Keep tray-only regions in a separate artifact class. Repeat this mapping for each light arrangement using the same physical tray contents. A correct total can contain a merge and an extra artifact that cancel numerically, so the audit must explain every individual contribution. Check internal holes and thin tips as well as outer silhouettes. A lighting arrangement that closes gaps or produces fragmented reflections should be rejected or explicitly bounded before any count rule is accepted.
| Control | Required observation | Decision boundary |
|---|---|---|
| N3: 3 separated parts | 3 eligible regions expected in this example | Compare with independent physical count |
| N2: 2 separated parts | 2 eligible regions expected in this example | Short fill; do not change the expected 3 |
| T3: 3 touching parts | Region count may differ from 3 | Review; connected regions are not physical objects |
Diagnose failed cases
Closing can join touching parts; opening can erase a small part or break a thin feature. Inspect before/after masks for each proposed kernel. Do not accept a morphological change solely because its final count happens to match the expectation.
Failure isolation
Compare split parts, joined parts and tray foreground. Matching the total does not prove correct individual regions.
- Separated
- Joined
- Split
- Tray feature
Validate independently
Change only one light variable in each trial: geometry, intensity or ambient shielding. Compare raw image contrast, saturation and the resulting mask before changing a decision threshold. Save both the successful and unsuccessful arrangements. The useful choice is the one that separates relevant classes over the allowed variation, not the one that makes a single sample look attractive.
Verify independently separated small and large parts at every tray location. Treat border clipping as review or a defined loading failure; never count an invisible remainder by assumption.
Test the region boundary deliberately. Move a valid separated part so that its outline crosses the ROI, while keeping the rest of the tray unchanged. Observe whether the pipeline counts the partial region, rejects it or flags it for review; compare that behavior with the declared loading policy. Move the part fully inside again and verify recovery without changing thresholds. Then repeat the boundary test at another edge and inspect the original-coordinate mapping. Do not assume a crop-local border flag has the same meaning after scaling or rotation. If a morphological filter is proposed, run the border and touching controls through both the unchanged and modified masks. Acceptance of the filter requires preservation of the intended part identities and explicit handling of incomplete visibility, not merely a better total. Save the chosen light, ROI and operation sequence together.
Continue the engineering handoff
Provide the light arrangement, ROI coordinates, raw frames and masks for review. Explain whether the task requires a silhouette or a top-surface feature before selecting Deyi Vision lighting and optics. Do not silently resize a crop; any coordinate or scale conversion must be explicit in the saved workflow.
Save the original image and the resulting record together.
Sources and technical references
These references explain the methods and limits used in this tutorial. Example checks are guidance; production acceptance requires evidence from your own samples.
- Machine vision lighting basicsDeyi Vision
Illumination geometry determines whether a surface feature or silhouette is visible.
Checked - Image thresholdingOpenCV
Thresholding converts image intensity into a binary segmentation; this does not identify semantic objects.
Checked
Component and selection references
- Automated Visual Inspection
- Industrial 2D Cameras
- Machine Vision Lighting
- Visual Inspection System Design Checklist
- What Is Machine Vision?
- Machine Vision Systems
- Machine Vision System Components
- How Does a Machine Vision System Work?
- PCB Connector Pin Presence Inspection
- Industrial Barcode Readers
- Component counting: camera setup for separation
- Component counting: merged and split part diagnosis
- Part positioning: acceptance and motion handoff
- Part positioning: an AI-assisted pixel workflow
- Part positioning: camera and coordinate setup
- Part positioning: lighting and ROI stability
- Part positioning: locate the cause of pick offset
- Presence inspection: acceptance and line integration
- Presence inspection: build an AI-assisted workflow
- Presence inspection: a reliable camera setup
- Presence inspection: lighting and ROI control
- Presence inspection: isolate false-pass causes

