Execute multiple camera image input and measurement at one measurement trigger

Overview

This sample executes multiple camera image input and measurement and displays the average values of the measurement results at one measurement trigger.

Specification of this example


Behavior
This sample executes [Camera Image Input] and [Ec Circle Search] three times at one measurement trigger and displays the average values of the measurement results.

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 executes [Camera Image Input] and [Ec Circle Search] three times at one measurement trigger and displays the measurement results and the average values of them in Image Window.
Note
In this sample, when remeasuring the same image (same file), the measurement result is same.
When measuring with camera images, the measurement results are differ.

How to implement

Scene data
Unit No.
Processing Item
0.
Camera Image Input
1.
Ec Circle Search
2.
Macro
The Macro Program below segment is to be set in '2.Macro'.
Macro Program
*MCRINIT
    'Initialize                                                  '(1)
    CAMERAUNITNO& = 0
    ECCIRCLESEARCHUNITNO& = 1
    MAXCOUNT& = 3
    FONTSIZE& = 20

    Dim POSITIONX#(MAXCOUNT&), POSITIONY#(MAXCOUNT&), CORRELATION#(MAXCOUNT&) 

Return

*MEASUREPROC

    GetUnitData ECCIRCLESEARCHUNITNO&, "X", POSITIONX#(0)       '(2)
    GetUnitData ECCIRCLESEARCHUNITNO&, "Y", POSITIONY#(0)
    GetUnitData ECCIRCLESEARCHUNITNO&, "CR", CORRELATION#(0)
    POSITIONX#(MAXCOUNT&) = POSITIONX#(MAXCOUNT&) + POSITIONX#(0)
    POSITIONY#(MAXCOUNT&) = POSITIONY#(MAXCOUNT&) + POSITIONY#(0)
    CORRELATION#(MAXCOUNT&) = CORRELATION#(MAXCOUNT&) + CORRELATION#(0)

    For CNT& = 1 To (MAXCOUNT& - 1) Step 1
        MeasureProc CAMERAUNITNO&
        MeasureProc ECCIRCLESEARCHUNITNO&

        GetUnitData ECCIRCLESEARCHUNITNO&, "X", POSITIONX#(CNT&)
        GetUnitData ECCIRCLESEARCHUNITNO&, "Y", POSITIONY#(CNT&)
        GetUnitData ECCIRCLESEARCHUNITNO&, "CR", CORRELATION#(CNT&)
        POSITIONX#(MAXCOUNT&) = POSITIONX#(MAXCOUNT&) + POSITIONX#(CNT&)
        POSITIONY#(MAXCOUNT&) = POSITIONY#(MAXCOUNT&) + POSITIONY#(CNT&)
        CORRELATION#(MAXCOUNT&) = CORRELATION#(MAXCOUNT&) + CORRELATION#(CNT&)
    Next

    POSITIONX#(MAXCOUNT&) = POSITIONX#(MAXCOUNT&) / MAXCOUNT&  '(3)
    POSITIONY#(MAXCOUNT&) = POSITIONY#(MAXCOUNT&) / MAXCOUNT&
    CORRELATION#(MAXCOUNT&) = CORRELATION#(MAXCOUNT&) / MAXCOUNT&

Return

*MEASUREDISPG
    SetTextStyle FONTSIZE&, TA_TOP, JUDGE_OK, 0, FONTSTYLE_BOLD + FONTSTYLE_UNDERLINE

    For CNT& = 0 To (MAXCOUNT& - 1) Step 1         '(4)
        DrawTextG "No." + Str$(CNT& + 1) + ", Correlation : " + Str$(CORRELATION#(CNT&)) + ", Position X : " + Str$(POSITIONX#(CNT&)) + ", Position Y : " + Str$(POSITIONY#(CNT&)), 10, (CNT& +1) * 20, 0
    Next
    DrawTextG "Average, Correlation : " + Str2$(CORRELATION#(MAXCOUNT&), 3, 1, 0, 0) + ", Position X : " + Str2$(POSITIONX#(MAXCOUNT&), 5, 4, 0, 0) + ", Position Y : " + Str2$(POSITIONY#(MAXCOUNT&), 5, 4, 0, 0), 10, (MAXCOUNT& +1) * 20, 0

Return

The macro program is in refthis link.
Explanation
(1)Initialize parameters(ex.Unit No. of [Ec Circle Search] ) when initialize measurement.
(2)Execute [Camera Image Input] and [Ec Circle Search] three times and get the measurement results of [Ec Circle Search].
(3)Calculate the average values of the measurement results.
(4)Display the measurement results and the average values in Image Window.