TransformRegions Method

NI Vision for Visual Basic

TransformRegions Method

Syntax

CWMachineVision.TransformRegions Regions, CoordinateTransformation

Return Type

Long

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

Purpose

Rotates and translates a Regions collection to transform the Regions from the reference coordinate system to the measurement coordinate system.

Remarks

This is a convenience method that calls CWIMAQVision.TransformRegions to actually do the transformation.

Parameters

Regions As CWIMAQRegions

The regions to transform.

CoordinateTransformation As CWMVCoordinateTransformation

The transformation to apply to the regions.

Example

Private Sub Run_Click()
    'Create a dummy transformation. Normally you would get this from:
    '  CWMachineVision.FindCoordTransformUsingRect
    '  CWMachineVision.FindCoordTransformUsingTwoRects
    '  CWMachineVision.FindCoordTransformUsingPattern
    Dim Transformation As New CWMVCoordinateTransformation
    With Transformation.ReferenceSystem
        .Angle = 0.3947748
        .AxisOrientation = cwimaqAxisOrientationDirect
        .Origin.Initialize 133.6109, 334.8592
    End With
    With Transformation.measurementsystem
        .Angle = 3.627943
        .AxisOrientation = cwimaqAxisOrientationDirect
        .Origin.Initialize 133.3554, 347.2317
    End With
    
    'Transform the regions on the viewer
    CWMachineVision1.TransformRegions CWIMAQViewer1.Regions, Transformation
End Sub

See Also

CWIMAQVision.TransformRegions