我有一张图像,我需要尽可能快地检测到一个物体。我也知道我只需要检测离中心最近的物体。
AFAIK Opencv 的 MatchTemplate 有点像这样(伪代码):
for(x in width):
for(y in height):
value = calcSimilarity(inputImage, searchedImage, x, y)
matched[x][y] = value
之后,我必须遍历生成的图像并找到离中心最近的点,这都是相当浪费的。
所以我想知道我是否可以做类似的事情:
coordsGen = new CoordsGen() // a class that generates specific coords for me
while(!coordsGen.stop):
x, y = coordsGen.next()
value = calcSimilarity(inputImage, searchedImage, x, y)
if(value > treshold)
return x, y
基本上我在这里需要的是 calcSimilarity 函数。这将使我能够大大优化流程。