当前位置:网站首页>labelme-5.0.1版本编辑多边形闪退

labelme-5.0.1版本编辑多边形闪退

2022-08-10 20:55:00 不爱打代码的程序员

    def _get_rgb_by_label(self, label):
        if self._config["shape_color"] == "auto":
            items = self.uniqLabelList.findItemsByLabel(label)
            if items:
                item = items[0]
            else:
                return (0, 255, 0)
            label_id = self.uniqLabelList.indexFromItem(item).row() + 1
            label_id += self._config["shift_auto_shape_color"]
            return LABEL_COLORMAP[label_id % len(LABEL_COLORMAP)]
        elif (
                self._config["shape_color"] == "manual"
                and self._config["label_colors"]
                and label in self._config["label_colors"]
        ):
            return self._config["label_colors"][label]
        elif self._config["default_shape_color"]:
            return self._config["default_shape_color"]
        return (0, 255, 0)

debug发现找标签时超出索引,解决方案:找不到item就直接返回(0, 255, 0),将该方法改为以上的代码就行

原网站

版权声明
本文为[不爱打代码的程序员]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_40109570/article/details/126260834