Measure multiple images at once

Overview

This sample measures multiple images at once.

Specification of this example


Behavior
This sample saves multiple images and measures them at once.

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 only saves images in first and second measurement trigger.
4.In third measurement trigger, System saves images and executes [Search] measurement to all saved images, and displays the measurement results in Text Window.

How to implement

Scene data
Unit No.
Processing Item
0.
Camera Image Input
1.
Macro
2.
End
3.
Search
The Macro Program below segment is to be set in '1.Macro'.
Macro Program
*MCRINIT
    SEARCHUNIT& = 3         '(1)
    MYUNIT& = UnitNo         
    MEASURENUM&=0
    Dim POSX#(2), POSY#(2), JUDGE&(2)
Return

*MEASUREPROC
    '(2)
    If MEASURENUM& >= 3 Then
        MEASURENUM& = 0
    EndIf

    CopyUnitImage 0, 0,  (5 + MEASURENUM&)     '(3)
    MEASURENUM& = MEASURENUM& + 1

    '(4)
    If MEASURENUM& = 3 Then
        For COUNT& = 0 To 2 Step 1
        SetMeasureImage 0, MYUNIT&, (5 + COUNT&)
        MeasureProc SEARCHUNIT&
        JUDGE&(COUNT&) = UnitJudge(SEARCHUNIT&)
        GetUnitData SEARCHUNIT&, "X", POSX#(COUNT&)
        GetUnitData SEARCHUNIT&, "Y", POSY#(COUNT&)
        Next
    EndIf

 Return

*MEASUREDISPT

    '(5)
    If MEASURENUM& = 3 Then
        For COUNT& = 0 To 2 Step 1
        If JUDGE&(COUNT&) = JUDGE_OK Then
        DrawText "Count :" + Str$(COUNT&) + " Judge : OK" , 1, 1
        Else
        DrawText "Count :" + Str$(COUNT&) + " Judge : NG" , 1, 1
        EndIf
        DrawText "Position X : " + Str$(POSX#(COUNT&)), 1, 1
        DrawText "Position Y : " + Str$(POSY#(COUNT&)), 1, 1
        Next
    EndIf
Return

The macro program is in refthis link.
Explanation
(1)Initialize parameters(ex.Unit No. of Search) when initialize measurement.
(2)If the count of measurement trigger is over three times, reset it to 0.
(3)Save the measurement image to images of [Macro] (save to image No.5 to 7).
(4)In third measurement trigger, execute [Search] to all images of [Macro], get the judgement results and measurement results.
(5)In third measurement trigger, display the judgement results and measurement results in Text Window.