Surface Detection

Surface Detection can be trained to detect a specific surface or known surface defects, it is suitable especially for detecting scratches, cracks, and defects on a highly variable background.

This module serves to detect a specific surface and it can also classify the types of surfaces, which are to be detected, into different classes like the Classifier.

Training

Annotations

Surfaces can be marked in two ways - by brush painting in the image or by making polygons, those ways can also be combined. Each surface class has one color assigned. For quick color switching, you can press a numeric key indicating the number of the class that is given in square brackets.

example annotations.png

 

annotated.png

 

Brush painting

Basic painting into the image by a brush of selected size. To change the brush size or switch between paint- and erase mode, you can either use the sliders at the top, or you can use shortcuts, which can be found in the Help section under the ‘?’ symbol. Currently, you can press or hold the 'K' and 'L' keys to decrease resp. increase the brush size, and holding 'E' temporarily switches the paintbrush to the eraser.

 

Polygons

When you choose the polygon mode, you left-click into the image to define the vertices of the polygon, which are being connected with a line in the order you put them in. When you're satisfied with the shape, click on the initial point marked with a circle, which joins the last vertex with the first one and fills the polygon with the chosen color. Polygons work in the erase mode as well.

 

Include

It is used to include the selected image for training if it does not contain any defects. The picture does not fall into one of the classes which were created, its whole surface is marked as defect-free.

It can be used when a defect-free/ok image has some noise or it’s slightly scratched for instance, or it has some very variable background and we get false defects detected on it. It can help achieve higher accuracy.

Ignore

Available only in Lightweight training

Surfaces marked with Ignore class are excluded from the training. Parts of the image left unannotated are considered as an ok class, which is not displayed when detected.

Can be used in cases when we are unsure whether a specific part of an image is ok or ng or if there’s some distortion and we don’t want to put that part into training.

Settings

Types of Surface Detection

Two types of surface detectors are available, each based on a different kind of neural network.

 

Lightweight:

  • Detects a wide range of defects, however, can suffer from a higher amount of false positives (good parts evaluated as bad by the software), adjusting the Confidence threshold after training can help reduce this.

  • Faster inference and training.

  • This type does not require large datasets, however, performance on highly variable patterns may be more suitable for the Standard option.

 

Standard:

  • This type produces very precise heatmaps and usually doesn’t have too many false positives. It's ideal for searching for objects/defects with closed shapes. It also takes into account the surroundings, not just the surface itself.

  • Training time is usually longer.

  • Ignore function is not included.

Feature size

Read more about Feature Size

Feature size determines the size of the surface defects the model is able to reliably find. Tweak the feature size by using the grid that appears and fit it according to the size of the image defects.

With small sizes the model loses the knowledge of the surroundings and can miss some defects. With bigger sizes the model has the “bigger picture” and some details can be overlooked.

The recognition speed also varies. There is no general rule on how to set the right size, you need to try out a number of sizes and learn how to estimate the best size on the first try. The size of the defects you are searching for might be of help.

Detection

The detection result is a set of heatmaps (one for each class). When validating, heatmaps are plotted in the image for better illustration. Heatmaps for the whole image are added to heatmaps in Context, and all the rectangles surrounding the searched-for areas are added to detectedRectangles. Each rectangle has a class assigned, depending on which heatmap it was found in.

Notice the grid specifying the feature size and the resulting heatmap. The detection sizes correspond to the feature size grid - the holes are filled using a higher feature size than optimal resulting in a worse heatmap accuracy.

In this case Feature size is too big to produce a heatmap without filling in the holes. However, it is optimal if we only need to find the rough shape, this way the performance is better.