Replies: 1 comment
-
要在 修改步骤:
示例代码修改:在 def paint(self, painter):
if self.selected:
pen = self.SELECTED_PEN
brush = self.SELECTED_BRUSH
else:
pen = self.PEN
brush = None
painter.setPen(pen)
if brush:
painter.setBrush(brush)
if self.shape_type == 'rectangle':
painter.drawRect(self.boundingRect())
elif self.shape_type == 'polygon':
painter.drawPolygon(self.points)
# 其他绘制逻辑... 在上述代码中,矩形框的绘制是通过 修改后,添加填充半透明颜色的逻辑: from PyQt5.QtGui import QColor
def paint(self, painter):
# 设置边框颜色(保持原有逻辑)
if self.selected:
pen = self.SELECTED_PEN
else:
pen = self.PEN
painter.setPen(pen)
# 设置填充半透明颜色
fill_color = QColor(0, 0, 255) # 示例:蓝色填充
fill_color.setAlpha(50) # 半透明效果,范围为 0(完全透明)到 255(不透明)
painter.setBrush(fill_color) # 设置填充颜色
# 绘制矩形框(保持原有逻辑)
if self.shape_type == 'rectangle':
painter.drawRect(self.boundingRect())
elif self.shape_type == 'polygon':
painter.drawPolygon(self.points)
# 其他绘制逻辑... 整体流程:
注意事项:
通过以上修改,启动 PPOCRLabel 时,所有矩形框都会以半透明的颜色进行填充。如有进一步问题,请提供更多上下文代码或报错信息以协助解决! Response generated by feifei-bot | chatgpt-4o-latest |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
PaddleOCR-release-2.6\PPOCRLabel\PPOCRLabel.py 要将所有显示的矩形框,在启动时,都fill半透明的颜色,代码要怎么修改?
PaddleOCR-release-2.6\PPOCRLabel\libs\shape.py改了这个就可以显示了
Beta Was this translation helpful? Give feedback.
All reactions