FindCoordTransformUsingTwoRects Method

NI Vision for Visual Basic

FindCoordTransformUsingTwoRects Method

Syntax

CWMachineVision.FindCoordTransformUsingTwoRects SourceImage, MainAxisSearchArea, SecondaryAxisSearchArea, MainAxisScanDirection, AxisOrientation, FirstRun, CoordinateTransformation [, FindCTUsingTwoRectsOptions] [, MainAxisLine] [, SecondaryAxisLine]

Return Type

Long

On success, this method returns 0. On failure, this function returns a negative number.

Purpose

Computes a coordinate system based on the position of an object in two search areas of an image. The location and orientation of the coordinate system found is used to create the reference position of a coordinate system or to update the current location and orientation of an existing coordinate system. The function has the capability to overlay, on the image returned, the position of the search area, the search lines, the edges found, and the location and orientation of the Coordinate System found.

Remarks

Use this method with U8, I16, and SGL images.

The method uses the following algorithm. First the method determines the position of the main axis of the coordinate system. It locates the intersection points between a set of parallel search lines, in the MainAxisSearchArea, and the edge of an object. The intersection points are determined based on their contrast, width and steepness. The method calculates a best-fit line through the points found. This line defines the main axis of the coordinate system. The process is repeated perpendicularly in the SecondaryAxisSearchArea in order to locate the secondary axis. The intersection between the main axis and secondary axis is the origin of the coordinate system.

Parameters

SourceImage As CWIMAQImage

The input image.

MainAxisSearchArea As CWIMAQRotatedRectangle

Specifies a rectangular search area where the edge corresponding to the MainAxis is to be located.

SecondaryAxisSearchArea As CWIMAQRotatedRectangle

Specifies a rectangular search area where the edge corresponding to the SecondaryAxis is to be located.

MainAxisScanDirection As CWIMAQRakeScanDirections

Indicates the direction of the rake which will search for the main axis.

AxisOrientation As CWIMAQAxisOrientations

The scan direction for the secondary axis is rotated 90 degrees from the scan direction of the main axis. AxisOrientation indicates whether the 90 degree angle is determined using a direct or indirect coordinate system.

FirstRun As Boolean

Indicates whether this is the first time that FindCoordTransformUsingPattern is run. If it is, this method uses the coordinate system it finds as the reference and measurement coordinate system. Otherwise, it updates the MeasurementSystem and leaves the ReferenceSystem unchanged.

CoordinateTransformation As CWMVCoordinateTransformation

On return, this parameter contains the reference coordinate system and measurement coordinate system.

FindCTUsingTwoRectsOptions As Variant

[Optional] A CWMVFindCTUsingTwoRectsOptions object defining the parameters of the algorithm that detects the edge locations and the information that are overlaid to the result image. Two independent sets of parameters specify the filters used to detect the main axis and the secondary axis.

MainAxisLine As Variant

[Optional] On return, a CWIMAQLine object specifying the coordinates of the edge corresponding to the MainAxis. The first point is the intersection of the two axes of the coordinate system. The second point is the result of the computation of the intersection of the MainAxis with the MainAxisSearchArea.

SecondaryAxisLine As Variant

[Optional] On return, a CWIMAQLine object specifying the coordinates of the edge corresponding to the SecondaryAxis. The first point is the intersection of the two axes of the coordinate system. The second point is the result of the computation of the intersection of the SecondaryAxis with the SecondaryAxisSearchRectangle.

Example

Fuse Inspection Example

See Also

FindCoordTransformUsingPattern

FindCoordTransformUsingRect

CWIMAQVision.Rake

TransformRegions

CWIMAQRotatedRectangle

CWMVFindCTUsingTwoRectsOptions

CWIMAQLine