Count the number of mesurement results OK/NG and display it in Image Window
Overview
Calculate OK, NG and total measurement counts, and percentage of OK and NG products.
And display them in Image Window.
Specification of this example
Behavior
At the end of measurement, calculate the number of OK/NG/Total and the percentage of OK/NG which is the judgement result of specified processing unit ([1.Search]).
And display them in Image Window.
Screenshot
How to try this example
1.Click the link below, then the folder containing zip file automatically opens.
File
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 displays the number of OK/NG/Total and the percentage of OK/NG which is the judgement result of specified processing unit (this sample is [Search]) in Image Window.
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
'Initialize '(1)
FONTSIZE& = 24
HEIGHT& = 24
LEFT& = 10
Return
*MEASUREPROC
MYUNIT& = UnitNo
RECGJDG& = UnitData(MYUNIT& - 1, "JG") '(2)
'(3)
If RECGJDG& = JUDGE_NG Then
CNT_NG& = CNT_NG& + 1
Elseif RECGJDG& = JUDGE_OK Then
CNT_OK& = CNT_OK& + 1
EndIf
CNT_TOT& = CNT_NG& + CNT_OK&
'(4)
If CNT_TOT& <> 0 Then
RATE_OK# = CNT_OK& / CNT_TOT& * 100
RATE_NG# = CNT_NG& / CNT_TOT& * 100
Else
RATE_OK# = 0
RATE_NG# = 0
EndIf
Return
*MEASUREDISPG
SetTextStyle 24, TA_TOP, JUDGE_OK, 0, FONTSTYLE_BOLD + FONTSTYLE_UNDERLINE '(5)
DrawTextG "Total :" + Str2$(CNT_TOT&,5,0,0,0), LEFT&, HEIGHT& * 1, 0
DrawTextG " OK :" + Str2$(CNT_OK&,5,0,0,0), LEFT&, HEIGHT& * 2, 0
DrawTextG " NG :" + Str2$(CNT_NG&,5,0,0,0), LEFT&, HEIGHT& * 3, 0
DrawTextG "Rate(percent)", LEFT&, HEIGHT& * 4, 0
DrawTextG " OK :" + Str2$(RATE_OK#,5,4,0,0), LEFT&, HEIGHT& * 5, 0
DrawTextG " NG :" + Str2$(RATE_NG#,5,4,0,0), LEFT&, HEIGHT& * 6, 0
Return
The macro program is in
this link.
Explanation
(1)Initialize parameters(ex.font size of message) when initialize measurement.
(2)Get measurement results of forward unit via external reference data.
(3)Count the number of OK/NG/Total.
(4)Calculate the percentage of OK/NG.
(5)Display it in Image Window.