bflim.py 文件源码

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

项目:3dstools 作者: ObsidianX 项目源码 文件源码
def _rotate_image(self, mat, angle, width, height):
        big = max(width, height)
        small = min(width, height)
        center = (big / 2.0) - (small / 2.0)

        trans = numpy.float32([[1, 0, 0], [0, 1, 0]])
        trans2 = numpy.float32([[1, 0, 0], [0, 1, 0]])

        if small == width:
            trans[0, 2] = center
            trans2[1, 2] = -center - 1
        else:
            trans[1, 2] = center
            trans2[0, 2] = -center - 1

        # first enlarge the image to a square, translating the pixels to the new center
        mat = cv2.warpAffine(mat, trans, (big, big))
        # then rotate on the new center
        rot = cv2.getRotationMatrix2D((big / 2, big / 2), angle, 1)
        mat = cv2.warpAffine(mat, rot, (big, big))
        # finally translate back to the start and resize to the new size
        return cv2.warpAffine(mat, trans2, (height, width))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号