def cam2PlaneVectorField(self, midpointdepth=None, **kwargs):
t, r = self.pose()
shape = self.opts['shape']
cam = self.opts['cameraMatrix']
# move reference point from top left quad corner to
# optical center:
# q0 = self.quad[0]
q0 = self.objCenter()
# dx,dy = cam[0,2]-q0[0], cam[1,2]-q0[1]
dx, dy = shape[1] // 2 - q0[0], shape[0] // 2 - q0[1]
# x,y component of undist plane:
rot0 = np.array([0, 0, 0], dtype=float)
worldCoord = np.fromfunction(lambda x, y:
imgPointToWorldCoord((y - dy, x - dx), rot0, t, cam
), shape).reshape(3, *shape)
# z component from plane-equation solved for z:
n = self.planeSfN(r)
x, y = worldCoord[:2]
zpart = (-n[0] * x - n[1] * y) / (-n[2])
ox, oy = self.objCenter()
v = zpart[int(oy), int(ox)]
if midpointdepth is None:
# TODO: review
midpointdepth = t[2, 0]
zpart += midpointdepth - v
worldCoord[2] = zpart
return worldCoord
# BEFORE REMOVING THINGS: MAKE EXTRA FN
评论列表
文章目录