Caliper2 Method

NI Vision for Visual Basic

Caliper2 Method

Syntax

CWIMAQVision.Caliper2 SourceImage, Points, CaliperOptions, CaliperReport [, EdgeOptions]

Return Type

Long

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

Purpose

Finds edges along a path in an image, chooses pairs of the edges, and measures the distance between them.

Remarks

Use this method with image types U8, I16, and SGL.

Tip  Use the RegionsProfile method to obtain the Points along the path.

Parameters

SourceImage As CWIMAQImage

The input image.

Points As CWIMAQPoints

The points along which the function uses the caliper tool.

CaliperOptions As CWIMAQCaliperOptions

CaliperOptions specifies the parameters that the method uses for finding the edge pairs.

CaliperReport As CWIMAQCaliperReport

On return, a report object containing information about each edge pair that the method found.

EdgeOptions As Variant

[Optional] A CWIMAQEdgeOptions object defining the characteristics the method uses to find the edges and the parameters it needs for subpixel analysis of the edges.

Example

Private Sub Run_Click()
    'Find edges along the path drawn in the Viewer
    Dim profileReport As New CWIMAQProfileReport
    Dim caliperOptions As New CWIMAQCaliperOptions
    Dim edgeOptions As New CWIMAQEdgeOptions
    Dim caliperReport As New CWIMAQCaliperReport
    Dim j
    'First get the points along the path using RegionsProfile
    CWIMAQVision1.RegionsProfile CWIMAQViewer1.Image, _
                                 CWIMAQViewer1.Regions, _
                                 profileReport
    
    'Then find the edges along the first path in the image in Viewer1
    CWIMAQVision1.Caliper2 CWIMAQViewer1.Image, _
                           profileReport(1).Coordinates, _
                           caliperOptions, _
                           caliperReport, _
                           edgeOptions
    
    'Overlay the edge coordinates
    For j = 1 To caliperReport.Count
        Dim oval As New CWIMAQOval
        oval.Initialize caliperReport(j).Edge1.X - 4, _
                        caliperReport(j).Edge1.Y - 2, _
                        8, 8
        CWIMAQViewer1.Image.Overlays(1).DrawOval oval, _
                                                 cwimaqOverlayModePaint, _
                                                 vbRed
        oval.Initialize caliperReport(j).Edge2.X - 4, _
                        caliperReport(j).Edge2.Y - 2, _
                        8, 8
        CWIMAQViewer1.Image.Overlays(1).DrawOval oval, _
                                                 cwimaqOverlayModePaint, _
                                                 vbRed
    Next
End Sub

See Also

CWIMAQEdgeOptions