从流视频中获取快照(新手)
我有一个使用 Emgu(OpenCV 的 .net 包装器)编写的视频播放器,我捕获帧并对某些帧执行一些操作。在功能中,我让用户拍摄流视频的快照,并以不同的形式突出显示快照的部分。
但是,由于视频播放器在下面播放,因此当用户在表单上绘图时,子表单上的图像也会更新。这是不希望的。我很确定这与我的锁定和解锁内容有关,而我是这方面的新手。
有什么想法我哪里出错了吗?我本以为锁定(bmpFrame)会阻止任何更新,但事实并非如此:
private void btnTag_Click(object sender, EventArgs e)
{
if (_video != null && _video.CurrentFrame != null)
{
try
{
using (Bitmap bmpFrame = (Bitmap)_video.CurrentFrame.Bitmap)
{
lock (bmpFrame)
{
TagForm f = new TagForm(bmpFrame);
f.Show();
}
}
}
catch { };
}
}
I have a video player written using Emgu (a .net wrapper for OpenCV) and I am capture the frames and performing some operations on certan frames. In on functionality, I let the user take a snapshot of a streaming video and highlight sections of the snapshot in a different form.
However, since the video player is playing underneath the image on the child form is also updated as the user draws on the form. This is undesirable. I am pretty sure this has something to do with my locking and unlocking stuff and I am a newbie to this stuff.
Any ideas where I am going wrong? I would have thought the lock (bmpFrame) would have prevented any updates, but it doesn't:
private void btnTag_Click(object sender, EventArgs e)
{
if (_video != null && _video.CurrentFrame != null)
{
try
{
using (Bitmap bmpFrame = (Bitmap)_video.CurrentFrame.Bitmap)
{
lock (bmpFrame)
{
TagForm f = new TagForm(bmpFrame);
f.Show();
}
}
}
catch { };
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
啊啊!我傻了,这确实是一个疏忽。通过为新位图分配新内存来修复
ahhh! silly me, it was indeed a oversight. Fixed by allocating new memory for the new bitmap