小编Max*_*nge的帖子

在 OpenCV 中使用 cv2.VideoCapture.read() 方法捕获什么数据类型?

我想知道使用 cv2.VideoCapture.read() 方法捕获什么样的数据类型。我一直在阅读 OpenCV 文档,我找到了这个解释:

在此处输入图片说明

我遵循了一些 OpenCV 的基本教程,其中网络摄像头可以捕获数据并输出帧。下图显示了帧数据。

在此处输入图片说明

下面是输出这些帧的代码:

import cv2, time, base64

framesCaptured = 0;
video=cv2.VideoCapture(0) <====== Video capture for the webcam

# Save camera frames as movie
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('recording.avi', fourcc, 20.0, (640, 480))

while True:
    framesCaptured += 1

    check, frame = video.read() <====== Grabs and retrieves frames and decode
    # Write video frames
    out.write(frame)

    # Print out statements
    #print(check)
    print(frame) <====== Print out frame data (as shown in the cmd picture below)

    gray=cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) …
Run Code Online (Sandbox Code Playgroud)

python opencv types cv2

5
推荐指数
1
解决办法
7443
查看次数

如何从按钮单击事件调用绘制事件?

我有一个带有事件“paint”的图片框,我还在那里获得了用于绘制图形的代码。

如:

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void pictureBox1_Paint(object sender, PaintEventArgs e)
    {
        Graphics graphics = e.Graphics;
        graphics.DrawEllipse(Pens.Blue, 10, 10, 100, 100);
    }

    private void button1_Click(object sender, EventArgs e)
    {
        pictureBox1.Invalidate();
    }
}
Run Code Online (Sandbox Code Playgroud)

}

我的问题是。如何从 button_click 事件触发这些事件?我在网上搜索了很多,发现了很多 awnsers,如“.invalidate()”或“.Refresh()”和“.Update”。但是我的作业告诉我,我需要使用 .Refresh() 方法来完成,并且绘画需要在一个pictureBox 中。

我从 .Refresh() 方法中注意到的。是它擦除了图片框(绘制图片框是如何在初始化时创建的)。所以在按钮中触发 .Refresh 方法对我不起作用。

关于如何从按钮触发绘画事件的任何其他建议?

c# paint winforms

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

标签 统计

c# ×1

cv2 ×1

opencv ×1

paint ×1

python ×1

types ×1

winforms ×1