我有一个带有点的二进制图像,我使用OpenCV的goodFeaturesToTrack获取,如Image1所示。如何适合随机点云上的点网格
我想适应的4个* 25点就可以了,比如网格上镜像2所示(并非所有的点都可见的图像,但它是一个普通的4个* 25点长方形)。
4×25点我的模型网格由参数化: 1 - 左上角的位置 2 - 与地平线 矩形的倾斜下面的代码显示一个函数,它建立这样的模型。
这个问题似乎接近棋盘角落的问题。
我想知道如何将我的模型云点拟合到输入图像,并获得云的位置和角度。 我可以很容易地测量两幅图像(输入图像和模型网格上的图像)之间的距离,但是我希望避免检查图像上的每个像素和角度以找出距离的最小值。
def ModelGrid(pos, angle, shape):
# Initialization of output image of size shape
table = np.zeros(shape)
# Parameters
size_pan = [32, 20]# Pixels
nb_corners= [4, 25]
index = np.ndarray([nb_corners[0], nb_corners[1], 2],dtype=np.dtype('int16'))
angle = angle*np.pi/180
# Creation of the table
for i in range(nb_corners[0]):
for j in range(nb_corners[1]):
index[i,j,0] = pos[0] + j*int(size_pan[1]*np.sin(angle)) + i*int(size_pan[0]*np.cos(angle))
index[i,j,1] = pos[1] + j*int(size_pan[1]*np.cos(angle)) - i*int(size_pan[0]*np.sin(angle))
if 0 < index[i,j,0] < table.shape[0]:
if 0 < index[i,j,1] < table.shape[1]:
table[index[i,j,0], index[i,j,1]] = 1
return table