小编pay*_*yam的帖子

如何使用 OpenCV python 为线条添加透明度?

我可以用 OpenCV Python 画一条线,但无法使线透明

def draw_from_pitch_to_image(image, reverse_output_points):
    for i in range(0, len(reverse_output_points), 2):
       x1, y1 = reverse_output_points[i]
       x2, y2 = reverse_output_points[i + 1]

       x1 = int(x1)
       y1 = int(y1)
       x2 = int(x2)
       y2 = int(y2)

       color = [255, 0, 0] if i < 1 else [0, 0, 255]
       cv2.line(image, (x1, y1), (x2, y2), color, 2)
Run Code Online (Sandbox Code Playgroud)

我更改了代码,但该行仍然不透明。我不知道为什么,有人可以帮我解决这个问题吗?

  def draw_from_pitch_to_image(image, reverse_output_points):
      for i in range(0, len(reverse_output_points), 2):
       x1, y1 = reverse_output_points[i]
       x2, y2 = reverse_output_points[i + 1]

       alpha = 0.4  # Transparency …
Run Code Online (Sandbox Code Playgroud)

python drawing opencv image image-processing

6
推荐指数
1
解决办法
8339
查看次数

无法在列表中添加元素(在 C# 中)

下面的代码我想将鼠标单击的坐标添加到列表中(我想在图片框中的不同位置单击 4 次)并且我想将鼠标单击的坐标存储在列表中

但此功能仅存储列表中的最后一个坐标(新坐标替换为最后一个坐标,并且不能添加到列表末尾)。我的列表始终只有一个元素(在列表中单击 4 次需要有 4 个坐标)(每次单击后,我在 textbox3 中都有新坐标,并且我在列表中也使用了列表 < Point > ,结果相同)感谢您的帮助

    private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
    {
        List<String> myPoints = new List<String>();
        textBox3.Text = e.X + " , " + e.Y;
        myPoints.Add(textBox3.Text);
     
    }
Run Code Online (Sandbox Code Playgroud)

c#

3
推荐指数
1
解决办法
460
查看次数

标签 统计

c# ×1

drawing ×1

image ×1

image-processing ×1

opencv ×1

python ×1