read_data.py 文件源码

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

项目:pose_estimation 作者: JakeRenn 项目源码 文件源码
def _batch_random_roate(self, images, labels, degree):
        if(images.shape[0] != labels.shape[0]):
            raise Exception("Batch size Error.")
        degree = degree * math.pi / 180
        rand_degree = np.random.uniform(-degree, degree)

        o_images = np.zeros_like(images)
        o_labels = np.zeros_like(labels)
        for idx in xrange(images.shape[0]):
            theta = rand_degree

            # labels
            for ii in xrange(self.points_num):
                o_labels[idx, 2*ii: 2*ii+2] = self._rotate(labels[idx, ii*2: 2*ii+2], theta)

            # image
            M = cv2.getRotationMatrix2D((self.img_width/2,self.img_height/2),-theta*180/math.pi,1)
            o_images[idx] = np.expand_dims(cv2.warpAffine(images[idx],M,(self.img_width,self.img_height)), axis=2)

        return o_images, o_labels
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号