NumberToFind属性

适用
视觉对象:ArcInspector, Blob, CodeReader, Contour, Correlation, DefectFinder, Edge, Geometric, LineInspector

说明
定义单个搜索窗口内要搜索的要素数量。

用法

VGet  Sequence.Object.NumberToFind, var
VSet  Sequence.Object.NumberToFind, value
Sequence
序列名或表示序列名的字符串变量
Object
对象名或表示对象名的字符串变量对象必须存在于指定的序列中。
var
表示属性值的整数变量
value
表示新属性值的整数或表达式


有效输入值为0(All)至各对象可检测出的最大数量(请参阅详细说明)。

默认:

  • 0 All(Contour对象),
  • 1(其他对象)

详细说明
ArcInspector、Blob、Correlation、DefectFinder、Edge、Geometric和LineInspector对象支持在单个搜索窗口内发现多个要素。NumberToFind属性定义数量。

由于许多应用仅需要在搜索窗口发现1个要素,因此除了Contour对象之外,NumberToFind属性的默认值设为1。

在Vision Guide开发环境中工作时,可以注意到Object窗口的结果列表中将显示“Result(1/15)”等标题。这意味着系统尝试查找15个要素(如NumberToFind属性中定义),结果列表中将显示项目1的结果。

如果要查看其他结果中的一项结果,只需更改CurrentResult属性值指示要检查的结果。

Blob结果根据SizeToFind和Sort属性排序。

如果NumberToFind设为“0 - All”,则会发现最多为最大检测数的所有可能的结果。各对象的最大检测数不同,如下所示。

对象名 最大检测数
CodeReader 8
Contour 1000
Blob, Edge 4000
其他 100

Sort为“None”时,Correlation和Geometric结果按最高Score结果至最低Score结果的顺序排序。(即结果记录1(CurrentResult = 1)为具有最高分值的要素结果。)

参照
ArcInspector对象、Blob对象、Contour对象、Correlation对象、CurrentResult属性、DefectFinder对象、Edge对象、Found结果、Geometric对象、LineInspector对象、NumberFound结果


以下SPEL+语言示例运行包含名为Corr01的Correlation对象、称为mtest的视觉序列。Corr01的NumberToFind值使用VSet设定。

以下程序运行该序列并确认Corr01发现正确数量(3)的要素,然后按降序打印Score结果。

Function main

  # define NUM_TO_FIND 3
	
  Boolean numfound
  Integer score

  VSet mtest.Corr01.NumberToFind, NUM_TO_FIND
  VRun mtest
  VGet mtest.Corr01.NumberFound, numfound
  If numfound = NUM_TO_FIND Then
    Print "The Proper Number of features(3) were found"
  Else
    Print "Only (", numfound, ") features were found"
    Exit Function
  EndIf
  VGet mtest.Corr01.Score(1), score
  Print "1st feature score (Best):   ", score

  VGet mtest.Corr01.Score(2), score
  Print "2nd feature score (Medium): ", score

  VGet mtest.Corr01.Score(3), score
  Print "3rd feature score (Worst):  ", score
Fend