Measure of each workpiece after classifiering the kind of workpieces

Overview

This Sample executes measurement of each workpiece after classifiering the kind of workpieces.

Specification of this example


Behavior
This Sample executes measurement of each workpiece after classifiering the kind of workpieces.
When 'Workpiece1' is found, [EC Circle Search] is executed, and displays the measurement result of it.
When 'Workpiece2' is found, [Search] is executed, and displays the measurement result of it.
When 'Workpiece3' is found, [Edge Position] is executed, and displays the measurement result of it.

Screenshot


How to try this example
1.Click the link below, then the folder containing zip file automatically opens.
refFile

2.Right-click and hold on the zip file, and drop it on working window of FJ system. The images and scene data in zip file are loaded on the program automatically.

3.Re-measure the image. Then System automatically classifieres the kind of workpieces.
4.When 'Workpiece1' is found, [Ec Circle Search] is executed, and displays the measurement result of it.
When 'Workpiece2' is found, [Search] is executed, and displays the measurement result of it.
When 'Workpiece3' is found, [Edge Position] is executed, and displays the measurement result of it.

How to implement

Scene data
Unit No.
Processing Item
0.
Camera Image Input
1.
Classification
2.
Macro
3.
End
4.
Ec Circle Search
5.
Search
6.
Edge Position
The Macro Program below segment is to be set in '2.Macro'.
Macro Program
*MCRINIT
    'Initialize                              '(1)
    UNITNO& = 1
    UNITNO1& = 4
    UNITNO2& = 5
    UNITNO3& = 6
    FONTSIZE& = 32
Return

*MEASUREPROC

    GetUnitData UNITNO&, 6, MODELNO&         '(2)

    Select MODELNO&         '(3)
        Case -1
        RESULT$ = "No Workpiece"
        Case 0
        MeasureProc UNITNO1&
        GetUnitData UNITNO1&, 5, POSITIONX#
        GetUnitData UNITNO1&, 6, POSITIONY#
        RESULT$ = "Workpiece1"
        Case 1
        MeasureProc UNITNO2&
        GetUnitData UNITNO2&, 6, POSITIONX#
        GetUnitData UNITNO2&, 7, POSITIONY#
        RESULT$ = "Workpiece2"
        Case 2
        MeasureProc UNITNO3&
        GetUnitData UNITNO3&, 5, POSITIONX#
        GetUnitData UNITNO3&, 6, POSITIONY#
        RESULT$ = "Workpiece3"
    END SELECT


Return

*MEASUREDISPG

    SetTextStyle FONTSIZE&, TA_TOP, JUDGE_OK, 0, FONTSTYLE_BOLD + FONTSTYLE_UNDERLINE    '(4)
    DrawTextG "Detected Workpiece : " + RESULT$ + " Found.", 10, 20, 0

    If MODELNO& >= 0 Then
        DrawTextG "PositionX F " + Str$(POSITIONX#) + " Position Y : " + Str$(POSITIONY#), 10, 50, 0
    EndIf

Return

The macro program is in refthis link.
Explanation
(1)Initialize parameters(ex.unit no of processing units ) when initialize measurement.
(2)Get the model no of [Classification].
(3)Execute the measurement of the processing unit which is selected by the model no, and get the measurement result of it.
(4)Display the measurement result in Image Window.