handpose_evaluation.py 文件源码

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

项目:semi-auto-anno 作者: moberweger 项目源码 文件源码
def saveVideoFrames(self, filename, images):
        """
        Create a video with synthesized images
        :param filename: name of file to save
        :param images: video data
        :return: None
        """

        txt = 'Saving {}'.format(filename)
        pbar = pb.ProgressBar(maxval=images.shape[0], widgets=[txt, pb.Percentage(), pb.Bar()])
        pbar.start()

        height = width = 128

        # Define the codec and create VideoWriter object
        fourcc = cv2.cv.CV_FOURCC(*'DIVX')
        video = cv2.VideoWriter('{}/synth_{}.avi'.format(self.subfolder, filename), fourcc, self.fps, (height, width))
        if not video:
            raise EnvironmentError("Error in creating video writer")

        for i in range(images.shape[0]):
            img = images[i]
            img = cv2.normalize(img, alpha=0, beta=255, norm_type=cv2.cv.CV_MINMAX, dtype=cv2.cv.CV_8UC1)
            img = cv2.cvtColor(img, cv2.cv.CV_GRAY2BGR)
            img = cv2.resize(img, (height, width))
            # write frame
            video.write(img)
            pbar.update(i)

        video.release()
        del video
        cv2.destroyAllWindows()

        pbar.finish()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号