# Localize and Inspect Screws

Screws or any other cylindrical object need to be rotated during inspection. Looking at the full object over several images, and not only at one specific line along the rotation axis, allows you to see the surface and defects at different angles to the camera and the illumination. For instance, some defects show best when they are on the center line, others show better when they are slightly off to the sides.

Since the Red Analyze tool does not rely on the precise positioning or orientation of the object, it can operate in an open loop. In other words, you can take a series of images of the rotating object and present the images directly to the Red Analyze tool.

In this tutorial, the screws are moving across the entire image. For this situation, use a Blue Locate Tool to localize and crop the screw before feeding the screw to the Red Analyze tool.

## Add Blue Locate tool

1. Add the images for the Screw tutorial.

   Note: While in training Training is the process that your tool, which is a neural network, is learning about the features (pixels) based on the labels you made. For example, a tool will learn the defect/normal pixels in each image based on the defect/normal labels you drew. The goal of the tool Training is learning enough to give the correct inspection results of whether an unseen image is defective or not. The key to training is to ensure that you include all possible variations within your training set, and that your images are accurately labeled. Training times vary by the application, tool setup and the GPU in the PC being used to train the network. mode, after you add or open a Workspace, you can add images through either the Database menu (select Add Images), by pressing Add Images in the display space of the GUI, or dragging and dropping images from a Windows Explorer directory into the View Browser.

2. Add a Blue Locate tool.

3. Adjust the ROI The Region of Interest (ROI) defines the area of operation for the tool. The ROI preserves the positions, angles, stretch and skew of the original image. to segment an image, and then press the Scissors icon to process the images based on the new ROI.

4. Set the Feature Size parameter to 80.

5. Define at least two features (for example, the end and the tip of the screw) on at least three images.

6. Press the Brain icon to train the system. Review the results and manually label the images where the features were not found correctly.

7. If you had to manually label new images, retrain the system and review the results.

8. Right click on an image which has the two features and create a model A specific spatial arrangement of a set of features (Blue Locate and Blue Read tools only.) During a post-processing step, the Blue Locate and Blue Read tools can fit all of the features detected in an image to the models defined for the tool. The overall pose and identity of the model is then returned. named "screw".

9. Reprocess the image and make sure the model is correctly found.

## Add Red Analyze tool

1. Add a Red Analyze tool, and leave it in Unsupervised mode.

2. Segment the images for the Red Analyze tool by choosing the "screw" model.

3. Change the size of the ROI to 700 x 250.

4. Disable the Centered checkbox and use the mouse to move the ROI over the screw.

5. Press Apply to segment all the images, and then verify that the images in the database are correctly segmented.

6. Label all the images as good where the defect is not visible, and bad for the images where the defect is visible.

7. Train the tool and verify the results.

8. If the results are not satisfactory, increase the number of iterative trainings by increasing the Training Passes parameter and retrain.