PRODUCT KNOWLEDGE

Deep Learning vs Traditional Machine Vision: When Should You Use AI?

When should you move from pattern matching, blob and edge tools to deep learning? A comparison, a checklist and Cognex tools for cosmetic defects.

Your line has run well for months on pattern matching and edge measurement. Then a new batch arrives with a slightly different surface, faint scratches, stains that change shape, and false rejects climb. At this point many factory engineers ask: should we move to deep learning in machine vision, or simply retune the traditional algorithms? This article helps you decide with a comparison table and a selection checklist, using surface defect inspection as the main example.

One point up front: deep learning does not fully replace traditional algorithms. Each is strong on a different class of problem, and many of the best systems use both.

How traditional (rule-based) algorithms work

Traditional, or rule-based, vision relies on explicit rules defined by an engineer. The familiar tool families are:

  • Pattern matching: finds the position and angle of a part from a learned template. Well suited to localization, alignment and robot guidance.
  • Blob analysis: separates bright or dark regions by thresholding, then measures area, perimeter and centroid. Used for counting and for detecting extra or missing material.
  • Edge and caliper measurement: finds edges and measures distances, diameters and concentricity. This is the foundation of 2D gauging.
  • Code reading and fixed-font OCR: works well when characters are clear and consistent.

The biggest advantage is explainability: when the system reports NG, you know exactly which threshold was crossed. Processing is typically fast, hardware is light (many applications run directly on a smart camera), and you do not need a large library of defect images. The weakness appears when the shape of the defect, or of the background, cannot be captured by a handful of rules.

Deep learning learns from images, not rules

With deep learning you do not write rules. You provide labeled images (for example OK/NG, or outlined defect regions) and a neural network learns the features that separate them. This approach suits tasks that are hard to program in the conventional way. For visual inspection, it means the system can learn what "normal" looks like even when the surface has texture, reflections or colour variation from part to part.

The trade-off is that you need good image data, a training and validation process, and usually stronger hardware. Results are also harder to explain: the model returns a score or a suspect region, not a specific threshold.

Comparison table: rule-based vs deep learning

CriterionTraditional algorithmsDeep learning
How it is builtEngineer sets rules, thresholds, parametersTrained from labeled images
Best suited toLocalization, gauging, counting, clear code readingVaried cosmetic defects, noisy backgrounds, variable surfaces, complex classification
Data neededA few sample images to tune parametersAn image set that represents all real-world variation
Unseen defectsCaught only if the rules cover themUnsupervised modes can flag deviations from "good" images
ExplainabilityHigh, every threshold can be tracedLower, needs heatmaps and a test set to build trust
HardwareUsually CPU or smart cameraMany modes need an NVIDIA GPU, especially for training
MaintenanceRetune parameters when the product changesAdd images and retrain when the product or background changes

Real-world speed and accuracy depend on the application, the input images and the hardware, so always test on real samples before drawing conclusions.

Main example: surface defect inspection on a noisy background

Picture a machined metal part or a textured panel. The defects to catch are scratches, stains, dents and colour deviations. With the traditional approach you usually run into:

  • Faint, low-contrast scratches: a high threshold misses them, a low threshold flags machining marks as defects.
  • Stains of arbitrary shape: blob analysis needs a threshold, but a pale stain blends into a variable background.
  • Dents: visible only at certain lighting angles, hard to describe with simple geometric rules.
  • Colour deviation: the "correct" colour spans a wide range across batches, so a single threshold is hard to fix.

This is where deep learning often has the edge: the model learns the full range of normal variation in the background and flags what falls outside it. However, lighting and optics still decide most of the image quality. If a scratch does not show up in the image, AI will struggle to rescue it. If you are choosing lighting for surface defects, see our article on the OPT RBV9855-W diffuse dark-field square light, and our overview What is machine vision if you are just starting.

For a broader view of defect inspection solutions, visit BeeVision's visual inspection page.

Checklist: rule-based or deep learning?

Answer these questions for your application:

  1. Can the defect be described with rules? If you can say "a defect is a region darker than X and larger than Y", rule-based is usually enough.
  2. Is the background stable? Texture, reflections or colour that vary between batches point towards deep learning.
  3. Do defects vary in shape? Scratches, stains and dents appearing in many shapes and positions point towards deep learning.
  4. Do you have representative OK/NG images? If you have no defect images yet, unsupervised mode needs only good images, but you still have to collect enough variation.
  5. Are lighting and part position under control? Both approaches need stable images. Control lighting, working distance and trigger timing.
  6. Must every decision be explainable? If quality rules require traceable thresholds, rule-based has the advantage.
  7. Do you have a GPU budget and someone to maintain the model? Deep learning needs a process for collecting images and retraining when products change.
  8. What cycle time do you need? Measure on real hardware rather than inferring from theory.

Rule of thumb: if most answers are "describable, stable background", keep rule-based. If most are "variable, diverse, hard to describe", try deep learning. If you land in between, combining both is often the right choice: use pattern matching to locate the part, then deep learning to inspect the surface inside the located region.

Cognex VisionPro Deep Learning: the main tool groups

BeeVision, a Cognex partner and Cognex distributor in Vietnam, supplies the Cognex VisionPro Deep Learning library and supports its integration for many large customers in Vietnam. It is a set of machine vision tools that use deep learning for tasks that are hard to program conventionally, with a standalone GUI called Cognex Deep Learning Studio and APIs for application development (more at cognex.com). There are four tool groups:

Red Analyze: anomaly and cosmetic defect detection

This is the core tool for visual inspection. Red Analyze learns the normal appearance of the zone being inspected in order to detect anomalies and aesthetic defects, with Focused Unsupervised, Focused Supervised and High Detail modes.

  • Unsupervised: trained with good images only, no defect images required. Suitable when defects are rare or not all defect types are known. Anomalies must be visually salient against the background; if the tool does not respond to the defects you care about, switch to a supervised mode.
  • Supervised: trained with both good images and defect images with the defect regions marked. Suitable for harder defects such as scratches, low-contrast stains or changes in surface texture.

A common pattern is to use an unsupervised tool first to filter anomalies, then supervised tools for the harder defects.

Green Classify: classification

Green Classify classifies objects or whole scenes from a set of labeled images, with Focused, High Detail and High Detail Quick modes. It can sit after Red Analyze to classify the type of defect found (scratch, stain, dent and so on), which is very useful for tracing defect causes back to a production step.

Blue Locate: feature localization

Blue Locate finds and localizes one or more features in an image, learning from annotated images. It is used for fixturing, counting and assembly verification. It is useful when classic pattern matching fails because the part deforms or the background is cluttered.

Blue Read: deep learning OCR

Blue Read reads characters, including codes that are deformed, skewed or poorly etched. It comes with a pre-trained font library that identifies most text without additional font training, and it can be retrained when needed.

Which tool for which job?

ProblemSuggested toolNote
Surface defect detection, few defect imagesRed Analyze (Unsupervised)Quick start with good images
Faint scratches, pale stains, hard defectsRed Analyze (Supervised / High Detail)Needs defect images with marked regions
Classifying defect type or product typeGreen ClassifyCan follow Red Analyze
Locating, counting, assembly checks when parts varyBlue LocateAn option when pattern matching is unstable
Difficult character reading (faint, skewed, deformed)Blue ReadPre-trained font library

Training image requirements

There is no single minimum image count for every application, and these tools need much smaller image sets than conventional deep learning. So do not trust any "you need exactly N images" claim without testing on real samples. Practical rules:

  • The image set must represent all the variation you will meet in production: batches, shifts, lighting conditions, defect types.
  • Label accurately. In supervised modes, wrong labels teach the model wrong things.
  • Control the imaging conditions: lighting, working distance, trigger timing.
  • Split training and test sets, and test on both good and defective images not used in training.
  • Unsupervised mode needs only good images; supervised modes need defect images with marked defect regions.

GPU hardware

VisionPro Deep Learning supports NVIDIA GPUs only. For release VPDL 3.3.x, the GPU must be CUDA-capable with compute capability 6.1 or higher; a training PC needs 10 GB or more of GPU memory and a deployment PC 8 GB or more, and High Detail tools call for more. Focused-mode tools can run without a GPU, but High Detail tools cannot be processed without one. Requirements change between versions, so check the exact version you will use before specifying hardware. BeeVision engineers can help you choose the GPU and the right PC-based vision system.

Deployment on the production line

The workflow typically has two phases: training (on a GPU-equipped PC) and processing (running the trained model on new images). Models can be deployed through the runtime environment or the runtime API, and a trained tool can be exported and imported into VisionPro as a tool block. That lets you combine deep learning with traditional tools in one program. PCs running the software need a valid Cognex Security Dongle. Cognex also offers some AI tools on the In-Sight platform; if you are interested in the smart camera route, read about Edge Learning technology.

When bringing it onto the line, plan for: the trigger signal and PLC connection, processing time within the cycle, saving NG images for traceability and retraining, and a process for updating the model when the product changes.

Frequently asked questions

Is deep learning always more accurate than traditional algorithms?

No. For gauging, localization or clear code reading, rule-based tools are often faster, more stable and easier to explain. Deep learning has the advantage when defects and backgrounds vary. Accuracy depends on the application and must be verified with real samples.

Can I use deep learning without many defect images?

You can start with Red Analyze's unsupervised mode, which needs only good images. If defects are not salient enough, you will need to collect defect images and move to a supervised mode.

Can both approaches be combined?

Yes, and it is common: traditional tools for locating and measuring, deep learning for judging the surface. See also our article on deep learning in machine vision for quality inspection.

Next steps with BeeVision

The fastest way to learn which approach fits your application is to test it on real samples. Send OK/NG samples or images and BeeVision engineers will run the test and recommend the camera, lighting and software setup. Start on the send samples for a POC page. You can also explore Cognex solutions and follow BeeVision on LinkedIn and YouTube for weekly machine vision insights.