FindEdges2 Method

NI Vision for Visual Basic

FindEdges2 Method

Syntax

CWIMAQVision.FindEdges2 SourceImage, Points, EdgeOptions, EdgeCoordinates [, Process = cwimaqEdgeProcessAll] [, EdgeReport]

Return Type

Long

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

Purpose

Obsolete—Use CWIMAQVision.FindEdges3 instead. Finds edges along a path in an image.

Remarks

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

You can use this method in conjunction with the LineProfile2 method or the RegionsProfile method to obtain the Points that define the path.

Parameters

SourceImage As CWIMAQImage

The input image.

Points As CWIMAQPoints

Specifies the coordinates of pixels along which the method detects edges.

EdgeOptions As CWIMAQEdgeOptions

Defines the characteristics that the method uses to find the edges and the parameters it needs for subpixel analysis of the edges.

EdgeCoordinates As CWIMAQPoints

On return, the coordinates of the detected edges. If you specified subpixel accuracy, the method returns the results with subpixel accuracy.

Process As Variant

[Optional] A CWIMAQEdgeProcesses enumeration which determines the type of search. The method can return the first edge, both the first and the last edge, or all edges found along the search path.

This parameter has a default value of cwimaqEdgeProcessAll.

EdgeReport As Variant

[Optional] On return, a CWIMAQEdgeReport object with information about each edge.

Example

' Find the first and last edge coordinates along a path defined by regions
' on Viewer1 and display the coordinates on the image.
Private Sub Run_Click()
    Dim ProfileReport As New CWIMAQProfileReport
    Dim EdgeOptions As New CWIMAQEdgeOptions
    Dim EdgeCoordinates As New CWIMAQPoints
    Dim EdgeReport As New CWIMAQEdgeReport
    Dim J As Integer
    
    ' Find the coordinates of the points along the path
    ' defined by the regions on Viewer1
    CWIMAQVision1.RegionsProfile CWIMAQViewer1.Image, CWIMAQViewer1.Regions, ProfileReport
    
    ' Find the first and last edges along the selected path
    CWIMAQVision1.FindEdges2 CWIMAQViewer1.Image, ProfileReport(1).Coordinates, EdgeOptions, _
                             EdgeCoordinates, cwimaqEdgeProcessFirstAndLast, EdgeReport
    
    ' Display the results
    For J = 1 To EdgeCoordinates.Count
        CWMachineVision1.DrawCircularPoint CWIMAQViewer1.Image.Overlays(1), EdgeCoordinates(J), _
                                           8, cwimaqOverlayModePaint, vbRed
    Next
End Sub

Edge Detection Example
Mechanical Assembly Example

See Also

LineProfile2

RegionsProfile