handpose_evaluation.py 文件源码

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

项目:semi-auto-anno 作者: moberweger 项目源码 文件源码
def plotFramesWithinMax(self, basename, methodName='Our method', baseline=None):
        """
        plot and save plot for fraction of frames within max distance
        :param basename: file basename
        :param methodName: our method name
        :param baseline: list of baselines as tuple (Name,evaluation object)
        :return: None
        """

        if baseline is not None:
            for bs in baseline:
                if not (isinstance(bs[1], self.__class__)):
                    raise TypeError('baseline must be of type {} but {} provided'.format(self.__class__.__name__,
                                                                                         bs[1].__class__.__name__))

        import matplotlib.pyplot as plt

        fig = plt.figure()
        ax = fig.add_subplot(111)
        ax.plot([self.getNumFramesWithinMaxDist(j) / float(self.joints.shape[0]) * 100. for j in
                 range(0, self.plotMaxJointDist)], label=methodName, c=self.colors[0], linestyle=self.linestyles[0],
                linewidth=self.linewidth)
        bs_idx = 1
        if baseline is not None:
            for bs in baseline:
                ax.plot([bs[1].getNumFramesWithinMaxDist(j) / float(self.joints.shape[0]) * 100. for j in
                         range(0, self.plotMaxJointDist)], label=bs[0], c=self.colors[bs_idx % len(self.colors)],
                        linestyle=self.linestyles[bs_idx % len(self.linestyles)], linewidth=self.linewidth)
                bs_idx += 1
        plt.xlabel('Distance threshold / mm')
        plt.ylabel('Fraction of frames within distance / %')
        plt.ylim([0.0, 100.0])
        ax.grid(True)
        if self.dolegend:
            # Put a legend below current axis
            handles, labels = ax.get_legend_handles_labels()
            # lgd = ax.legend(handles, labels, loc='lower right', ncol=1) #, bbox_to_anchor=(0.5,-0.1)
            lgd = ax.legend(handles, labels, loc='upper center', bbox_to_anchor=(0.5, -0.1), ncol=3)  # ncol=2, prop={'size': 14})
            bbea = (lgd,)
        else:
            bbea = None
        plt.show(block=False)
        fig.savefig('{}/{}_frameswithin.pdf'.format(self.subfolder, basename), bbox_extra_artists=bbea,
                    bbox_inches='tight')
        plt.close(fig)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号