When deploying AI visual inspection for nonmetal foreign matter in food packaging, start with a physical question: where, when and under what light is the fragment actually visible? A plastic chip, hair, paper fibre or wood splinter exposed in an open tray before sealing is a different inspection problem from a fragment hidden inside an opaque pouch. An ordinary visible-light camera cannot establish the absence of an object it cannot see. This guide shows food and beverage plants in Thailand how to specify, buy and accept an inspection cell for *visible, pre-seal* foreign matter. It gives quality, production engineering, maintenance, IT/OT and purchasing teams a shared set of boundaries and acceptance evidence.
Inspection is one layer of foreign-material control. FDA hazard-analysis draft guidance (Draft–Not for Implementation) describes physical hazards including hard plastic from cracked tools or containers, as well as glass and metal from equipment or packaging. That US draft is a useful framework for identifying sources; it does not automatically impose a US legal duty on every Thai factory. Source prevention, maintenance, sieving, metal detection, X-ray and visual inspection have complementary roles. A camera installation alone does not complete a hazard analysis.
1. Define the target as *visible* nonmetal material
“Find all nonmetals with AI” is not an acceptance criterion. A dark plastic chip against a white tray may have usable image contrast. A clear chip immersed in pale sauce, wood hidden underneath food, or a fragment behind printed opaque film may have none. AI cannot inspect information absent from the image. Record that boundary in the specification before a proof of concept (PoC), rather than discovering a disagreement after a successful demonstration on a few easy samples.
Describe each target by material, colour, shape, thickness, smallest agreed size, surface condition, position, overlap with food, stage before or after sealing, and packaging transparency. “Nonmetal” includes plastics, rubber, paper, wood, insects, fibres, hair, shell and bone; these are not one visual class. Clear or product-coloured fragments deserve separate trials. The quality team sets hazard priority for the actual product and consumer; imaging feasibility is demonstrated with real or approved representative samples.
| Specify | Evidence to retain | Decision owner |
|---|---|---|
| Material and likely source | Broken parts, utensils, packaging or raw-material samples | Quality and maintenance |
| Visible location | Open tray, exposed product surface, clear film or pre-seal rim | Production and quality |
| Size and background | Dimensions, colour, wetness, reflectance, food overlap | Quality and vision engineer |
| Exclusions | Opaque packs, fragments completely covered by product | Quality owner |
| Response | Reject item, stop line, hold lot, investigate source | Quality and production owners |
An exclusion still needs a control
An object the camera cannot see is not an object the plant may ignore. Evaluate upstream prevention, material inspection or a suitable downstream method. X-ray can inspect some internal foreign bodies, but it too has limits. METTLER TOLEDO explains X-ray detection through differences in absorption, influenced by material density, size, shape, position, product and pack. Anritsu identifies low-density wood and common plastics near the density of the food as challenging; detectability depends on the product and fragment size. Do not turn a vendor’s list of detectable materials into a guarantee for your SKU. Our metal detector and X-ray selection guide covers those methods; this article focuses on where a visible-light cell adds value.
2. Map the process before choosing a camera position
The best camera location is not simply the available length of conveyor. Walk from the last plausible contamination point to sealing and find the stage where product is exposed, least overlapped and most repeatably positioned. For filled open trays, this may be after filling and before entry to a sealing machine. For bagged products, a thin-layer feed before bagging may be better than looking through a printed pouch. An overhead image of a closed opaque pack cannot reveal its contents.
Draw raw-material feed, sorting, filling, tray alignment, image capture, decision, rejection, reject verification, sealing and downstream inspection in order. Mark each possible new contamination source. If a seal jaw or guide can shed material after the camera, that later risk needs its own control. Production and quality should walk the line together, note tooling or film changes, and define the exact inspection window.

At each candidate location measure product spacing and stability. Touching trays can break item tracking; changed fill volume alters shadows and overlap; clear film reflects light; tray texture may resemble a defect. If daylight or night-shift lighting changes the image, use a guarded enclosure and controlled light. Collect images under normal operation and after cleaning. Training AI to compensate for uncontrolled hardware is a poor substitute for stable optics.
3. Test lighting and background before model choice
KEYENCE’s machine-vision lighting guide explains why reflected, diffuse and transmitted light, illumination angle, colour and wavelength determine contrast and repeatability. More camera pixels will not create a contour when a white chip is invisible against white food. Diffuse light may reduce glare on film; transmitted light can reveal a silhouette on a suitable translucent carrier. It cannot shine through thick opaque food or a solid tray. Ask suppliers to present *raw images* from each proposed light arrangement, not only marked-up AI output.
The imaging sheet should show field of view, target size in pixels, working distance, depth of field, exposure, strobe timing, conveyor speed and trigger delay. There is no universal pixel count that guarantees detection. Capture actual samples with candidate lens and light, varying position, pose, colour and background. Compare a top camera with an oblique second view where useful, but draw the visible and hidden zones of each view. Additional cameras do not automatically remove every occlusion.
Water, oil, condensation and changing temperature can move highlights or fog a protective window. Define cleaning and replacement of the window, and verify a reference image after anyone touches the optics. Keep the original capture distinct from the preprocessed model input. That distinction lets an engineer tell whether a missed object was absent from the captured image or lost during processing.
Collect failure cases, not only attractive examples
Position the smallest target at edges, recesses, wet surfaces, tray rims and shadowed areas, alongside normal ingredients and film patterns. Never introduce hazardous test pieces into saleable product. Use a separated and controlled test batch, approved by quality, with issue, recovery and disposal records. A surrogate fragment must be described as a surrogate; its colour and reflectance may differ from the real contaminant. Passing a surrogate test alone does not establish performance on every real fragment.
4. Limit AI’s role to decisions based on captured images
An inline cell must (1) trigger an image for an item, (2) isolate the inspection region, (3) evaluate suspicious areas, (4) issue pass, reject or review for that *same item*, and (5) physically handle and record it. The AI model mainly supports step 3. It does not solve double triggers, mismatched IDs, missing images, network loss or a jammed reject gate. Model evaluation and end-to-end line evaluation must both pass.
Threshold, colour or geometry rules may be sufficient for a repeatable target. Compare AI where normal ingredients vary widely or the boundary between product and contamination is complex. Separate training and validation by SKU, pack, lot, lighting condition, shift and cleaning state. Do not mix near-identical pictures from one lot into training and acceptance sets. The buyer should hold a sealed acceptance set that the supplier cannot tune against.
A “review” state helps quality staff handle ambiguous images, but a review item cannot continue to saleable output while nobody is available. Specify a secure hold lane, controlled stop or equivalent process. Make the rule work on night shift as well as day shift. Our general AI visual inspection implementation article provides a wider planning framework; foreign-material inspection adds a stricter need to document visibility and sample control.
5. Build learning and acceptance samples by condition
A total such as “100 good and 100 bad images” says little about coverage. Make rows for product and package combinations, foreign-material class, dimensions near the agreed minimum, placement, background colour, wetness, wrinkles, glare, speed and light changes. Even if real contamination is rare, deliberately test conditions that the hazard analysis prioritises. Mark untested conditions as unverified, with an interim control or exclusion. Never report them as validated.
Quality approves minimum targets by material. Engineering measures maximum speed and minimum spacing. Maintenance checks reject and guarding constraints. The supplier identifies each position successfully imaged and provides the raw image and decision region. Tie every result to item ID, lot, time and physical disposition. Vary placement to avoid a model appearing to learn one fixed location rather than the foreign body.
Report missed target pieces, false rejects of sound product, review rate, image failures, reject failures, hold time and stoppage separately. State sample denominators and uncertainty; “100% detected” in a small trial is not a production guarantee. Overall accuracy is especially misleading for rare contaminants because a system answering “pass” for every item can still have a high overall score. Quality defines the acceptance threshold from risk and signs it with the supplier.
6. Treat capture, tracking and rejection as one cell
Calculate camera-to-reject distance with conveyor speed, encoder or item tracking, item spacing, PLC cycle, inference and communication latency, and the response of the air jet or gate. A red NG indicator on a screen is not a rejected item. In site acceptance testing (SAT), change speed, stop and restart, remove an item upstream and challenge the tracking logic. Our high-speed visual inspection guide discusses trigger-to-PLC design; foreign-material projects must add material classes and hold disposition.

An NG command sent to a PLC is insufficient evidence of removal. Consider gate-position sensing, passage detection into the reject bin, a full-bin signal and controlled access to held product. Correlate trigger and physical rejection timestamps under one item ID. Test consecutive rejects, jams, power recovery and communications loss. Decide in advance when to stop the line and which output interval to hold after an uncertain event.
Decide fail-safe behaviour before installation
Specify what happens when a camera misses a frame, light fails, a window becomes dirty, an edge computer stops, PLC communication fails or the reject bin fills. Do not issue an OK on inspection failure. Depending on the process, stop, reject or hold affected items. Test physical action, not merely an alarm screen. After recovery, define which items require reinspection; a backlog must not silently become accepted product.
7. Keep the hazard plan and other inspection technologies aligned
The FDA preventive-controls overview describes identifying reasonably foreseeable physical hazards and documenting controls. Thai plants must apply their own local law, customer requirements, certification scheme and HACCP plan. Installing a camera is not a reason by itself to remove a metal detector or X-ray unit. Metal detection or X-ray may address metals; X-ray can address some internal bodies with sufficient density contrast; a camera may address visible surface objects with usable optical contrast. Confirm the choice with samples for each SKU and pack.
Metallised film, thick products, glass containers and multilayer materials alter the suitability of each method. Put product, pack, fragment material and size, position, speed, stage and outcome in the trial record. Quality decides whether a checkpoint is part of a formal food-safety control or an additional quality screen, with monitoring and deviation actions that match that decision. “AI-powered” is not a substitute for that designation.
| Target situation | Initial observation method | Practical limit to test |
|---|---|---|
| Exposed coloured plastic, paper or hair before sealing | Camera, designed lighting, optional AI | Occlusion, shadow, clear or same-colour material |
| Metal inside a finished pack | Metal detector or X-ray | Pack material, product effect, size and position |
| Stone, glass or bone with density contrast inside a pack | X-ray candidate | Product thickness, density and container |
| Low-density piece hidden under product or opaque film | Upstream prevention or earlier inspection stage | Visible-light camera has no view of it |
8. Put measurable conditions in the RFP
Give bidders the target samples, hazard priority, exclusions, response and acceptance conditions, not just photographs. Specify SKU and pack range, expected changes, speeds, shifts, floor space, hygienic zone, cleaning chemicals and method, air and power, existing PLC and interface constraints, data location and operator language. For a Thai plant, explicitly define Thai operator screens, the agreed maintenance language and night-shift contacts. Hygiene and enclosure requirements must reflect the actual cleaning process; one IP rating does not settle all design questions.
Compare the complete cell cost: cameras, lighting hood, conveyor alteration, guides, triggers, encoder, reject mechanism and verification sensors, PLC changes, wiring, sample trials, model maintenance, remote support, FAT/SAT, training and data storage. Assign an owner for the shutdown window and safe rollback. Installation must preserve cleaning, changeover and safe operator access.
Ask suppliers how they declare blind conditions, detect unavailable inspection, verify removal and export evidence after a mismatch. Agree who owns images and training data, how updates are approved, how model and configuration versions are restored, and how data is handed over at contract end. If workers or customer-identifying labels enter the camera field, set access and retention according to applicable local rules and agreements.
9. Give PoC, FAT and SAT different jobs
PoC chooses the observation method: compare lighting, background, camera position and visible limits. Factory acceptance testing (FAT) checks the adjusted cell against agreed image capture, decision, signals, simulated rejection and records before shipment. SAT checks the installed line at maximum speed and normal variation, after cleaning and changeover, and through jams, faults and power recovery. Passing a still-image FAT does not automatically pass real-line rejection.
Include samples unseen during model development in the buyer’s acceptance set. Register every test piece and reconcile recovery after the trial. If a safe surrogate is necessary, record the difference from the real hazard. Isolate trial products from saleable production and document date, lot, line state, disposal and approval. Sign expected results before the tests.

| Test | Challenge | Expected outcome | Evidence |
|---|---|---|---|
| P01 | Minimum agreed object at varied positions | Reject or hold within approved scope | Raw image, region, item ID |
| P02 | Good product with ingredients, drops, creases and print | Meet signed false-reject criterion | Denominator, NG images, cause |
| P03 | Consecutive NG at maximum speed and minimum gap | Correct items physically removed | Trigger, PLC and reject timestamps |
| P04 | Camera, light, network or reject-bin fault | Agreed stop or hold action | Alarm, PLC state, hold interval |
| P05 | Cleaning, changeover and power recovery | Release only after reference check | Checklist, model version, approver |
Do not copy a generic “99% detection” target into the contract. Limits depend on hazard severity, product value, inspection volume and reinspection capacity. Sign the denominator, target distribution, uncertainty and method with the threshold. A high false-reject rate can make the cell unusable; a low measured miss rate on an easy sample set says little about difficult fragments. Retest both sides after correction.
10. Set restart rules for SKU changeover and cleaning
One food-packaging line may run several SKUs, tray colours, ingredients, fill weights and films. Immediately after changeover, the old inspection recipe may still be active when new product arrives. Even automatic recipe selection from a production order or barcode can read the wrong order or code. Require the operator to compare the on-screen SKU, physical pack and production order; then run a reference sample before releasing any product as saleable. Record changeover time, approver, recipe version and reference image.
Cleaning may shift camera or light angle slightly, while droplets or detergent film remain on the lens window. Alongside hygienic inspection, compare image edges, brightness, field boundary and blind zones with the approved reference. Define how controlled test pieces enter the food area and where they are stored; count them before and after use. A forgotten challenge piece would itself become a contamination risk. Replacing a protective window calls for a short verification including the smallest agreed target, not just a tick in the cleaning log.
A restart sheet can capture seven items: product-and-pack combination, raw image, model/configuration version, reference-piece outcome, physical reject confirmation, recovery count of test pieces, and approver. If one is missing, do not return automatically to saleable operation; quality determines the hold interval. This is evidence that the accepted configuration remains intact, not a new claim of model accuracy. For multilingual plants, use one-to-one SKU and alarm identifiers in all screens and night-shift records.
11. Link inspection records to lots
GS1’s Global Traceability Standard explains how identified objects, lots and process events support traceability. Link inspection records to lot, SKU, pack version, equipment, time, model and configuration version, image, decision and reject verification. This supports a later hold decision. Use the identifiers already defined by the plant and its MES/ERP; GS1 adoption alone does not certify the visual cell or establish legal compliance.
Choose all-image versus NG/review-image retention based on audit needs, storage, learning needs, privacy and network capacity. Even without all images, retain counts and intervals of inspection unavailability and the affected lots. Synchronise clocks across PLC, camera computer and MES; otherwise one cannot reliably match image to rejected item. Test local buffering during network loss and retransmission after recovery. Record who returned held items to the line and prevent double acceptance.
Simulate a customer complaint. Starting from manufacturing date, lot and carton, can the team reach the item’s inspection record and identify the adjacent items and any inspection outage? Test lot, film and shift boundaries. Confirm access to raw equipment data before relying on a formatted PDF report.
12. Maintain performance after go-live
Raw-material origin, ingredient colour, tray mould, print design, lamp ageing, dirty windows and moving guides all change images. Quality owns daily reference images and controlled challenge samples. Maintenance checks lighting, triggers and rejection. IT/OT watches computer health, storage and clock synchronisation. Do not relax a threshold merely to reduce rejects without assessing missed hazards. Record the reason, version, comparison result, approver and rollback condition for each change.
Review detection counts, false-reject causes, review backlog, missing frames, reject-verification failures and post-cleaning shifts weekly or at product changes. A rise in real foreign matter calls for investigation of broken tools, worn guides or suppliers *before* model retraining. A sudden drop to zero also calls for checking the trigger and light. Compare a revised model on the sealed original acceptance set and new plant samples, and identify material or positions whose performance worsened.
13. Measure value with the plant’s own numbers
Separate food-safety control effort, inspection coverage, false-reject waste, rework, downtime and complaint investigation from labour reduction. Initial cost includes hardware, conveyor and PLC integration, installation and trials. Ongoing cost includes maintenance, lamp replacement, model revisions, data storage, challenge-piece control and review labour. Rare-event complaint reductions cannot be forecast reliably as an invented percentage. Inspection coverage, documented target scope, record retrieval time and physical reject success are measurable deliverables.
At PoC exit choose deployment, a changed observation point, another inspection method or stronger upstream prevention. Buying a camera for invisible fragments has poor value. Where visible pre-seal pieces are the main concern, start with a limited accepted scope and expand only after line evidence. Recheck light, speed, pack and reject distance before copying the first cell to another line.
Frequently asked questions
Can an AI camera guarantee all nonmetal foreign matter in packaged food is found?
No. Imaging every item is possible, but an object hidden by food or opaque packaging cannot appear in a visible-light image. Specify material, minimum size, exposed area, light, background and speed; test that defined scope. Manage excluded hazards through prevention or a suitable different method.
Can it replace metal detection or X-ray?
Do not assume so. Their observation principles differ. X-ray can be challenged by low-density plastics near product density; a camera cannot see hidden material. Use hazard analysis and SKU-specific samples to choose complementary methods.
Where should the camera sit?
Between the final relevant contamination point and sealing, where the largest surface is visible and item pose and spacing are stable. Manage contamination that may occur afterward separately. Verify tracking, physical rejection and its confirmation in SAT.
What if there are few real contamination samples?
Prioritise materials by risk, use real pieces or quality-approved surrogates in a controlled isolated trial, and record what remains unverified. Compare simple rules as well as AI. Never feed hazardous trial pieces into saleable output.
May we loosen the threshold when false rejects rise?
Only after quality evaluates any increase in missed hazards. Classify glare, water, wrinkles, ingredient variation, dirty windows and mispositioning in the raw images. Fix optical or handling causes first, then compare old and new settings on the same sealed acceptance set.
Conclusion
AI visual inspection can be a useful food-packaging control when the defined target is visible before sealing. Start with the hazard and contamination point, establish a stable view and light, and test AI judgement together with item tracking and physical rejection. PoC identifies visible scope and blind conditions; FAT checks the equipment functions; SAT checks the production line through real speeds, cleaning, changeovers and failures. Keep hidden hazards in the wider plan for prevention, metal detection, X-ray or other suitable controls.
If your team is still choosing the inspection point, assembling target samples or specifying PLC rejection and acceptance tests, contact TOMAS TECH. We can help define the visible scope and the evidence to collect from your existing product, pack, speed and cleaning conditions before you commit to equipment.
Primary sources
- FDA, Hazard Analysis and Risk-Based Preventive Controls for Human Food, Chapter 3 — Draft, Not for Implementation: draft discussion of physical hazards and sources, not final guidance.
- FDA, FSMA Final Rule for Preventive Controls for Human Food: US hazard analysis and written controls; cited as a framework, not a claim of direct Thai applicability.
- FDA, HACCP Principles & Application Guidelines: physical-hazard questions across the process.
- KEYENCE, Machine Vision Lighting Selection Guide: lighting geometry and contrast.
- KEYENCE, Food and Beverage Packaging Vision Systems: examples of package and foreign-particle inspection.
- Anritsu, The 411 on Contaminant Detection: limits of metal and X-ray inspection.
- METTLER TOLEDO, How Do X-ray Systems Find Contaminants: density contrast and product dependence.
- GS1, Traceability Standards: lot and event linkage.
*The cell architecture, test cases and cost categories here are planning examples. Detection performance, legal duties and certification status must be established for the actual product, risk assessment and customer requirements.*