# 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.

Note: For more information on the specific steps of setting up the tools, see the and .

## Add Blue Locate Tool

1. Add the images for the Screw tutorial.

   Note: While in training 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 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 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.