Click here to Skip to main content
15,886,025 members
Articles / Multimedia / DirectX
Article

DirectX Video Stream and frame capture

Rate me:
Please Sign up or sign in to vote.
4.58/5 (42 votes)
12 Jul 20042 min read 655.5K   27.2K   138   115
A library that can capture video stream and frame together

Introduction

There is a tremendous job done by NET master and enhanced by Brian Low. However, I was needed a library that can continuously capture image/bitmap from the video source and record it at the same time. Then I saw the Net master's project and Brian low's project. Well, they have done a great job, but the feature was not included in the project. So I decided to add one. By the way, I saw another project that did the same function, but it was not continuously capturing the frame by triggering event, and the video capture is rather slow, it cannot produce a smooth stream. And the frame per second is rather slow too. However, it was a great effort.

Background

Actually I was just combining the samples together. So, it could be best for you all to refer back to the samples.

Using the code

Just add a button for triggering the event and the GrapImg method. Then, add another handler of the event, which I add is the CaptureDone handler.

The CaptureDone will be fired once a frame was copied from the image buffer. After that, just display the bitmap into a picture box.

C#
private void button1_Click(object sender, System.EventArgs e)
{
    capture.FrameEvent2 += new Capture.HeFrame(CaptureDone);
    capture.GrapImg();
}

private void CaptureDone(System.Drawing.Bitmap e)
{
    this.pictureBox.Image=e;
}

However, for it to work, you will have to know how to use the DirectX capture library at first. because you will have to setup the properties for a video capture to be started, and you will need to start previewing the video before the CaptureDone will be fired.

Points of Interest

Well, one thing is, it took me a lot of time reading through NET master's and Brian Low's code. Any comment, you are welcome..... thanks. Below are two links to the Brian Low's class library and NET Master's DirectShow.NET. (Thanks for the suggestion)

History

None.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Malaysia Malaysia
Please visit my website www.mbwebcreator.com for more web site information.

Comments and Discussions

 
General^.^ Thanks........ Pin
Choon kiat18-Feb-09 16:00
Choon kiat18-Feb-09 16:00 
GeneralCapture several images with GrapImg Pin
6F2120-Jan-09 20:49
6F2120-Jan-09 20:49 
GeneralRe: Capture several images with GrapImg Pin
kumi_aberer@hotmail.com10-Mar-09 12:39
kumi_aberer@hotmail.com10-Mar-09 12:39 
Questioncan not download the source code? Pin
bluewater020928-Nov-08 16:14
bluewater020928-Nov-08 16:14 
QuestionA dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A) Pin
Saravanan.rex21-Nov-08 0:12
Saravanan.rex21-Nov-08 0:12 
AnswerRe: A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A) Pin
donperry12-Feb-09 6:49
donperry12-Feb-09 6:49 
GeneralRe: A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A) Pin
kostiak26-Jul-09 9:30
kostiak26-Jul-09 9:30 
GeneralError HRESULT E_FAIL has been returned from a call to a COM component. Pin
anki12320-Nov-08 1:15
anki12320-Nov-08 1:15 
I m using DirectX.Capture.

First time when I click on capture.start() it works fine.
but next time when click on capture.start() I m getting "Error HRESULT E_FAIL has been returned from a call to a COM component." error

If anyone has any idea, tell me please

Thanks
GeneralStart() causes crash Pin
Member 320461014-Oct-08 8:30
Member 320461014-Oct-08 8:30 
GeneralStill unable to grab an image [modified] Pin
ChiWaiLam17-Sep-08 0:19
ChiWaiLam17-Sep-08 0:19 
QuestionVC++ version of DirectXCapture Pin
Wilson Kopman16-Sep-08 13:39
Wilson Kopman16-Sep-08 13:39 
GeneralColor Control Pin
renoreballos4-Jan-08 4:07
renoreballos4-Jan-08 4:07 
GeneralDetect webcam Pin
Eddiema26-Dec-07 8:31
Eddiema26-Dec-07 8:31 
QuestionDirectShow as Web Applictaion Pin
menaka.ca19-Nov-07 13:33
menaka.ca19-Nov-07 13:33 
QuestionHelp, Code doesn't run (DShowNET could not be found) Pin
smitti12326-Oct-07 4:17
smitti12326-Oct-07 4:17 
Questioncan managed C++ use this DLL? Pin
rayher20-Oct-07 3:47
rayher20-Oct-07 3:47 
GeneralInterlacing in fast motion Pin
brs0264-Aug-07 5:56
brs0264-Aug-07 5:56 
GeneralHelp Pin
NelsonPaz26-Jul-07 13:14
NelsonPaz26-Jul-07 13:14 
QuestionI face aproblem in changing the video source Pin
Ali Habib18-Jun-07 11:04
Ali Habib18-Jun-07 11:04 
AnswerRe: I face aproblem in changing the video source Pin
Raghu_Super24-Sep-07 23:20
Raghu_Super24-Sep-07 23:20 
QuestionCapture a frame without preview Pin
RodrigoZaratin12-Jun-07 10:28
RodrigoZaratin12-Jun-07 10:28 
QuestionCapture audio and video from firewire dvcam Pin
Carnivash12-Jun-07 6:19
Carnivash12-Jun-07 6:19 
QuestionHow do i get pixel co-ordinates (pos) on clicking the frame playing in the pictureBox? Pin
Dharani_Prasad12-Apr-07 21:44
Dharani_Prasad12-Apr-07 21:44 
QuestionHow do i play a video in the picture box? [modified] Pin
Dharani_Prasad12-Apr-07 21:39
Dharani_Prasad12-Apr-07 21:39 
QuestionIs that possible to grap image without working with windows.form? [modified] Pin
F.E.L.I.X.24-Mar-07 11:13
F.E.L.I.X.24-Mar-07 11:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.