AI in factories

Computer vision for factories: inspect, count and measure the right errors

By RUBIKSCORP · Published · 4 min read

Factory computer vision uses image or video data to support tasks such as product counting and visible defect inspection. A useful pilot tests the full operating setup, including cameras, lighting, labels and the action taken after an alert.

Factory worker operating textile production machinery — stock photograph
Stock photo · EqualStock IN / Pexels

Pick a task the camera can actually observe

A camera can support decisions about visible features under the conditions it captures. It cannot establish an invisible material property merely because the project is called AI. Define the product, visible condition and decision before selecting a model.

Counting at a conveyor point and inspecting a surface need different evidence. Counting may need tracking across frames to avoid counting the same item twice. Inspection needs a clear definition of each visible defect and what should happen when it is detected.

  • Specify the product, line position and visible target.
  • Record camera position, exposure, lighting and line speed.
  • Include normal variation, changeovers and partial obstruction.
  • Agree an operator review and exception process.
  • Keep machine safety controls separate from an experimental vision pilot.

Agree labels before collecting a large dataset

Ask knowledgeable staff to label a small shared set of images first. If they disagree about whether a mark is a defect, document the reason and refine the definition. Otherwise the model will be evaluated against inconsistent instructions.

Collect examples across the conditions where the system will operate. A convenient folder of clear, stationary images is not a substitute for varied shifts, product finishes and actual motion. Separate related images across time or production runs so near-identical frames do not make testing artificially easy.

Worked example: why 98% accuracy can still be insufficient

Illustrative arithmetic only. This is not a RUBIKSCORP project result.

Suppose a test contains 1,000 items: 50 are defective and 950 are acceptable. A system flags 40 of the defective items and incorrectly flags 10 acceptable items. It misses 10 defects and correctly passes 940 acceptable items.

OutcomeCountOperational meaning
True positive40Defective item flagged
False negative10Defective item missed
False positive10Acceptable item flagged
True negative940Acceptable item passed
  • Accuracy = (40 + 940) / 1,000 = 98%.
  • Defect recall = 40 / (40 + 10) = 80%.
  • Defect precision = 40 / (40 + 10) = 80%.
  • Defect miss rate = 10 / 50 = 20%.

The same result can be described as 98% accurate while missing one in five defects in this illustrative test. Whether it is acceptable depends on the defect, consequences, review process and agreed criteria. The numbers are not a recommended threshold.

Choose metrics that match the decision

Recall describes the proportion of actual defects detected. Precision describes the proportion of flagged items that are actually defective. False alarms can create review work; misses can create quality escapes. Report both, along with the sample composition and conditions.

Changing an alert threshold can change the balance between errors. Do not choose a threshold on the final test set and then report that same set as independent evidence. Keep a validation process and review results by defect type and operating condition.

A classification score also does not measure counting quality, throughput or response time. For a counting task, compare counts against a verified reference over defined intervals and inspect how errors accumulate.

What an operational handover should include

Start in an observation or review-assisted mode appropriate to the process. Connect results to a real decision only after the responsible team accepts the evidence and operating controls. A successful demonstration is a starting point for that decision, not automatic permission to control a production line.

  • The exact approved task and excluded conditions.
  • Camera and lighting settings, with a way to detect changes.
  • A labeled evaluation set and results by relevant condition.
  • Who reviews alerts and what happens to disputed items.
  • A fallback when a camera, network connection or model fails.
  • Model and dataset versions, a change log and retraining triggers.

Common questions

Does 98% accuracy mean 98% of defects were caught?

No. Defect recall measures the share of actual defects detected. Overall accuracy also includes acceptable items.

Can one camera setup work on every line?

That needs testing. Product appearance, motion, lighting and obstruction can change the task.

Should a pilot replace machine safety controls?

No. An experimental vision system must not be treated as a substitute for required safety controls.

Sources and notes

  1. Google — Accuracy, recall and precision

    Metric definitions and why error costs affect their interpretation.

  2. scikit-learn — Metrics and scoring

    Technical reference for classification and regression evaluation.

  3. Google — Dividing datasets

    Separating training, validation and testing.

Educational guidance and illustrative examples by RUBIKSCORP. Examples are not client results. Read our editorial approach or report a correction.

Read next

AI learning hub · AI glossary · All articles

Have a specific question?

Tell us the task, the information available and what a useful result would look like.