PerspectiveCorrection.py 文件源码

python
阅读 40 收藏 0 点赞 0 评论 0

项目:imgProcessor 作者: radjkarl 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号