我想知道使用 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) 我有一个带有事件“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 方法对我不起作用。
关于如何从按钮触发绘画事件的任何其他建议?