Fit Rectangle to Surface Edge

You are currently viewing the documentation for the latest version (2.2.0). To access a different version, click the "Switch version" button located in the upper-right corner of the page.

■ If you are not sure which version of the product you are currently using, please feel free to contact Mech-Mind Technical Support.

Description

This Step is used to detect the edge of a rectangle from the surface data and fit the rectangle.

Basic Concepts

  • Caliper

    The calipers will be placed evenly along the rectangular path at the specified caliper center spacing. From the data in each caliper region, a profile perpendicular to the rectangular path can be extracted.

  • Profile

    A string of data points extracted from the caliper region. By smoothing the profile, gap filling, and detecting edges, edge points for fitting oblong holes can be obtained.

  • Edge point

    A position on the profile at the edge of the rectangle where the depth or intensity value changes significantly. The Step extracts edge points from each profile for final fitting based on the configured edge detection parameters.

Workflow

The process of configuring this Step is shown below:

  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 according to the rectangle position, and then determine whether to enable Use intensity image according to the actual scenario.

  3. Configure the Caliper Settings so that the calipers cover all sides of the rectangle as evenly as possible.

  4. Configure the Profile Processing and Edge Detection Settings to ensure stable extraction of edge points.

  5. Configure Fitting Settings.

  6. Under Output, select the Output Items. Click ▶ on the left of an output item to expand it, and configure the Lower limit and Upper limit values to define the acceptable range.

  7. Run the Step and view output.

Input Description

Input item Description

Surface Data

Surface data used for detecting rectangle-shaped edges and rectangle fitting.

Alignment Parameter Group

Used to adjust the target region’s pose in sync with the target object’s pose changes.

See Alignment Parameter Group for usage scenarios.

Parameter Description

General Parameters

Parameter Description

Use Intensity Image

Enable this option to use the intensity image to detect the edge of a rectangle when the target region is relatively flat and has distinct color differences.

When this option is selected, the Step uses intensity image data for edge detection and fitting. Otherwise, the Step uses depth map data by default.

Feature Region

Used to define the approximate position of the rectangular edge in the surface data. The system automatically generates a closed rectangular path in this region as a track line for the caliper placement.

The feature region should be slightly larger than the actual rectangular edge to ensure complete edge coverage. For more information on how to set and adjust the feature region(s), see Feature Region.

Caliper Settings

Parameter Description

Caliper Center Spacing

The distance between two caliper centers on a rectangular path.

Setting this parameter properly can make the calipers evenly distributed along the rectangular edges, thus obtaining more stable edge points.

Caliper Width

The caliper width along the rectangular path.

Caliper Length

The length direction of the caliper is perpendicular to the path direction of the rectangular.

Setting the caliper length appropriately ensures that the profile line fully crosses the rectangular edges, enabling stable edge point extraction.

Profile Processing

Parameter Description

Window Size for Profile smoothing

The window size used to filter each profile line along its direction. After filtering, the profiles become smoother.

Gap Filling Threshold

When a gap on a profile is less than or equal to the configured threshold, it is filled using the first valid point on the lower side of the gap. When the gap exceeds the threshold, it remains invalid.

Include Null Points

When this option is selected, you must specify a fixed value to fill all invalid points on the profile.

Setting this parameter helps ensure the continuity of the profile data and avoid missed detections caused by invalid points.

Null Filling Value of Depth

The depth value used to fill invalid points in the profile.

This parameter only needs to be set when Include Null Points is selected.

Null Filling Value of Intensity

The intensity value used to fill invalid points in the profile.

This parameter only needs to be set when both Use Intensity Image and Include Null Points are selected.

Edge Detection Settings

Parameter Description

Edge Polarity

Defines the direction of depth or intensity value changes from the inside to the outside of the rectangle edge.

Value list: Rising, Falling, Rising or falling

Edge Mode

Define the edge types to be retained in edge detection.

Value list: Best, First, Last

Absolute Depth Variation Threshold

At the edge of the rectangle hole, the absolute value of depth change of adjacent data points on the profile must be greater than or equal to this threshold for edge points to be detected.

Absolute Intensity Variation Threshold

At the edge of the rectangle hole, the absolute intensity change between neighboring data points on the profile must be greater than or equal to this threshold to enable edge point detection.

Only needs to be set after Use Intensity Image is selected.

Use Relative Threshold

Once this parameter is selected, edge points will only be detected if the depth or intensity value between neighboring data points varies by at least the specified percentage of the maximum variation on the profile.

Relative Threshold

Only visible when Use Relative Threshold is selected.

This parameter specifies the lower limit of the relative variation relative to the maximum variation on the profile.

Fitting Settings

Parameter Description

Max Iterations

The maximum number of attempts the algorithm will make to fit an optimal plane. Iteration stops once this limit is reached.

Max Distance Threshold

The maximum allowed distance from detected edge points to the fitted rectangle. Edge points with a distance less than or equal to this threshold are considered inliers.

Min Fit Score

The lowest score for determining whether the fitted result is acceptable. The score equals the ratio of the number of inliers to the total number of edge points.

The algorithm takes the iteration result with the highest inlier ratio and compares its score against the set value. If the score is lower than this value, the fitting is judged as failed. This parameter is only used for result evaluation and will not affect the fitting process.

Show Detail

Once this option is selected, the rectangular path, calipers, and relevant detection details can be displayed in the visualization window to facilitate parameter tuning.

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 Lower limit and Upper limit values to determine the acceptable range. If the output value of the measurement item falls within the acceptable range, it is judged as okay (OK), or else it is judged as not good (NG).

Output item Description

Center Point

The geometric center of the fitted rectangle.

Center X

The X coordinate of the center point of the fitted rectangle.

Center Y

The Y coordinate of the center point of the fitted rectangle.

Rectangle Width

The width of the fitted rectangle.

Rectangle Length

The length of the fitted rectangle.

Rectangle Rotation Angle

The rotation angle of the fitted rectangle, relative to the positive X-axis direction.

Fitted Rectangle

The fitted rectangle.

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-W4301

Error: The set “Caliper Length” value is outside of the valid range.

Solution: Ensure the parameter value is within 0–1000.

CV-W4302

Error: The set “Caliper Center Spacing” value is outside of the valid range.

Solution: Ensure the parameter value is within the range of 0 to 100.

CV-W4303

Error: The set “Caliper Width” value is outside of the valid range.

Solution: Ensure the parameter value is within the range of 0 to 100.

CV-W4304

Error: The set “Gap Filling Threshold” value is outside of the valid range.

Solution: Ensure the parameter value is within the range of 0 to 100.

CV-W4305

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

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

Solution: Ensure the parameter value is within the range of 0 to 255.

CV-W4306

Error: The “Null Filling Value of Depth” is outside of the valid range.

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

Solution: Ensure the parameter value is within −10000–10000.

CV-W4307

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

Solution: Ensure the parameter value is within the range of 0 to 100.

CV-W4308

Error: The set “Edge Polarity” is invalid.

Solution: Select valid edge polarity from the drop-down list.

CV-W4309

Error: The set “Edge Type” is invalid.

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

CV-W4310

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

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

Solution: Ensure the parameter value is within the range of 0 to 255.

CV-W4311

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

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

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

CV-W4312

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

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

Solution: Ensure the parameter value is within the range of 0% to 100%.

CV-W4313

Error: Unable to fit a rectangle since the detected edge points are insufficient.

Possible causes:

  • The calipers are not set properly.

  • The position or size of the feature region(s) is inappropriate.

  • The set “Absolute Depth Change Threshold” or “Absolute Intensity Change Threshold” or “Relative Threshold” is too large.

Solutions:

  • Adjust the caliper settings to ensure edge points can be detected from the calipers.

  • Set the feature region(s) properly.

  • Decrease “Absolute Depth Change Threshold” or “Absolute Intensity Change Threshold” or “Relative Threshold”.

CV-W4314

Error: Unable to fit a rectangle since the detected edge points are insufficient.

Possible causes:

  • The calipers are not set properly.

  • The position or size of the feature region(s) is inappropriate.

  • The set “Absolute Depth Change Threshold” or “Absolute Intensity Change Threshold” or “Relative Threshold” is too large.

Solutions:

  • Adjust the caliper settings to ensure edge points can be detected from the calipers.

  • Set the feature region(s) properly.

  • Decrease “Absolute Depth Change Threshold” or “Absolute Intensity Change Threshold” or “Relative Threshold”.

CV-W4316

Error: The “Min Fit Score” must be within the range [0, 1].

Solution: Ensure the parameter value is within [0, 1].

CV-W4318

Error: The “Max Distance Threshold” value must exceed 0.

Solution: Ensure the parameter value is greater than 0.

CV-W4319

Error: The “Max Iterations” value is outside of the valid range.

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

Is this page helpful?

You can give a feedback in any of the following ways:

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.