【发布时间】:2019-03-12 03:45:35
【问题描述】:
以下代码用于在给定位置 x y 坐标和变量“locs”.tp=256,r=180,c=240 的情况下查找图像的关键点。在调试期间,我收到 desc[idx-1, ] = tmp 行的索引错误。
tp = compareX.shape[0]
desc = np.zeros((1, tp))
r = im.shape[0]
c = im.shape[1]
idx = 1
new_locs = np.zeros((locs.shape))
for i in range(1, locs.shape[0]):
x = math.floor(locs[i - 1, 0]) # keypoint x coordinate
y = math.floor(locs[i - 1, 1]) # keypoint y coordinate
#non-maximum suppression
if (x - 4) < 1 or (y - 4) < 1 or (x + 4) > c or (y + 4) > r:
continue
#save passing coordinates
new_locs[idx - 1,] = np.array([x, y])
#Calculate BRIEF descriptor
tmp = np.zeros((1, tp))
x = x-4
y = y-4
for j in range(1, tp):
ax = x + math.floor((compareX[j-1]-1)/patchWidth)
ay = y + ((compareX[j-1]-1) % patchWidth)
bx = x + math.floor((compareY[j-1] - 1) / patchWidth)
by = y + ((compareY[j-1] - 1) % patchWidth)
if (im[ay, ax] < im[by, bx]).all():
tmp[0, j-1] = 1
***desc[idx-1, ] = tmp***
idx = idx + 1
locs = new_locs
return locs, desc
【问题讨论】:
标签: python python-3.x python-2.7 numpy