如何使用鼠标在视频流上未填充的框上绘制 [英] How to draw on an unfilled box on a video stream using the mouse

查看:76
本文介绍了如何使用鼠标在视频流上未填充的框上绘制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用dshownet(第一次)和C#.我有一个样本来获取网络摄像头输入并将其显示在表单上.现在,我需要使用鼠标在视频流顶部绘制一个矩形. (目的是从此跟踪盒子中的内容.)

我听说有一个叫做VMR的东西.因此,我去了dshownet示例并进行了研究.我没有找到任何使用鼠标在视频流上覆盖形状的示例.建议此处的某人使用colorkey.另一个人说使用GDI +和鼠标处理.我尝试编译DXLogo示例,但收到此错误:
__________________________________________________________________________

错误1无法创建抽象类或接口``System.Drawing.Image''C:\ Documents and Settings \ TLNA \ Desktop \ Final Year Project \ Libraries \ DirectShow库2 \ DirectShowSamples-2010-February \ Samples \的实例Capture \ DxLogo \ Capture.cs 128 32 DxLogo-2008

__________________________________________________________________________

对于代码部分:
__________________________________________________________________________

如果(fileName.Length> 0)
{
m_Bitmap = new Image(文件名); //错误发生在这里

矩形r =新矩形(0,0,m_Bitmap.Width,m_Bitmap.Height);
m_bmdLogo = m_Bitmap.LockBits(r,ImageLockMode.ReadOnly,PixelFormat.Format24bppRgb);
}

__________________________________________________________________________

我知道我必须通过IMVRMixerBitmap9接口.但是我真的不知道从哪里开始.我应该阅读Directshow API文档.

顺便说一句,我还有《数字视频和电视编程Microsoft Directshow编程》一书.我开始读那本书,并在几页后停了下来,因为代码主要是C ++.我应该继续阅读这本书吗?如何完成C#中提到的某些任务?

有关如何在视频上绘画的任何建议.一些有用的链接(教程)会很有帮助.

非常感谢
Tlna

Hi,

I am using dshownet(first time) and C#. I have got a sample to take the web cam input and display it on a form. I now need to draw a rectangle on top of the video stream using the mouse. (the intent is to track what is inside the box from there onwards).

I heard that there is something called VMR. So I went to the dshownet samples and went through them. I didnt find any samples that use the mouse to overlay a shape on the video stream. Someone on here suggested to use colorkey. Another person said to use GDI+ and mouse handling. I tried to compile the DXLogo sample but got this error :
__________________________________________________________________________

Error 1 Cannot create an instance of the abstract class or interface ''System.Drawing.Image'' C:\Documents and Settings\TLNA\Desktop\Final Year Project\Libraries\DirectShow library 2\DirectShowSamples-2010-February\Samples\Capture\DxLogo\Capture.cs 128 32 DxLogo-2008

__________________________________________________________________________

for the code section:
__________________________________________________________________________

if (fileName.Length > 0)
{
m_Bitmap = new Image(fileName); // error happened here

Rectangle r = new Rectangle(0, 0, m_Bitmap.Width, m_Bitmap.Height);
m_bmdLogo = m_Bitmap.LockBits(r, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
}

__________________________________________________________________________

I know that I must go through the IMVRMixerBitmap9 Interface. But I really dont know where to start. Should I read the Directshow API docs.

btw I also have the book Programming Microsoft Directshow for digital video and television. I started reading that book and stopped after a few pages since the code is mainly in C++. Should I continue to read this is book ? How can I accomplish the certain mentioned tasks in C# ?

Any suggestions as how to draw on the video. Some useful links(tutorials) would be helpful.

Many Thanks
Tlna

推荐答案

您将要使用Image.FromFile(filename)克服所看到的错误(图像是抽象的,您无法像这样初始化它).

另一种方法是创建一个实现Image的类的实例,例如Bitmap.如果m_Bitmap是图像类型,则可以执行m_Bitmap = new Bitmap(filename).

您提到的书是一本更好的书,它将帮助您了解您提到的该库中发生的事情. 本文 [
希望这会有所帮助.

干杯.
You will want to use Image.FromFile(filename) to get past the error you''re seeing (Image is abstract and you can''t initialize it like that).

The alternative would be to create an instance of a class that implements Image, such as Bitmap. If m_Bitmap is of type image you can do m_Bitmap = new Bitmap(filename).

The book you mention is a gooder and will help you understand what''s going on in that library you mentioned. This article[^] will also help a bit and there are some good links at the bottom.

My strong suspicion is that you''re going to be either working with a filter in the graph or finding a .Net library someone''s crafted for DirectShow that has a "frame ready" event of some sort...this would allow you to draw on the frame prior to displaying it.

Hope this helps.

Cheers.


这篇关于如何使用鼠标在视频流上未填充的框上绘制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆