Fit Line to Surface Edge

Description

Use this Step to fit a line to the straight edge detected from the surface data.

Basic Concepts

Search Direction, Profile, and Edge Points

Set a feature region on the input surface data, ensuring that it contains the straight edge to be detected. The depth or intensity value of data points at the edge will change significantly. To find out the points of significant changes, you can use the Step to extract evenly spaced profiles along the search direction. Each profile can well reflect the depth and intensity change of points at the edge. The search direction should be as perpendicular to the edge as possible. Then, you can detect edge points from the extracted profiles and use these points to fit a line.

basic concepts

As shown in the figure above, extracts evenly spaced profiles along the search direction (0°, the positive X-axis direction) and detects edge points from these profiles.

In summary, the basic concepts you should grasp while using this Step are as follows:

  • Search direction

    The direction along which the profiles are extracted in the feature region(s). The search direction should be as perpendicular to the edge as possible to better reflect changes in depth or intensity values of points at the edge.

  • Profiles and edge points

    The Step will detect edge points that meet the requirements from each profile and fit a line with these points. An edge point is not necessarily a point on the profile. Instead, it is a point with the greatest gradient change calculated by the changes in depth and intensity.

    single profile

    A profile, where the blue dot is the detected edge point.

Workflow

The process of configuring this Step is shown below.

fit line to surface edge process
  1. Configure the input. Connect the Step ports in the graphical programming workspace or select the input under Input in the parameter configuration panel.

  2. Set the feature region(s) for edge detection and line fitting.

  3. Select the Edge Detection Mode and set the parameters accordingly.

  4. Select the desired output items under Output. For an expandable output item, click ▶ and configure the Min and Max values to determine the acceptable range for the item.

  5. Run the Step and view output.

Parameter Description

General Parameters

Parameter Description

Use Intensity Image

Select this option to use the intensity image for edge detection when the target detection region is flat, and the color differences in the region are prominent.

Once selected, the Step uses the intensity image for straight edge detection and line fitting; otherwise, the Step uses the depth map by default.

Feature Regions

Set 1–4 feature region(s) for edge detection and line fitting. See Feature Regions to learn about how to adjust a feature region.

Search Direction

The direction for detecting edge points. The Step will extract profiles along the search direction to detect edge points. The search direction is defined as the angle of rotation about the Z-axis counterclockwise, relative to the positive X-axis direction.

Value list: 0°, 90°, 180°, 270°

The search direction should be roughly perpendicular to the straight edge.

Fixed Angle

Select this option to fix the angle of the fitted line when the actual edge angle is known. Once this option is selected, you should set Fixed Angle Value.

This parameter can only determine the position of the line and cannot determine the line direction.

Fixed Angle Value

The angle of rotation about the Z-axis counterclockwise, relative to the positive X-axis direction. The angle should be within -180°–180°

Only visible when Fixed Angle is selected.

Outlier Fraction

The percentage of outlier points to be removed during line fitting.

Edge Detection Mode

The depth or intensity changing mode of data points at the edge.

  • Step: The depth or intensity values of points at the edge change abruptly. Once you select the step mode, set step edge parameters.

  • Corner: The depth or intensity values of points at the edge change continuously. Once you select the corner mode, set corner edge parameters.

Fitted Line Direction

Select an appropriate option from the drop-down list to determine the direction vector of the fitted line, thus determining the direction of the fitted line.

  • Positive X: The X component of the direction vector is positive.

  • Negative X: The X component of the direction vector is negative.

  • Positive Y: The Y component of the direction vector is positive.

  • Negative Y: The Y component of the direction vector is negative.

Profile Spacing

The distance between adjacent profiles in the feature region(s). If the set spacing is less than the pixel width of a pixel, the Step will take the pixel width as the profile spacing.

The smaller the spacing, the more profiles there are, the more edge points are detected, and the more accurate the fitted line, but the computational cost is also higher.

Profile Averaging Width

The size of the windows for calculating the average of data points along the direction perpendicular to the profile to obtain a smoother profile and thus reduce the impact of noise. When it is set to 0, no averaging operation will be performed on the profiles.

Set the parameter according to your actual needs. A window that is too large may lead to excessive smoothing and loss of important details; if a window is too small, however, the noise may not be effectively reduced.
profile averaging width

Show Detail

Select this parameter to display the search direction in the visualization window.

Step Edge Parameters

Set the parameters below when you set the edge detection mode to Step.

Parameter Description

Window Size for Profile Smoothing

The window size for averaging profiles along the search direction (the direction of profiles). After averaging, the profile will be smoother. When it is set to 0, no averaging operation will be performed on the profiles along the search direction.

window size for profile smoothing

Gap Filling Threshold

The data points on a profile may be subject to a gap due to occlusion. When the size of a gap on a profile is less than or equal to the set threshold, use the nearest valid point from the lower side of the gap to fill the gap. When the gap size exceeds the set threshold, leave the gap as null point(s).

gap filling
If the gap size exceeds the set threshold, you can decide whether to Include Null points or not in the edge detection process.

Include Null Points

Use this parameter to determine whether to include null points or not in the edge detection process. (Null points are points without depth or intensity information, which are often the result of data loss or inappropriate settings of the feature region(s).) Once this parameter is selected, set Null Filling Value of Depth.

Null Filling Value of Depth

A depth value for filling null points.

Only needs to be set after Include Null Points is selected.

Null Filling Value of Intensity

An intensity value for filling null points.

Only needs to be set after both Use Intensity Image and Include Null Points are selected.

Step Width

The width of the step on a profile. When the step on a profile is a slope, set this parameter can help you accurately measure the step height and locate the position of the edge.

The step width should be slightly greater than the edge with so that the Step can accurately measure the step height on the basis of the flat region on both sides of the edge.

Step Direction

The step direction along the search direction.

Value list: Rising, Falling, Rising or falling.

Step Type

Set the type of step that will be selected from each profile.

Value list: Best, First, Last.

Absolute Threshold

The minimum height variation for a potential step on a profile.

When the parameter Use Intensity Image is selected, absolute threshold means the minimum intensity variation for a potential step on a profile.

Use Relative Threshold

Use this parameter to determine that a step is valid if the height (or intensity) change of the step is not less than the set percentage of the maximum change found on a profile. Once this parameter is selected, set Relative Threshold.

A step is valid only when both Absolute Threshold and Relative Threshold are satisfied.

Relative Threshold

Only visible when Use Relative Threshold is selected.

Corner Edge Parameters

Set the parameters below when you set the edge detection mode to Corner.

Parameter Description

Corner Type

Select a proper corner type from the drop-down list to determine the edge point.

Value list: First, Last, Top, Bottom, Best.

Epsilon

This parameter reflects the sensibility to the change of the profile shape. A larger value means that fewer points can meet the requirements, and thus it is more challenging to detect corners.

In most cases, set the value between 0 and 1 can meet the needs.

Output Description

Select the output item(s) to add the output port(s) to the Step, and the corresponding data will be output after the Step is run. You can select the output according to the actual measurement requirements.

If you select an expandable output item, you should expand it by clicking ▶, and then set the Min and Max values to determine the acceptable range. If the output value falls within the acceptable range, the measurement item is judged as passing (OK), or else it is judged as failing (NG).

Output item Description

Center X

The X value of the midpoint of the fitted line.

Center Y

The Y value of the midpoint of the fitted line.

Center Z

The Z value of the midpoint of the fitted line.

Rotation Angle

The rotation angle of the fitted line, i.e., the angle of rotation about the Z-axis counterclockwise, relative to the positive X-axis direction. If you have set a Fixed Angle Value, then the rotation angle is determined by both the fixed angle value and the fitted line direction.

Average Step Size

The average step height or intensity of all profiles.

Edge Point Count

The number of edge points used for line fitting.

Min Error

The error value of the edge point farthest below the fitted line, which is a negative number.

Max Error

The error value of the edge point farthest above the fitted line, which is a positive number.

Fitted Edge Line

The fitted line by detected edge points.

Center Point

The intersection point of the fitted line with the line representing the search direction through the center point of Region1.

Edge Plane

The plane through the fitted line and parallel to the Z-axis.

Troubleshooting

  • For common errors, see Error Code List.

  • If the error code is inconsistent with the error message, please contact Technical Support for help.

CV-W3301

Error: The “Profile Spacing” value is not within the valid range.

Possible cause: The parameter value is less than 0 or greater than the length of the longest side of the image.

Solution: Ensure the parameter value is greater than or equal to 0 and less than the length of the longest side of the image.

CV-W3302

Error: The “Window Size for Profile Smoothing” value is not within the valid range.

Possible cause:

  • The parameter value is less than 0 or greater than the length of the longest side of the image.

  • The parameter value is not within the valid range of the feature region(s).

Solution:

  • Ensure the parameter value is greater than or equal to 0 and less than the length of the longest side of the image.

  • Lower the parameter value or expand the feature region(s) to make sure the value is within the valid range.

CV-W3303

Error: The “Step Width” value is not within the valid range.

Possible cause:

  • The parameter value is less than 0 or greater than the length of the longest side of the image.

  • The parameter value is not within the valid range of the feature region(s).

Solution:

  • Ensure the parameter value is greater than or equal to 0 and less than the length of the longest side of the image.

  • Lower the parameter value or expand the feature region(s) to make sure the value is within the valid range.

CV-W3304

Error: The “Gap Filling Threshold” value is not within the valid range.

Possible cause: The parameter value is less than 0 or greater than the length of the longest side of the image.

Solution: Ensure the parameter value is greater than or equal to 0 and less than the length of the longest side of the image.

CV-W3305

Error: The “Outlier Fraction” value is not within the valid range.

Possible cause: The parameter value is less than 0 or greater than 1.

Solution: Make sure the parameter value is within 0–1.

CV-W3306

No edge points detected.

Possible cause:

  • The feature region is not set properly.

  • “Absolute Threshold” and “Relative Threshold” are too large.

  • The “Search Direction” is not set properly.

Solution:

  • Adjust the feature region to ensure edge points can be detected from the region(s).

  • Lower “Absolute Threshold” and “Relative Threshold” values.

  • The “Search Direction” should be as perpendicular to the edge to be detected as possible.

CV-W3307

The set Epsilon value is invalid.

Possible cause: The parameter value is less than 0.

Solution: Make sure the parameter value is greater than or equal to 0.

CV-W3308

Error: The “Profile Averaging Width” value is outside of the valid range.

Possible cause:

  • The parameter value is less than 0 or greater than the length of the longest side of the image.

  • The parameter value is not within the valid range the feature region(s).

Solution:

  • Ensure the parameter value is greater than or equal to 0 and less than the length of the longest side of the image.

  • Lower the parameter value or expand the feature region(s) to make sure the value is within the valid range.

CV-W3309

Error: The feature region settings are invalid.

Possible cause:

  • The length or width of the feature region(s) is less than or equal to 0.

  • The length or width of the feature region(s) is more than twice the length of the longest side of the image.

Solution:

  • Ensure that the length and width of the feature region(s) are greater than 0.

  • Ensure the length and width of the feature region(s) are less than twice the length of the longest side of the image.

CV-W3310

Error: The “Null Filling Value of Intensity” value is the valid range.

Possible cause: The parameter value is less than 0 or greater than 255.

Solution: Make sure the parameter value is within 0–255.

CV-W3311

Error: The “Null Filling Value of Depth” value is not within the valid range.

Possible cause: The parameter value is less than −10000 or greater than 10000.

Solution: Make sure the parameter value is within −10000–10000.

CV-W3312

Error: The set “Corner Type” is invalid.

Solution: Select a valid corner type from the drop-down list.

CV-W3313

Error: The “Relative Threshold” value is outside of the valid range.

Possible cause: The parameter value is less than 0 or greater than 1.

Solution: Make sure the parameter value is within 0–1.

CV-W3314

Error: The “Absolute Threshold” value is outside of the valid range.

Possible cause: The parameter value is less than 0 or greater than or equal to 255.

Solution: When the “Use Intensity Image” parameter is selected, ensure the absolute threshold is within 0–255.

CV-W3315

Error: The “Absolute Threshold” value is outside of the valid range.

Possible cause: The parameter value is less than 0 or greater than or equal to 10000.

Solution: Make sure the parameter value is within 0–10000.

CV-W3316

Error: The set “Edge Detection Mode” is invalid.

Solution: Select a valid edge detection mode from the drop-down list.

CV-W3317

Error: The set “Search Direction” is invalid.

Solution: Select a valid search direction from the drop-down list.

CV-W3318

Error: The set “Step Direction” is invalid.

Solution: Select a valid step direction from the drop-down list.

CV-W3319

Error: The set “Step Type” is invalid.

Solution: Select a valid step type from the drop-down list.

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.