Traindataset.py 文件源码

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

项目:convolutional-pose-machines-chainer 作者: tomoyukun 项目源码 文件源码
def rotate_image(self, image, joint_x, joint_y, bbox):
        joints = np.transpose(np.array((joint_x, joint_y), dtype=(np.float32)), (1,0))
        angle = np.random.randint(-self.rotate_range, self.rotate_range)
        theta = -np.radians(angle)
        image = transform.rotate(image, angle, center = (bbox[0], bbox[1]))
        c, s = np.cos(theta), np.sin(theta)
        rot_mat = np.array([[c, -s], [s, c]])
        joints = rot_mat.dot((joints - [bbox[0], bbox[1]]).T).T + [bbox[0], bbox[1]]
        joint_x = joints[:,0]
        joint_y = joints[:,1]
        bbox[2:4] = [(max(joint_x) - min(joint_x)) * 1.2,
                     (max(joint_y) - min(joint_y)) * 1.2]
        return image, joint_x, joint_y, bbox
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号