Etiquetas

lunes, 11 de mayo de 2015

Artificial Vision 5 Inspecting an Object that Spans Two Image Frames

Inspecting an Object that Spans Two Image Frames

This example introduces the Select Image and Calculator steps.

Assume that you need to measure the width of a wide wooden plank with
high accuracy. The only cameras available for the application have low
pixel resolutions.

To measure the width of a plank, you need to locate its left and right edges.

If you were to set up the imaging system so both edges of a plank fit within
an available camera’s field of view, the resulting image detail would be too
low to yield accurate measurements. Because the required image detail
exceeds the pixel resolution capability of a single camera, two cameras per
plank are needed—one camera to acquire an image of the left edge and one
camera to acquire an image of the right edge.

Acquiring Inspection Images from Two Cameras


Acquiring and Calibrating the Image of the Left Edge


Complete the following instructions to configure Simulate Acquisition
steps that simulate acquiring an image of the left section of the wooden
plank and calibrating the image.

1. In the Inspection Steps palette, select the Acquire Images tab.

2. Click the Simulate Acquisition step. The property page for the step
opens.

3. In the Step Name control, enter Acquire Plank (Left).
4. Click the Browse button. The Select an Image File dialog box opens.
5. Navigate to <Vision Builder AI>\DemoImg\Tutorial 4 Left,
where <Vision Builder AI> is the location where Vision Builder
AI is installed.
6. Select the first image, Image 01.jpg, and click Open.

7. Make sure the Cycle Through Folder Images control is enabled so
that Vision Builder AI loads a different simulation image from the
folder each time the step is run.

8. Click the Calibration tab.

9. Click Create Calibration to launch the calibration wizard.
10. In the Calibration Name control, enter Plank Calibration
(Left).

11. Click Next.

For this example, assume that the camera that acquired the inspection
images is perpendicular to the image plane and lens distortion is negligible.
Based on these assumptions, you can use Simple Calibration to calibrate
your images. Simple Calibration transforms a pixel coordinate to a
real-world coordinate through scaling in the x (horizontal) and y (vertical)
directions.

12. Select the Simple Calibration option, and click Next.

13. Make sure Use Current Image is selected, and click Next.

14. Make sure Pixel Type is set to Square because the camera that
acquired the images for this exercise has square pixels.

15. Click Next.

16. In the Specify the Pixel Ratio step, carefully click the 1 cm and 5 cm
markings on the ruler at the bottom of the image, as shown in the picture.




17. In the Correspondence Image - Real World control, enter 4 for the
value, and select centimeter for the Unit.

18. Click Next.

19. In the Set Calibration Axis step, click the 1 cm marking to define it as
the origin of the calibration axis. Draw a line horizontally and to the
right along the edge of the ruler to define the angle of the calibration
axis, as shown in the next picture.



20. Set the Axis Reference control to Direct.

21. Click OK to learn the calibration information and exit the calibration
wizard.

22. Click OK to add the step to the inspection.

Acquiring and Calibrating the Image of the Right Edge


This section simulates acquiring an image of the right section of the
wooden plank. Because the simulated acquisition represents a second
camera, you cannot reuse the calibration that you created for the first
camera.

Complete the following instructions to configure Simulate Acquisition
steps that simulate acquiring an image of the right section of the wooden
plank and calibrating the image.

1. In the Inspection Steps palette, select the Acquire Images tab.

2. Click the Simulate Acquisition step. The property page for the step
opens.

3. In the Step Name control, enter Acquire Plank (Right).

4. Click the Browse button. The Select an Image File dialog box opens.

5. Navigate to <Vision Builder AI>\DemoImg\Tutorial 4
Right, where <Vision Builder AI> is the location where Vision
Builder AI is installed.
6. Select the first image, Image 01.jpg, and click Open.

7. Make sure the Cycle Through Folder Images control is enabled so
that Vision Builder AI loads a different simulation image from the
folder each time the step is run.

8. Click the Calibration tab.

9. Click Create Calibration to launch the calibration wizard.

10. In the Calibration Name control, enter Plank Calibration
(Right).

11. Click Next.

Again, assume that the camera that acquired the inspection images is
perpendicular to the image plane and lens distortion is negligible.

12. Select the Simple Calibration option, and click Next.

13. Make sure Use Current Image is selected, and click Next.

14. Make sure Pixel Type is set to Square because the camera that
acquired the images for this exercise has square pixels.

15. Click Next.

16. In the Specify the Pixel Ratio step, carefully click the 38 cm and
42 cm markings on the ruler at the bottom of the image, as shown in
the picture.



17. In the Correspondence Image - Real World control, enter 4 for the
value, and select centimeter for the Unit.

18. Click Next.

19. In the Set Calibration Axis step, click the 38 cm marking to define it
as the origin of the calibration axis. Draw a line horizontally and to the
right along the edge of the ruler to define the angle of the calibration
axis, as shown in the following picture.




20. Set the Axis Reference control to Direct.

21. Click OK to learn the calibration information and exit the calibration
wizard.

22. Click OK to add the step to the inspection.

Locating the Right Edge of the Part


Complete the following instructions to configure a Find Edges step that
locates the right edge of the part.

1. In the Inspection Steps palette, select the Locate Features tab.

2. Click the Find Edges step. The property page for the step opens.

3. In the Step Name control, enter Find Right Edge.

4. Draw a line across the right edge of the part going from right to left, as
shown in the picture.

Tip Pressing the <Shift> key while drawing a line constrains the line tool to only draw
horizontal or vertical lines.

5. Click the Settings tab.

6. In the Look for control, select First Edge.

7. In the Edge Polarity control, select Bright to Dark Only.




Notice the red square on the search line. The step searches along the
search line for a sharp transition in pixel intensities, which usually
represents an object edge. The red square marks the location of the
right edge of the part.

8. Click OK to add the step to the inspection.

Switching Images


Now that you have configured the inspection to locate the right edge of the
wooden plank, you need to switch to the image of the left side of the plank.
Complete the following instructions to configure a Select Image step that
makes the image of the left side of the plank active for processing.

1. In the Inspection Steps palette, select the Acquire Images tab.

2. Click the Select Image step. The property page for the step opens.

3. In the Step Name control, enter Switch to Left Side.

4. In the Image Selection list, select Acquire Plank (Left). The image
of the left side of the part appears in the Main window.

5. Click OK to add the step to the inspection.

Locating the Left Edge of the Part


Complete the following instructions to configure a Find Edges step that
locates the left edge of the part.

1. In the Inspection Steps palette, select the Locate Features tab.

2. Click the Find Edges step. The property page for the step opens.

3. In the Step Name control, enter Find Left Edge.

4. Hold down the <Shift> key and draw a line across the left edge of the
part going from left to right, as shown in next picture.

5. Click the Settings tab.

6. In the Look for control, select First Edge.

7. In the Edge Polarity control, select Bright to Dark Only.



The step searches along the search line and marks the location of the
left edge with a red square.

8. Click OK to add the step to the inspection.

Calculating the Width of the Part


Now that you have located the right edge of the part in one image and
the left edge of the part in another image, you need to combine the
measurements from the two images to determine the width of the part. Use
the Calculator step to combine the two measurements and compute the
width.

Refer to the following equations as you configure the step.

Right (LC) = Right (RC) + (Origin R – Origin L) 

Part Width = Right (LC) – Left (LC) 

where          Right (LC) = The x position of the right edge in the calibration
axis of the left edge.

                    Right (RC) = The x position of the right edge in the calibration
         axis of the right edge. This corresponds to the calibrated
x position result of the Find Right Edge step.

                    Origin R = The x position of the origin in the calibration axis of
the right edge.

                   Origin L = The x position of the origin in the calibration axis of
the left edge.

                     Left (LC) = The x position of the left edge in the calibration axis
               of the left edge. This corresponds to the calibrated x position
result of the Find Left Edge step.

Setting Calculator Step Inputs and Outputs


Complete the following instructions to configure a Calculator step to
select the input measurements from the previous Find Right Edge and
Find Left Edge steps, and create output results for the calculated values.

1. In the Inspection Steps palette, select the Use Additional Tools tab.

2. Click the Calculator step. The Calculator Setup Wizard opens.

3. Click Next to proceed with the wizard.

Notice the Input Measurements list. The list contains all of the
measurable data from each of the previous steps in the inspection.

4. Select the following measurements from the Input Measurements
list:

• Find Right Edge»Edge [1].X Position (Calibrated)

• Find Left Edge»Edge [1].X Position (Calibrated)

5. Click Next.

6. Click Add New Output Result. A new output appears in the Output
Results list.

7. In the Name control, enter Part Width. This output will contain the
results of Equation 5-2.
8. Make sure Type is set to Numeric.
9. Click Add New Output Result again.
10. In the Name control, enter Right (LC). This output will contain the
results of Equation 

11. Make sure Type is set to Numeric.

12. Click Finish to close the Calculator Setup Wizard.

The Main window now displays a diagram with the measurement inputs
and result outputs you specified in the Calculator Setup Wizard, as shown
in the next picture. The diagram also contains a default Boolean result named
Step Result. You can connect the result of a computation to Step Result,
which changes the status of the Calculator step to the result of the
computation. Refer to the Making Logical PASS/FAIL Decisions with the
Calculator Step section of this chapter for more information about Step
Result.





Notice that the inputs and outputs are framed with color and have codes at the
bottom of their frames. These colors and codes visually group inputs and
outputs into their respective data types—numerics, Booleans, or strings.

13. To simplify the process of connecting the diagram elements later in
this chapter, arrange the elements into the configuration shown in
the picture by dragging them to their new positions.




Adding Operators and Constants


Earlier in this chapter, you used the Calibration Wizard to set calibration
axis origins for the right and left sides of the part. These origins are the only
elements of Equations not yet represented in the Calculator
diagram: (Origin R and Origin L).

In step 19 of the Acquiring and Calibrating the Image of the Right Edge
section of this chapter, you set the origin of the right side to the 38 cm
marking of the imaged ruler. In step 19 of the Acquiring and Calibrating
the Image of the Left Edge section of this chapter, you set the origin of the
left side to the 1 cm marking of the imaged ruler. Therefore,
(Origin R – Origin L) = 38 – 1 = 37.

The distance between the calibration axis origins is a constant value. Add a
constant with the value 37 to the Calculator diagram.

1. In the Functions palette, click Numeric.

2. Click the Num Const operator. Click inside the Calculator diagram
below the Find Right Edge - Edge [1].X Position (Calibrated) input
measurement to place the numeric constant on the Calculator diagram.

3. Double-click the numeric constant and type 37 to set the value of the
constant.

4. Click the Add operator in the Functions palette. Click inside the
Calculator diagram to the right of the Find Right Edge - Edge [1].X
Position (Calibrated) input measurement.

Tip Place the Add operator close enough to the Find Right Edge - Edge [1].X Position
(Calibrated) input so that the Calculator step automatically connects the two elements
with a wire.

5. Click the Show Help Window button on the Main tab of the
Calculator step to launch the Help window, or click the Help button
in the Calculator diagram toolbar. When you move your cursor over
certain elements within the Calculator diagram, information about that
item shows in the Help window.

6. Place your cursor over the Add operator. Notice in the Help window
that the operator has an x input terminal, y input terminal, and
x+y output terminal.

7. Click the Subtract operator in the Functions palette. Click inside the
Calculator diagram to the right of the Find Left Edge - Edge [1].X
Position (Calibrated) input measurement.

Your Calculator diagram should look similar to the diagram shown in
the following picture.




Connecting the Equation Elements


Complete the following instructions to wire the diagram elements together
such that they form Equation 5-1: Right (LC) = Right (RC) + (37).

1. Place your cursor on the small, triangular terminal located on the right
side of the numeric constant. The cursor changes into a Wiring tool.

2. Use the Wiring tool to click the terminal and release the mouse. As you
move the cursor across the Calculator diagram, the Calculator step
draws a wire between the terminal and the Wiring tool as though the
wire were unwinding from a spool.

3. Without holding down the mouse button, move the cursor to the y input
terminal of the Add operator. The y input terminal blinks. Use the
Wiring tool to click the y input terminal and complete the connection.

4. Click the output terminal of the Add operator, and connect it to the
input terminal of Right (LC).

Tip If you do not terminate a wire correctly, the wire is broken and appears as a dashed
black line with a red X in the middle. Click Remove Broken Wires in the Main tab to
remove broken wires.

Complete the following instructions to wire the diagram elements together
such that they form Equation : Part Width = Right (LC) – Left (LC).

1. Place the cursor on the wire that connects the Add operator to
Right (LC). The cursor changes into the Wiring tool.

2. Click the wire, and connect it to the x input terminal of the Subtract
operator.

3. Click the Find Left Edge - Edge [1].X Position (Calibrated) output
terminal, and connect it to the y input terminal of the Subtract
operator.

4. Click the output terminal of the Subtract operator, and connect it to
the input terminal of Part Width.

Your connected Calculator diagram should look similar to the diagram
shown in the next picture.




5. In the Calculator step property page, click the Measurements tab.

6. Click Compute Results to see the results of the calculation thus far.

Making Logical PASS/FAIL Decisions with the Calculator Step


Now that you have a created a diagram to measure the width of the part,
you need a way to verify that the width meets manufacturing specifications.

Complete the following instructions to add diagram elements that compare
the measured width to minimum and maximum width tolerances and
decide whether the plank passes inspection.

1. Click the up arrow in the Functions palette to return to the main palette.

2. Select the Comparison palette.

3. Click the Less? operator in the Comparison palette. Click inside the
Calculator diagram below Part Width.

4. Connect the wire between Subtract and Part Width to the x input of
the Less? operator.

5. Click the up arrow in the Functions palette to return to the main palette.

6. Select the Numeric palette.

7. Click the Num Const operator in the Numeric palette.

8. Click close enough to the y input of Less? to automatically wire the
numeric constant and y input together.

9. Type 40.5 to set the maximum width a plank can be to pass the
inspection.

10. Click the up arrow in the Functions palette to return to the main palette.

11. Select the Comparison palette.

12. Click the Greater? operator. Click inside the Calculator diagram
below the Less? operator.

13. Connect the wire between Subtract and Part Width to the x input of
the Greater? operator.

14. Click the up arrow in the Functions palette to return to the main palette.
15. Select the Numeric palette.

16. Click the Num Const operator.

17. Click close enough to the y input of Greater? to automatically wire the
numeric constant and y input together.

18. Type 39.5 to set the minimum width a plank can be to pass the
inspection.

19. Click the up arrow in the Functions palette to return to the main palette.

20. Select the Boolean palette.

21. Click the And operator. Click close enough to the left side of Step
Result to wire the two elements together.

22. Connect the Less? output to the x input of And.

23. Connect the Greater? output to the y input of And.

Your completed Calculator diagram should look similar to the diagram
shown in the picture.




24. In the Calculator step property page, click the Limits tab.

25. Enable the Step Result is True checkbox.

26. Click OK to add the step to the inspection.

Setting the Inspection Status


Complete the following instructions to add a Set Inspection Status step to
determine whether the inspection passes or fails.

1. In the Inspection Steps palette, select the Use Additional Tools tab.

2. Click the Set Inspection Status step. The property page for the step
opens.

3. In the Inspection Status control, Select the FAIL if any previous
step fails option.

4. Click OK to add the step to the inspection.

Testing the Inspection


Test the inspection to make sure it returns the results you expect. Click the
Run Inspection Once button to test the remaining images. The next table lists
the test images, the inspection status to expect for each image, and an
explanation of the status.



Note Results may vary slightly based on the accuracy of the calibration and the edge
detection location.

Saving the Inspection





No hay comentarios:

Publicar un comentario