Display the measurement result graphically

Overview

This example displays the measurement result graphically.

Specification of this example


Behavior
This example compares the measurement result with answer positions.
When the distance is under the threshold, display a green circle on the position of the measurement result.
When the distance is over the threshold, display a red circle on the position of the measurement result.

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 compares the measurement result with answer positions.
When the distance is under the threshold, System displays a green circle on the position of the measurement result.
When the distance is over the threshold, System displays a red circle on the position of the measurement result.

How to implement

Scene data
Unit No.
Processing Item
0.
Camera Image Input
1.
Search
2.
Macro
The Macro Program below segment is to be set in '2.Macro'.
Macro Program
*MCRINIT

    UNITNO& = 1        '(1)
    LIMIT# = 4
    CIRCLEWIDTH& = 10

    Dim ANSWERX#(14), ANSWERY#(14)
    ANSWERX#(0) = 168.5         '(2)
    ANSWERX#(1) = 191.5
    ANSWERX#(2) = 212.5
    ANSWERX#(3) = 235.5
    ANSWERX#(4) = 257.5
    ANSWERX#(5) = 279.7
    ANSWERX#(6) = 301.5
    ANSWERX#(7) = 323.8
    ANSWERX#(8) = 342.9
    ANSWERX#(9) = 367.6
    ANSWERX#(10) = 389.5
    ANSWERX#(11) = 416.6
    ANSWERX#(12) = 433.4
    ANSWERX#(13) = 456.2
    ANSWERX#(14) = 476.5

    ANSWERY#(0) = 211
    ANSWERY#(1) = 254.7
    ANSWERY#(2) = 211
    ANSWERY#(3) = 253.5
    ANSWERY#(4) = 211
    ANSWERY#(5) = 253
    ANSWERY#(6) = 210
    ANSWERY#(7) = 250.1
    ANSWERY#(8) = 212.9
    ANSWERY#(9) = 251.7
    ANSWERY#(10) = 210
    ANSWERY#(11) = 251.4
    ANSWERY#(12) = 211.5
    ANSWERY#(13) = 246.4
    ANSWERY#(14) = 210.9

    Dim RESULT&(14)

Return

*MEASUREPROC
   SETCOUNT& = 0

   GetUnitData UNITNO&, 14, WORKNUM&     '(3)

   If WORKNUM& > 0 Then

       For CNT& = 0 To 14 Step 1
        RESULT&(CNT&) = JUDGE_NG
        For CNT2& = SETCOUNT& To (WORKNUM& - 1) Step 1
        GetUnitData UNITNO&, 1001 + (CNT2& * 4), POSX#     '(4)
        GetUnitData UNITNO&, 1002 + (CNT2& * 4), POSY#
        DISTANCE# = (POSX# - ANSWERX#(CNT&)) * (POSX# - ANSWERX#(CNT&)) + (POSY# - ANSWERY#(CNT&)) * (POSY# - ANSWERY#(CNT&)) '(5)

        If DISTANCE# < LIMIT# Then
        RESULT&(CNT&) = JUDGE_OK     '(6)
        SETCOUNT& = SETCOUNT& + 1
        Exit For
        EndIf
        Next
       Next
   EndIf

Return

*MEASUREDISPG

    For CNT& = 0 To 14 Step 1
        SetDrawStyle PS_SOLID, 3, RESULT&(CNT&)    '(7)
        DrawCircle ANSWERX#(CNT&), ANSWERY#(CNT&), CIRCLEWIDTH&, 0
    Next

Return

The macro program is in refthis link.
Explanation
(1)Initialize parameters(ex.Unit No. of [Search]) when initialize measurement.
(2)Set the answer positions of [Search].
(3)Get Count of [Search].
(4)Get the position X, and Y of [Search].
(5)Calculate the distance between answer position and measurement result.
(6)When the distance is under the threshold, the position is detected.
(7)Display circle on the answer positions. Green circles are displayed on the detected positions, and red circles are displayed in the non-detected positions.