Click here to Skip to main content
15,889,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

1 solution

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.
 
Share this answer
 
Comments
btap_644 25-Jun-10 13:00pm    
Thks alot more than I can digest I am going to read the whole book first. I will be using dshownet wrapper. The code compiles when I use new Bitmap(Thks).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900