如何在一维测量阵列上检测图案

问题描述 投票:1回答:1

我正在为需要跟随一条直线的机器人开发IA算法。地板将是黑色的,上面有一条白线,并且会有不同的标记来确定不同类型的“障碍物”。我正在使用一个传感器,该传感器为我提供了地板的8个测量值的阵列,如图1上所示,该传感器为我提供了从0到1000的8个测量值的阵列,其中0没有白,而1000是全白。在下面的示例中,测量的是传感器阵列中间的白线以及其他情况。

int array[] = {50, 24, 9, 960, 1000, 150, 50, 45} // white line in the middle
int array2[] = {50, 24, 9, 960, 1000, 150, 50, 960} // white line in the middle and a square box on the right
int array3[] = {1000, 24, 9, 960, 1000, 150, 50, 40} // white line in the middle and a square box on the left
int array4[] = {1000, 980, 950, 0, 10, 980, 1000, 960} // black square box in the middle

给定这种测量阵列,我可以用巫婆算法检测下面图像上的图案吗?我不想使用几个“硬编码”条件作为模板,因为我认为它不能很好地扩展。我正在考虑实现“峰值计数器”算法,但我不知道它是否会足够健壮。

在图中我们可以看到不同的情况,我要检测的情况是带有红色圆圈的情况。

谢谢!

Sensors arrangementBlack square

LeftRight

arrays algorithm sensor
1个回答
1
投票

如何做一些简单的事情,例如将每个度量都视为N维向量。您的情况N = 8。然后,所有测量都包含在hypercube中,其边长最大为1000。对于N = 8,将有256个角。对于您感兴趣的每种情况,请关联最适合它的超立方体角。请注意,某些角可能不会关联。然后,对于每个测量,找到其最近的关联超立方体角。这告诉您是哪种情况。您可以通过执行一些检查来减少错误。例如,如果度量接近多个角(在某个不确定性阈值内),则将度量标注为模棱两可,然后跳过它。

对于3次测量的情况更容易看到这一点。立方体的8个角可以代表

[0,0,0] = no white
[0,0,1] = white on right
[0,1,0] = white in middle
[0,1,1] = white in middle and right
[1,0,0] = white on left
[1,0,1] = white on left and right
[1,1,0] = white on left and middle
[1,1,1] = all white

下面显示的情况是中间的一个不明确的度量。

cube(来源:ctralie.com

© www.soinside.com 2019 - 2024. All rights reserved.