Using the Cross Section ToolCognex VisionPro

The Cog3DRangeImageCrossSectionTool creates the profile of a range image portion by taking a thin slice of the range image (acquired from a Cognex 3D displacement sensor). The slice is defined by an affine rectangle Region. The tool allows you to look at the profile from the side and perform various measurements on it using operators. The profile is cut parallel to the Z-axis of the range image. The tool returns a Cog3DRangeImageCrossSectionProfile object containing the profile data. It also returns the results of your measurements included in the operators that you use to perform the measurements and the overall status of executing all operators. Note that the tool does not produce a separate result object containing measurement results.

The following figure outlines the steps of profile generation.

Image Processing Profile Plus Theory 3DCross Section Profile Illustration

The operators for the profile include:

Programmatically, these operators must be added to the Cog3DRangeImageCrossSectionOperatorsParams collection class, which is a collection of operators and which fixtures the profile and runs the operators. Once you added the operators to this collection class, configure them, and then run them by using the Execute method. The Execute method takes in a profile object. This method is responsible for the following:
  • Fixturing the profile: adding a user-defined space to the profile space tree in the output profile (optional).
  • Running the operators. The operators are run in the resulting profile space. The operators interpret their regions in that space and produce results in that space.
The Cross Section tool has 2 parts: one to create the profile and the other to run the operators. The Cog3DRangeImageCrossSectionRunParams class provides a central location for executing both parts. The first part can be skipped if you pass in a profile.

For the theory of range images, acquired from displacement sensors, see the Working with 3D Range Images topic. For information on setting up acquisition with your displacement sensor, see the Getting Started topic. For detailed information on range image acquisition, see the Acquiring Images from a DS900 Series Sensor and Acquiring Images from a DS1000 Series Sensor topics. For advanced range image acquisition details, including coordinate spaces related to range images, see the Range Image Coordinate Spaces and Associated Parameters topic. For hardware-related information (such as mounting and physical product features) and further product details, see the DS900 Quick Reference Guide, DS1000 Quick Reference Guide, and the DS1000 Technical Reference Manual.

Profile Extraction and Measurement in QuickBuild

The following example demonstrates profile extraction from a range image and performing measurements on the profile. The geometry of a frustum is measured: the angle of its pyramidal sides and the height difference between its top and rim are measured. The height difference between its top and rim is measured in a separate Cog3DRangeImageCrossSectionTool instance using profile sharing.

Perform the following to extract the profile from a range image and perform the above measurements on it:

  1. Configure the Job's Image Source to acquire images from a Cognex 3D displacement sensor or from an image database containing range images.
  2. Add to the job and connect to the Image Source two Cog3DRangeImageCrossSectionTool instances.
    Image Processing Profile Plus Example 3DCross Section QBConfiguration
    Connect the output profile of the first instance to the input profile terminal of the second instance.

    Note: Even though the input profile you pass to the second instance contains all data you need to perform measurements on it, you must still wire the range image from which you extracted the profile to the second instance to enable fitting its measurement results back on the range image.
  3. Acquire a range image about the object that you want to inspect, in this case a frustum, open the first Cog3DRangeImageCrossSectionTool instance and make sure the range image portion from which you want to extract the profile is in your field of view on the display. Apply Colormap if necessary to better see the portion of the range image that you want to inspect.
  4. Specify the Region based on which the profile should be created. Specify the region as an affine rectangle either using the mouse (defining its location, size and angles of skew and rotation) or numerically (using the region parameters). See more regarding affine rectangle regions and their parameters in the Specifying the Caliper Input Region topic.
    Image Processing Profile Plus Example 3DCross Section Specify Region
    Specifying a thicker region helps suppress noise in the range image.
  5. Run the tool on your selected range image, observe the resulting profile.
    Image Processing Profile Plus Example 3DCross Section Profile Result
  6. Configure the operators for your measurements on the Operators tab. You configure the feature extracting operators by placing an affine rectangle covering the area where you expect the feature to appear. Computing and measurement operators work based on these extracted features. Using the compute operators, you can compute features based on other features, such as information on the relative position of two other features. Operators are executed in the order they are listed, specified by their Index. You can pass the result of one operator as an input to another operator with a greater Index.

    Specifying a line to be extracted:
    Image Processing Profile Plus Example 3DCross Section Operators 1

    Specifying the angle to be measured:
    Image Processing Profile Plus Example 3DCross Section Operators
    Run the tool again and observe your measurement results contained in the operators you configured. The results of a measurement operator include the measured property of the found and analyzed features and a status that indicates whether the features have been found and whether they were within the tolerances you can specify.

    In this case the angle is measured of the two line segments, extracted from the profile, that represent the pyramidal sides of the frustum.

    The angle has been found to be 89.86 degrees.
    Image Processing Profile Plus Example 3DCross Section Operators Result
  7. Open the second Cog3DRangeImageCrossSectionTool instance. On the Profile tab, configure it to accept the profile extracted by the first Cog3DRangeImageCrossSectionTool instance (profile sharing). In this configuration, the second Cog3DRangeImageCrossSectionTool instance will not extract the profile to work based upon, which saves processing time.
    Image Processing Profile Plus Example 3DCross Section Profile Sharing
  8. Configure the operators for the second Cog3DRangeImageCrossSectionTool instance to measure the distance between the frustum's rim (extracted as a line segment) and top (extracted as a point).
    Image Processing Profile Plus Example 3DCross Section Operators 2
    The distance has been found to be 20.12 mm.
    Image Processing Profile Plus Example 3DCross Section Operators 2 Result

When Object Positions Vary, Use Fixturing

If the positions of the objects you want to inspect vary, use fixturing.

Fixturing the Range Image

To make sure you are viewing the profile of the same portion of each object to be inspected, it is recommended that you fixture the range image projection region based on which the profile is created. You can fixture a region in the range image by using the CogFixtureTool. First, you have to extract the 16-bit image component of the range image and convert it to 8-bit using a CogPixelMapTool, and then pass the resulting image to the CogPMAlignTool for alignment.

Fixturing the Profile

You can change the profile coordinate space to a coordinate space that better suits your application than the default Profile2D space. The profile data will be expressed in the profile coordinate space you specify. You can, for example, fixture your profile coordinate space to a known feature within the profile. You can extract that specific feature from the profile using another Cog3DRangeImageCrossSectionTool and pass its location information to your original tool. That location information can be the origin of your new profile coordinate space. You can set your profile coordinate space on the Fixture tab. Manually, you can adjust your profile coordinate space in the Current.Fixture record.

Image Processing Profile Plus Example 3DCross Section Manual Fixture

You can pin the profile regions specified in the operators to their current location while you are changing the profile space selection or the new space transform by setting PinRegions to True. The profile regions with the default selected space name equal to "." will be updated. The profile regions with any other selected space name will not be pinned, updated, or modified. The PinRegions applies only during the setup of the Cross Section tool, it is ignored at runtime. This property is only used by the control; the programmatic interface ignores this property. This option must be checked before specifying the new space if operators exist already.

The following figure shows the results of the operators in the new fixtured profile space, while the regions were pinned during fixture setup.
Image Processing Profile Plus Example 3DCross Section Operators Result Fixtured Pinned

Results Displayed

In addition to displaying the results of the operators in the Current.Profile record, results such as points and line segments are also displayed mapped back on the input range image.

Image Processing Profile Plus Example 3DCross Section Operators Result Mapped

Image Processing Profile Plus Example 3DCross Section Operators Result Mapped 2

Measurements are not mapped back to the range image.

The Cog3DRangeImageCrossSectionTool also displays the results in a convenient way in the LastRun.CombinedGraphics record, which combines and displays all results with the Region-X axis position adjusted to be near your profile contour features.
Image Processing Profile Plus Example 3DCross Section Operators Result Combined

Image Processing Profile Plus Example 3DCross Section Operators Result Combined 2

Area Measurement

The following example demonstrates profile extraction from a range image and performing measurements on the profile. The subject is a V-channel and the cross-section profile of it looks like this:

Image Processing Profile Plus Example 3DCross Section VChannel

We can measure different things related to this, for example its capacity.

Image Processing Profile Plus Example 3DCross Section VChannel Capacity

It can be filled with different materials as well (like glue).

Image Processing Profile Plus Example 3DCross Section VChannel Glue

With area measurement, we can answer the following questions:

  • What is the capacity of the V-channel?
  • How much glue is in it?
  • What is the remaining area?
  • Does it have too much glue in it?
  • Does it have enough glue in it?

When this V-channel is filled with something, we get the following cross-section profile:

Image Processing Profile Plus Example 3DCross Section VChannel Cross Section Profile

Since the lower part is filled with glue, that part is not visible for the camera and the Cross Section Tool could not extract that part. But we know that the V-Channel is perfectly manufactured and the sides are straight lines and we know where the imaginary continuation of the sides intersect that would be the bottom of the V-Channel. So basically we can reconstruct the V-Channel's profile from the visible pieces and we have the profile of the filling, so we have all the information to measure the area of the filling.

Image Processing Profile Plus Example 3DCross Section VChannel Cross Section Line Segments

Add two operators to extract line segments and we could use those line segments as boundaries of the interesting area at the bottom while the profile's curve could be the upper boundary. In general, the new Area operator will measure the area between:

  • The profile of a cross-section and
  • One or more line segments

The line segments will be interpreted as infinite lines and these infinite lines will make up a new reference profile and we can measure the difference between these two profiles.

Image Processing Profile Plus Example 3DCross Section VChannel Cross Section Area Highlighted

The user can specify whether the curves that represent the threshold (HeightThreshold) above and below the reference profile should be displayed or not (by default it is not displayed). If the user chooses to display them, they will be drawn with white dashed lines. In the case of very small threshold value it will be necessary to zoom in to see them.

Image Processing Profile Plus Example 3DCross Section No Threshold

With MaxFillLength, the user can determine the maximum length along the X-axis the Cross Section Tool is supposed to fill. Intervals greater than this value will not be considered as part of the area to be measured.

Image Processing Profile Plus Example 3DCross Section Max Fill Length

Depending on what we want to measure in the Cross Section Tool's profile, we can create the reference profile from the highest or from the lowest line segments. Depending on the choice, the Cross Section Tool goes along the points of the X-axis and seeks the corresponding lowest or highest points of the reference profile on the Y-axis. The following illustrations show two cross section profiles and the difference between the measured area with the highest and with the lowest line segments. The reference profile is marked with orange.

The base cross section profile (input profile)
Image Processing Profile Plus Example 3DCross Section Highest Lowest Base Input Profile

The area between the highest points of the reference profile (orange) and the corresponding points of the base cross section profile (input profile)
Image Processing Profile Plus Example 3DCross Section Highest Lowest Area Above Create From Highest

The base cross section profile (input profile)

The area between the lowest points of the reference profile (orange) and the corresponding points of the base cross section profile (input profile)
Image Processing Profile Plus Example 3DCross Section Highest Lowest Area Above Create From Lowest

Finally, we might be interested in the area that is under the input profile and above the reference profile, or that is above the input profile and under the reference profile or both. Since this choice is heavily application-specific, the option is given to the users to pick the one that fits their application needs the most.

Area Above and Below the Reference Profile

The meaning of "measuring both" the area above and the area below the reference profile always depends on the actual application. It can mean that the total area is the sum of the above and the below area, or the value of area above the reference profile minus the value of the area below the reference profile. See an example below:

Image Processing Profile Plus Example 3DCross Section Input Profile

The input profile is represented by the yellow line and the line segment is the dashed light blue line. The measured area is the following:

Image Processing Profile Plus Example 3DCross Section Above Below

  • The area painted in yellow (in the picture above) is the area above the reference profile since it is above the line segment and below the profile’s curve.
  • The area painted in light blue (in the picture above) is the area below the reference profile because it is below the line segment and above the input profile’s curve.
Those can be of an interest separately or together depending on the application.

Since we distinguish between area above the reference profile and area below the reference profile the question arise how we want to treat these separate areas when both parts are being measured. Again, it is application specific, whether their values add up or they balance out each other when summarized. Therefore the user can set what part of the area he is interested in and how it should be calculated in the case when both the area above and below the reference profile is measured. Therefore we provide the following four choices:

  • Measure only the area that is above the reference profile.
  • Measure only the area that is below the reference profile.
  • Measure both the area that is above the reference profile and below the reference profile and add their values together, i.e. TotalArea = AreaAbove + AreaBelow
  • Measure both the area that is above the reference profile and below the reference profile and subtract the value of the area below from the value of the area above., i.e. TotalArea = AreaAbove - AreaBelow

The farthest point is a point on the input profile where the difference between the input profile and the reference profile is the greatest. Likewise, the closest point is the point on the input profile where the difference between the input profile and the reference profile is the smallest. This difference is always measured along the height-value axis and the Cross Section Tool will return these closest and farthest points for both above the reference profile and below the reference profile.